public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: Joe Perches <joe@perches.com>, Kees Cook <keescook@chromium.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	Cong Wang <xiyou.wangcong@gmail.com>,
	Jiri Pirko <jiri@resnulli.us>,
	"David S. Miller" <davem@davemloft.net>,
	Network Development <netdev@vger.kernel.org>
Subject: Re: [PATCH] net: sched: Fix memory exposure from short TCA_U32_SEL
Date: Mon, 27 Aug 2018 05:04:23 +0100	[thread overview]
Message-ID: <20180827040423.GB6515@ZenIV.linux.org.uk> (raw)
In-Reply-To: <alpine.DEB.2.21.1808262319000.2295@hadrien>

On Sun, Aug 26, 2018 at 11:35:17PM -0400, Julia Lawall wrote:

> * x = \(kmalloc\|kzalloc\|devm_kmalloc\|devm_kzalloc\)(...)

I can name several you've missed right off the top of my head -
vmalloc, kvmalloc, kmem_cache_alloc, kmem_cache_zalloc, variants
with _trace slapped on, and that is not to mention the things like
get_free_page or

void *my_k3wl_alloc(u64 n) // 'cause all artificial limits suck, that's why
{
	lots and lots of home-grown stats collection
	some tracepoints thrown in just for fun
	return kmalloc(n);
}

(and no, I'm not implying that net/sched folks had done anything of that
sort; I have seen that and worse in drivers, though)

> The * at the beginning of the line means to highlight what you are looking
> for, which is done by making a diff in which the highlighted line
> appears to be removed.

Umm...  Does that cover return, BTW?  Or something like
	T *barf;
	extern void foo(T *p);
	foo(kmalloc(sizeof(*barf)));


> The limitation is the ability to figure out the type of x.  If it is a
> local variable, Coccinelle should have no problem.  If it is a structure
> field, it may be necessary to provide command line arguments like
> 
> --all-includes --include-headers-for-types
> 
> --all-includes means to try to find all include files that are mentioned
> in the .c file.  The next stronger option is --recursive includes, which
> means include what all of the mentioned files include as well,
> recursively.  This tends to cause a major performance hit, because a lot
> of code is being parsed.  --include-headers-for-types heals a bit with
> that, as it only considers the header files when computing type
> information, and now when applying the rules.
> 
> With respect to ifdefs around variable declarations and structure field
> declaration, in these cases Coccinelle considers that it cannot make the
> ifdef have an if-like control flow, and so if considers the #ifdef, #else
> and #endif to be comments.  Thus it takes into account only the last type
> provided for a given variable.

[snip]

What about several variants of structure definition?  Because ifdefs around
includes do occur in the wild...

  reply	other threads:[~2018-08-27  4:04 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-26  5:58 [PATCH] net: sched: Fix memory exposure from short TCA_U32_SEL Kees Cook
2018-08-26  6:15 ` Al Viro
2018-08-26  6:19   ` Kees Cook
2018-08-26 17:30     ` Jamal Hadi Salim
2018-08-26 21:56       ` Kees Cook
2018-08-27 11:46         ` Jamal Hadi Salim
2018-08-27 14:08           ` Kees Cook
2018-08-27 14:26             ` Roman Mashak
2018-08-26 17:32     ` Al Viro
2018-08-26 18:57       ` Joe Perches
2018-08-26 21:24         ` Al Viro
2018-08-26 22:26           ` Joe Perches
2018-08-26 22:43             ` Al Viro
2018-08-27  2:00               ` Julia Lawall
2018-08-27  2:35                 ` Al Viro
2018-08-27  3:35                   ` Julia Lawall
2018-08-27  4:04                     ` Al Viro [this message]
2018-08-27  4:41                       ` Julia Lawall
2018-08-27  1:59             ` Julia Lawall
2018-08-26 22:57       ` Al Viro
2018-08-27 11:57         ` Jamal Hadi Salim
2018-08-27 21:31           ` Cong Wang
2018-08-28  0:03             ` Al Viro
2018-08-28 15:59               ` Al Viro
2018-08-31  4:03                 ` Al Viro
2018-08-29 19:07               ` Cong Wang
2018-08-29 21:33                 ` Al Viro
2018-08-26 21:22 ` David Miller

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=20180827040423.GB6515@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=davem@davemloft.net \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=joe@perches.com \
    --cc=julia.lawall@lip6.fr \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=xiyou.wangcong@gmail.com \
    /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