mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: jesper.juhl@gmail.com
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	gem@asplinux.ru, davem@redhat.com, kuznet@ms2.inr.ac.ru,
	kunihiro@ipinfusion.com, miyazawa@linux-ipv6.org,
	derek@ihtfp.com
Subject: Re: [PATCH] potential NULL pointer deref in net/key/af_key.c
Date: Mon, 27 Nov 2006 13:53:33 -0800 (PST)	[thread overview]
Message-ID: <20061127.135333.28790424.davem@davemloft.net> (raw)
In-Reply-To: <200611272244.08189.jesper.juhl@gmail.com>

From: Jesper Juhl <jesper.juhl@gmail.com>
Date: Mon, 27 Nov 2006 22:44:07 +0100

> In net/key/af_key.c::pfkey_send_policy_notify() there's a check at the 
> beginning of the function : 
> 
>     if (xp && xp->type != XFRM_POLICY_TYPE_MAIN)
> 
> this implies that 'xp' may be null when the function is called. But later 
> on in the function we have this code : 
> 
>     return key_notify_policy(xp, dir, c);
> 
> key_notify_policy() passes 'xp' to pfkey_xfrm_policy2msg_prep() that pass
> it on to pfkey_xfrm_policy2msg_size() which dereferences it.
> key_notify_policy() also passes 'xp' to pfkey_xfrm_policy2msg() which 
> also dereferences it.
> 
> So, in pfkey_send_policy_notify() in the cases where we end up calling 
> key_notify_policy(), we should test 'xp' for NULL.
> 
> (note: patch is compile tested only)
> 
> 
> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>

We really need to teach your automated tool about context.

The NULL case can only occur for XFRM_MSG_FLUSHPOLICY.

Look at the km_policy_notify() call sites.  You can even see from the
net/xfrm/xfrm_user.c:xfrm_send_policy_notify() implementation of this
callback that for XFRM_MSG_FLUSHPOLICY the "xp" argument is ignored.

       reply	other threads:[~2006-11-27 21:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200611272244.08189.jesper.juhl@gmail.com>
2006-11-27 21:53 ` David Miller [this message]
2006-11-27 21:56   ` Jesper Juhl

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=20061127.135333.28790424.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=davem@redhat.com \
    --cc=derek@ihtfp.com \
    --cc=gem@asplinux.ru \
    --cc=jesper.juhl@gmail.com \
    --cc=kunihiro@ipinfusion.com \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miyazawa@linux-ipv6.org \
    --cc=netdev@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®