Skip to content

Commit acbc372

Browse files
WOnder93pcmoore
authored andcommitted
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: [email protected] Fixes: ee1a84f ("selinux: overhaul sidtab to fix bug and improve performance") Signed-off-by: Ondrej Mosnacek <[email protected]> Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Paul Moore <[email protected]>
1 parent ea74a68 commit acbc372

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

security/selinux/ss/sidtab.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ static int sidtab_reverse_lookup(struct sidtab *s, struct context *context,
286286
++count;
287287
}
288288

289+
/* bail out if we already reached max entries */
290+
rc = -EOVERFLOW;
291+
if (count >= SIDTAB_MAX)
292+
goto out_unlock;
293+
289294
/* insert context into new entry */
290295
rc = -ENOMEM;
291296
dst = sidtab_do_lookup(s, count, 1);

0 commit comments

Comments
 (0)