* [PATCH v2] kernel: sysctl: ignore out-of-range taint bits introduced via kernel.tainted
@ 2020-05-12 22:39 Rafael Aquini
2020-05-13 0:39 ` Luis Chamberlain
0 siblings, 1 reply; 3+ messages in thread
From: Rafael Aquini @ 2020-05-12 22:39 UTC (permalink / raw)
To: linux-kernel, linux-fsdevel, mcgrof; +Cc: keescook, akpm, yzaikin, tytso
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=...'.
These interface, however, are open for any integer value
and this might 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 <aquini@redhat.com>
---
Changelog:
v2: simplify the bit iterator within proc_taint(),
and silently drop out-of-range bits (akpm)
kernel/sysctl.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 8a176d8727a3..fcd46fc41206 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2628,10 +2628,9 @@ static int proc_taint(struct ctl_table *table, int write,
* to everyone's atomic.h for this
*/
int i;
- 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;
--
2.25.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] kernel: sysctl: ignore out-of-range taint bits introduced via kernel.tainted
2020-05-12 22:39 [PATCH v2] kernel: sysctl: ignore out-of-range taint bits introduced via kernel.tainted Rafael Aquini
@ 2020-05-13 0:39 ` Luis Chamberlain
2020-05-13 0:54 ` Rafael Aquini
0 siblings, 1 reply; 3+ messages in thread
From: Luis Chamberlain @ 2020-05-13 0:39 UTC (permalink / raw)
To: Rafael Aquini; +Cc: linux-kernel, linux-fsdevel, keescook, akpm, yzaikin, tytso
On Tue, May 12, 2020 at 06:39:46PM -0400, Rafael Aquini wrote:
> 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=...'.
> These interface, however, are open for any integer value
> and this might 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 <aquini@redhat.com>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Luis
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] kernel: sysctl: ignore out-of-range taint bits introduced via kernel.tainted
2020-05-13 0:39 ` Luis Chamberlain
@ 2020-05-13 0:54 ` Rafael Aquini
0 siblings, 0 replies; 3+ messages in thread
From: Rafael Aquini @ 2020-05-13 0:54 UTC (permalink / raw)
To: Luis Chamberlain
Cc: linux-kernel, linux-fsdevel, keescook, akpm, yzaikin, tytso
On Wed, May 13, 2020 at 12:39:53AM +0000, Luis Chamberlain wrote:
> On Tue, May 12, 2020 at 06:39:46PM -0400, Rafael Aquini wrote:
> > 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=...'.
I just notice 2 minor 'screw ups' on my part in the commit log:
> > These interface, however, are open for any integer value
This one probably needs to be reprhased as:
"The interface, however, is ... "
> > and this might an invalid set of flags being committed to
and I'm missing a verb here, as it should read:
"and this might cause an invalid ... "
I hope these are easy fixes, in the pre-merge step. (Sorry!)
> > 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 <aquini@redhat.com>
>
> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
>
Thanks!
-- Rafael
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-13 0:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-12 22:39 [PATCH v2] kernel: sysctl: ignore out-of-range taint bits introduced via kernel.tainted Rafael Aquini
2020-05-13 0:39 ` Luis Chamberlain
2020-05-13 0:54 ` Rafael Aquini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.