From: Tycho Andersen <tycho@tycho.ws>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: linux-sparse@vger.kernel.org,
kernel-hardening@lists.openwall.com,
linux-kernel@vger.kernel.org
Subject: Re: [RFC v1] copy_{to,from}_user(): only inline when !__CHECKER__
Date: Sun, 9 Dec 2018 14:56:58 -0700 [thread overview]
Message-ID: <20181209215658.GG30796@cisco> (raw)
In-Reply-To: <20181209214600.GC2217@ZenIV.linux.org.uk>
On Sun, Dec 09, 2018 at 09:46:00PM +0000, Al Viro wrote:
> On Sun, Dec 09, 2018 at 02:25:23PM -0700, Tycho Andersen wrote:
>
> > > Which sparse checks do not trigger? Explain, please - as it is, I had been
> > > unable to guess what could "specifically looks for a call instruction" refer
> > > to.
> >
> > In sparse.c there's check_call_instruction(), which is triggered when
> > there's an instruction of OP_CALL type in the basic block. This simply
> > compares against the name of the call target to determine whether or
> > not to call check_ctu().
>
> Oh, that Linus' experiment with "look for huge constant size argument
> to memcpy() et.al."? Frankly, it's not only the wrong place to put the
> checks, but breaking inlining loses the _real_ "known constant size"
> checks in there.
>
> I don't know if the check_ctu thing has ever caught a bug... What kind of
> checks do you want to add? Because this place is almost certainly wrong
> for anything useful...
Yeah, agreed that the static size check doesn't seem particularly
useful. I linked to these in the other mail, but the top two patches
here are what I was playing with:
https://github.com/tych0/sparse/commits/check-as-infoleaks
> If anything, I would suggest simulating this behaviour with something like
> if (__builtin_constant_p(size) && size > something)
> /* something that would trigger a warning */
> _inside_ copy_from_user()/copy_to_user() and to hell with name-recognizing
> magic...
Hmm. I wonder if we couldn't do some size checking with the argument
like this instead. Thanks for the idea, I'll play around with it.
Tycho
prev parent reply other threads:[~2018-12-09 21:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-09 20:44 [RFC v1] copy_{to,from}_user(): only inline when !__CHECKER__ Tycho Andersen
2018-12-09 21:02 ` Al Viro
2018-12-09 21:25 ` Tycho Andersen
2018-12-09 21:39 ` Luc Van Oostenryck
2018-12-09 21:53 ` Tycho Andersen
2018-12-09 21:56 ` Al Viro
2018-12-09 22:08 ` Luc Van Oostenryck
2018-12-09 21:46 ` Al Viro
2018-12-09 21:56 ` Tycho Andersen [this message]
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=20181209215658.GG30796@cisco \
--to=tycho@tycho.ws \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sparse@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).