diff options
author | Rafael Aquini <[email protected]> | 2020-06-07 21:40:51 -0700 |
---|---|---|
committer | Linus Torvalds <[email protected]> | 2020-06-08 11:05:56 -0700 |
commit | e77132e75845470065768e2205727e6be52cb7f4 (patch) | |
tree | dd222e1900ff7b29db7f001e1a4fcb353a9935cc | |
parent | 60c958d8df9cfc40b745d6cd583cfbfa7525ead6 (diff) |
kernel/sysctl.c: ignore out-of-range taint bits introduced via kernel.tainted
Users with SYS_ADMIN capability can add arbitrary taint flags to the
running kernel by writing to /proc/sys/kernel/tainted or issuing the
command 'sysctl -w kernel.tainted=...'. This interface, however, is
open for any integer value and this might cause an invalid set of flags
being committed to the tainted_mask bitset.
This patch introduces a simple way for proc_taint() to ignore any
eventual invalid bit coming from the user input before committing those
bits to the kernel tainted_mask.
Signed-off-by: Rafael Aquini <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Reviewed-by: Luis Chamberlain <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Iurii Zaikin <[email protected]>
Cc: "Theodore Ts'o" <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r-- | kernel/sysctl.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index f69d581d39c3..db1ce7af2563 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -880,10 +880,9 @@ static int proc_taint(struct ctl_table *table, int write, * Poor man's atomic or. Not worth adding a primitive * to everyone's atomic.h for this */ - for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { - if ((tmptaint >> i) & 1) + for (i = 0; i < TAINT_FLAGS_COUNT; i++) + if ((1UL << i) & tmptaint) add_taint(i, LOCKDEP_STILL_OK); - } } return err; |