From: Rafael Aquini <aquini@redhat.com>
To: Luis Chamberlain <mcgrof@kernel.org>
Cc: linux-doc@vger.kernel.org, Takashi Iwai <tiwai@suse.de>,
Jeff Mahoney <jeffm@suse.com>,
bhe@redhat.com, corbet@lwn.net, Laura Abbott <labbott@redhat.com>,
dyoung@redhat.com, Ann Davis <AnDavis@suse.com>,
Richard Palethorpe <rpalethorpe@suse.de>,
keescook@chromium.org, Jiri Kosina <jikos@kernel.org>,
cai@lca.pw, Adrian Bunk <bunk@kernel.org>,
Tso Ted <tytso@mit.edu>, Jessica Yu <jeyu@suse.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
rdunlap@infradead.org, kexec@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
akpm@linux-foundation.org,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH v2] kernel: add panic_on_taint
Date: Thu, 7 May 2020 18:06:06 -0400 [thread overview]
Message-ID: <20200507220606.GK205881@optiplex-lnx> (raw)
In-Reply-To: <20200507203340.GZ11244@42.do-not-panic.com>
On Thu, May 07, 2020 at 08:33:40PM +0000, Luis Chamberlain wrote:
> On Thu, May 07, 2020 at 02:47:05PM -0400, Rafael Aquini wrote:
> > On Thu, May 07, 2020 at 02:43:16PM -0400, Rafael Aquini wrote:
> > > On Thu, May 07, 2020 at 06:22:57PM +0000, Luis Chamberlain wrote:
> > > > On Thu, May 07, 2020 at 02:06:31PM -0400, Rafael Aquini wrote:
> > > > > diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> > > > > index 8a176d8727a3..b80ab660d727 100644
> > > > > --- a/kernel/sysctl.c
> > > > > +++ b/kernel/sysctl.c
> > > > > @@ -1217,6 +1217,13 @@ static struct ctl_table kern_table[] = {
> > > > > .extra1 = SYSCTL_ZERO,
> > > > > .extra2 = SYSCTL_ONE,
> > > > > },
> > > > > + {
> > > > > + .procname = "panic_on_taint",
> > > > > + .data = &panic_on_taint,
> > > > > + .maxlen = sizeof(unsigned long),
> > > > > + .mode = 0644,
> > > > > + .proc_handler = proc_doulongvec_minmax,
> > > > > + },
> > > >
> > > > You sent this out before I could reply to the other thread on v1.
> > > > My thoughts on the min / max values, or lack here:
> > > >
> > > > Valid range doesn't mean "currently allowed defined" masks.
> > > >
> > > > For example, if you expect to panic due to a taint, but a new taint type
> > > > you want was not added on an older kernel you would be under a very
> > > > *false* sense of security that your kernel may not have hit such a
> > > > taint, but the reality of the situation was that the kernel didn't
> > > > support that taint flag only added in future kernels.
> > > >
> > > > You may need to define a new flag (MAX_TAINT) which should be the last
> > > > value + 1, the allowed max values would be
> > > >
> > > > (2^MAX_TAINT)-1
> > > >
> > > > or
> > > >
> > > > (1<<MAX_TAINT)-1
> > > >
> > > > Since this is to *PANIC* I think we do want to test ranges and ensure
> > > > only valid ones are allowed.
> > > >
> > >
> > > Ok. I'm thinking in:
> > >
> > > diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> > > index 8a176d8727a3..ee492431e7b0 100644
> > > --- a/kernel/sysctl.c
> > > +++ b/kernel/sysctl.c
> > > @@ -1217,6 +1217,15 @@ static struct ctl_table kern_table[] = {
> > > .extra1 = SYSCTL_ZERO,
> > > .extra2 = SYSCTL_ONE,
> > > },
> > > + {
> > > + .procname = "panic_on_taint",
> > > + .data = &panic_on_taint,
> > > + .maxlen = sizeof(unsigned long),
> > > + .mode = 0644,
> > > + .proc_handler = proc_doulongvec_minmax,
> > > + .extra1 = SYSCTL_ZERO,
> > > + .extra2 = (1 << TAINT_FLAGS_COUNT << 1) - 1,
> > ^^^^^^^^
> > Without that crap, obviously. Sorry. That was a screw up on my side,
> > when copyin' and pasting.
>
> I really think that the implications of this needs a bit further review,
> hence the wider CCs.
>
> Since this can trivially crash a system, I think we need to be careful
> about this value. First, proc_doulongvec_minmax() will not suffice alone,
> we'll *at least* want to check for capable(CAP_SYS_ADMIN)) as in
> proc_taint(). Second first note that we *always* build proc_taint(), if
> just CONFIG_PROC_SYSCTL is enabled. That has been the way since it got
> merged via commit 34f5a39899f3f ("Add TAINT_USER and ability to set
> taint flags from userspace") since v2.6.21. We need to evaluate if this
> little *new* knob you are introducing merits its own kconfig tucked away
> under debugging first. The ship has already sailed for proc_taint().
> Anyone with CAP_SYS_ADMIN can taint.
>
> The good thing is that proc_taint() added its own TAINT_USER, *but*, hey
> it didn't use it. A panic-on-taint system would be able to tell if a
> panic was caused by proc_taint() throught the stack trace only.
> If panic-on-taint proc was used *later* after a custom taint was set
> or happened naturally, no panic would trigger since your panic-on-taint
> check on your patch only happens on add_taint(). This means that for
> those thinking about using this for QA or security purposes, the only
> sensible *reliable* way to use panic-on-taint would be through cmdline,
> from boot. Post-boot means to enable this would either need to check
> existing taint flags, or we'd want to a way to check if this was not
> added post boot. Also, a post-booteed system with panic-on-taint could
> easily allow for reductions of the intended goal, thereby allowing one
> to cheat.
>
> I think a new TAINT_MODIFIED for use when proc_taint() is used is worth
> considering. Ted? Even though 'M' is taken -- I think its silly to rely
> on the character to be anything of meaning, once we run out of the
> alphabet letters that will be the way anyway, unless we-redo this a bit.
> Note we use value for when this is on and off, typically an empty space
> when a taint is not seen.
>
> The good thing is that proc_taint() only *increments* taint, it doesn't
> remove taints.
>
> Are we OK with panic-on-taint only with CAP_SYS_ADMIN?
>
> I can see this building up to a "testing" solution to ensure / gaurantee
> no bugs have happened during QA, but since QA would want the same binary
> for production it is hard to see this enabled for QA but not production.
> To resolve that last concern, if we do go with moving this under a
> kconfig value, a simple cmdline append would address the concerns. Ie,
> even if you enabled this mechanism through its kconfig you would not be
> able to modify the panic-on-tain unless you passed a cmdline option.
>
> Note that Vlastimil has some patches which are visible on linux-next,
> but not yet merged on Linus' tree, which enable these params to be set
> on the cmdline too now, so perhaps yet-another cmdline param is not
> needed anymore.
>
> I *think* that a cmdline route to enable this would likely remove the
> need for the kernel config for this. But even with Vlastimil's work
> merged, I think we'd want yet-another value to enable / disable this
> feature. Do we need yet-another-taint flag to tell us that this feature
> was enabled?
>
I guess it makes sense to get rid of the sysctl interface for
proc_on_taint, and only keep it as a cmdline option.
But the real issue seems to be, regardless we go with a cmdline-only option
or not, the ability of proc_taint() to set any arbitrary taint flag
other than just marking the kernel with TAINT_USER.
-- Rafael
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2020-05-07 22:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-07 18:06 [PATCH v2] kernel: add panic_on_taint Rafael Aquini
2020-05-07 18:22 ` Luis Chamberlain
2020-05-07 18:43 ` Rafael Aquini
2020-05-07 18:47 ` Rafael Aquini
2020-05-07 20:33 ` Luis Chamberlain
2020-05-07 22:06 ` Rafael Aquini [this message]
2020-05-07 22:25 ` Luis Chamberlain
2020-05-08 12:47 ` Rafael Aquini
2020-05-09 3:48 ` Luis Chamberlain
2020-05-09 14:56 ` Rafael Aquini
2020-05-07 18:50 ` Luis Chamberlain
2020-05-07 18:53 ` Rafael Aquini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200507220606.GK205881@optiplex-lnx \
--to=aquini@redhat.com \
--cc=AnDavis@suse.com \
--cc=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=bunk@kernel.org \
--cc=cai@lca.pw \
--cc=corbet@lwn.net \
--cc=dyoung@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=jeffm@suse.com \
--cc=jeyu@suse.de \
--cc=jikos@kernel.org \
--cc=keescook@chromium.org \
--cc=kexec@lists.infradead.org \
--cc=labbott@redhat.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=rdunlap@infradead.org \
--cc=rpalethorpe@suse.de \
--cc=tiwai@suse.de \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox