linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>,
	syzbot <syzbot+5af9a90dad568aa9f611@syzkaller.appspotmail.com>,
	David Miller <davem@davemloft.net>,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	Jiri Pirko <jiri@resnulli.us>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux Kernel Network Developers <netdev@vger.kernel.org>,
	syzkaller-bugs <syzkaller-bugs@googlegroups.com>
Subject: Re: KASAN: slab-out-of-bounds Read in __nla_put_nohdr
Date: Thu, 23 Jan 2020 10:13:13 +0300	[thread overview]
Message-ID: <20200123071313.GI1847@kadam> (raw)
In-Reply-To: <7056f971-8fae-ce88-7e9a-7983e4f57bb2@gmail.com>

On Wed, Jan 22, 2020 at 12:33:17PM -0800, Eric Dumazet wrote:
> 
> 
> On 1/22/20 12:27 PM, Cong Wang wrote:
> > On Tue, Jan 21, 2020 at 11:55 AM Eric Dumazet <eric.dumazet@gmail.com> wrote:
> >> em_nbyte_change() sets
> >> em->datalen = sizeof(*nbyte) + nbyte->len;
> >>
> >> But later tcf_em_validate() overwrites em->datalen with the user provide value (em->datalen = data_len; )
> >> which can be bigger than the allocated (kmemdup) space in em_nbyte_change()
> >>
> >> Should net/sched/em_nbyte.c() provide a dump() handler to avoid this issue ?
> > 
> > I think for those who implement ->change() we should leave
> > ->datalen untouched to respect their choices. I don't see why
> > we have to set it twice.
> > 
> >
> 
> Agreed, but we need to audit them to make sure all of them are setting ->datalen
> 

Smatch provides a way to do this sort of search:

$ smdb where tcf_ematch datalen
net/sched/ematch.c             | tcf_em_validate                | (struct tcf_ematch)->datalen | 0-65519
net/sched/ematch.c             | tcf_em_tree_validate           | (struct tcf_ematch)->datalen | 0
net/sched/em_ipt.c             | em_ipt_change                  | (struct tcf_ematch)->datalen | 16-131080
net/sched/em_meta.c            | em_meta_change                 | (struct tcf_ematch)->datalen | 48
net/sched/em_text.c            | em_text_change                 | (struct tcf_ematch)->datalen | 16
net/sched/em_canid.c           | em_canid_change                | (struct tcf_ematch)->datalen | 276-4268
net/sched/em_ipset.c           | em_ipset_change                | (struct tcf_ematch)->datalen | 4
net/sched/em_nbyte.c           | em_nbyte_change                | (struct tcf_ematch)->datalen | 4-4099

It is imperfect...  The main drawback is that it's based on my
allmodconfig which might not include every function.  But always there
are other bugs to be discovered.

regards,
dan carpenter


      parent reply	other threads:[~2020-01-23  7:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-21 19:47 KASAN: slab-out-of-bounds Read in __nla_put_nohdr syzbot
2020-01-21 19:55 ` Eric Dumazet
2020-01-22 20:27   ` Cong Wang
2020-01-22 20:33     ` Eric Dumazet
2020-01-22 22:09       ` Cong Wang
2020-01-23  7:13       ` Dan Carpenter [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=20200123071313.GI1847@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=syzbot+5af9a90dad568aa9f611@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --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;
as well as URLs for NNTP newsgroup(s).