UPSTREAM: selinux: check sidtab limit before adding a new entry
We need to error out when trying to add an entry above SIDTAB_MAX in sidtab_reverse_lookup() to avoid overflow on the odd chance that this happens. Cc: stable@vger.kernel.org Fixes: ee1a84fdfeed ("selinux: overhaul sidtab to fix bug and improve performance") Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com> Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Paul Moore <paul@paul-moore.com> Change-Id: I17468cf0db77ba30dd333c73f742ab17072d4ef0 (cherry picked from commit acbc372e6109c803cbee4733769d02008381740f) Bug: 140252993 Signed-off-by: Jeff Vander Stoep <jeffv@google.com> Signed-off-by: Rapherion Rollerscaperers <rapherion@raphielgang.org> Signed-off-by: Chenyang Zhong <zhongcy95@gmail.com> Signed-off-by: Sorayukii <sorayukii69@gmail.com>
This commit is contained in:
parent
6b655dcbba
commit
20399d61d3
1 changed files with 5 additions and 0 deletions
|
|
@ -285,6 +285,11 @@ static int sidtab_reverse_lookup(struct sidtab *s, struct context *context,
|
|||
++count;
|
||||
}
|
||||
|
||||
/* bail out if we already reached max entries */
|
||||
rc = -EOVERFLOW;
|
||||
if (count >= SIDTAB_MAX)
|
||||
goto out_unlock;
|
||||
|
||||
/* insert context into new entry */
|
||||
rc = -ENOMEM;
|
||||
dst = sidtab_do_lookup(s, count, 1);
|
||||
|
|
|
|||
Loading…
Reference in a new issue