All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: Jan Engelhardt <jengelh@inai.de>,
	Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>,
	netfilter-devel@vger.kernel.org
Subject: Re: [PATCH 1/3] nfnetlink: Check callbacks before using those in nfnetlink_rcv_msg
Date: Wed, 4 Jul 2012 22:54:03 +0200	[thread overview]
Message-ID: <20120704205403.GA22228@1984> (raw)
In-Reply-To: <20120630085425.GE13074@breakpoint.cc>

On Sat, Jun 30, 2012 at 10:54:25AM +0200, Florian Westphal wrote:
> Jan Engelhardt <jengelh@inai.de> wrote:
> > On Friday 2012-06-29 13:15, Pablo Neira Ayuso wrote:
> > >On Thu, Jun 28, 2012 at 03:57:47PM +0300, Tomasz Bursztyka wrote:
> > >> ---
> > >> @@ -184,9 +184,11 @@ replay:
> > >>  					lockdep_is_held(&nfnl_mutex)) != ss ||
> > >>  			    nfnetlink_find_client(type, ss) != nc)
> > >>  				err = -EAGAIN;
> > >> -			else
> > >> +			else if (nc->call)
> > >>  				err = nc->call(net->nfnl, skb, nlh,
> > >>  						   (const struct nlattr **)cda);
> > >> +			else
> > >> +				err = -EINVAL;
> > >
> > >Hm, I think this is redundant. We got the ipset problem fixed with
> > >2/3. I think we can add some BUG_ON instead as all nc->call needs to
> > >be defined. Otherwise, spot a bug message so it is fixed.
> > 
> > Seriously, we have run into NULL dereferences at this place so often
> > that it should not be discarded as a PEBKAC issue. Yes, it is the
> > programmer's responsibility to fill in .call, but error handling is
> > anytime better than driving one's machine into the pit stop due to a
> > NULL deref or BUG_ON.
> 
> Agreed.  I think this should be WARN_ON_ONCE + ret EINVAL.
> We also do this with various places that e.g. fill netlink
> messages so that adding new attributes without bumping allocation
> sizes is reported without crashes.  Since we've started to move
> the performance-critical nfnetlink stuff over to ->call_rcu
> the extra NULL test should not harm fastpath either.

OK, fair enough. I've enqueued this to nf-next.

  reply	other threads:[~2012-07-04 20:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-28 12:57 [PATCH 0/3] Nfnetlink and ipset fixes Tomasz Bursztyka
2012-06-28 12:57 ` [PATCH 1/3] nfnetlink: Check callbacks before using those in nfnetlink_rcv_msg Tomasz Bursztyka
2012-06-29 11:15   ` Pablo Neira Ayuso
2012-06-29 19:03     ` Jan Engelhardt
2012-06-30  8:54       ` Florian Westphal
2012-07-04 20:54         ` Pablo Neira Ayuso [this message]
2012-06-28 12:57 ` [PATCH 2/3] ipset: Handle properly an IPSET_CMD_NONE Tomasz Bursztyka
2012-06-28 14:40   ` Jozsef Kadlecsik
2012-06-29 11:13     ` Pablo Neira Ayuso
2012-06-28 12:57 ` [PATCH 3/3] nfnetlink: Unlock a previously locked rcu_read in nfnetlink_rcv_msg Tomasz Bursztyka
2012-06-28 13:30   ` Eric Dumazet
2012-06-29 11:13     ` Pablo Neira Ayuso

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=20120704205403.GA22228@1984 \
    --to=pablo@netfilter.org \
    --cc=fw@strlen.de \
    --cc=jengelh@inai.de \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=tomasz.bursztyka@linux.intel.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 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.