From: Steffen Klassert <steffen.klassert@secunet.com>
To: "Su Yanjun <suyj.fnst@cn.fujitsu.com>" <suyj.fnst@cn.fujitsu.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>, <davem@davemloft.net>,
<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] net: xfrm: Fix potential oops in xfrm_user_rcv_msg and array out of bounds
Date: Tue, 5 Mar 2019 08:31:17 +0100 [thread overview]
Message-ID: <20190305073117.GD14737@gauss3.secunet.de> (raw)
In-Reply-To: <d401c74f-43cd-7abe-a02d-7397b09b1784@cn.fujitsu.com>
On Tue, Mar 05, 2019 at 03:08:49PM +0800, Su Yanjun <suyj.fnst@cn.fujitsu.com> wrote:
> On 2019/3/5 14:49, Herbert Xu wrote:
>
> > On Sun, Mar 03, 2019 at 10:47:39PM -0500, Su Yanjun wrote:
> > > When i review xfrm_user.c code, i found some potentical bug in it.
> > >
> > > In xfrm_user_rcvmsg if type parameter from user space is set to
> > > XFRM_MSG_MAX or XFRM_MSG_NEWSADINFO or XFRM_MSG_NEWSPDINFO. It will cause
> > > xfrm_user_rcv_msg referring to null entry in xfrm_dispatch array.
> > >
> > > Signed-off-by: Su Yanjun <suyj.fnst@cn.fujitsu.com>
> > > ---
> > > net/xfrm/xfrm_user.c | 4 +++-
> > > 1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
> > > index a131f9f..d832783 100644
> > > --- a/net/xfrm/xfrm_user.c
> > > +++ b/net/xfrm/xfrm_user.c
> > > @@ -2630,11 +2630,13 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
> > > return -EOPNOTSUPP;
> > > type = nlh->nlmsg_type;
> > > - if (type > XFRM_MSG_MAX)
> > > + if (type >= XFRM_MSG_MAX)
> > > return -EINVAL;
> > Your patch is wrong. Please check the definition of XFRM_MSG_MAX.
>
> I see, thanks for your reply.
>
> type -= XFRM_MSG_BASE;
> link = &xfrm_dispatch[type];
> + if (!link)
> + return -EOPNOTSUPP;
>
> Here **link** may refer to null entry for special types such as
> XFRM_MSG_MAX or XFRM_MSG_NEWSADINFO or XFRM_MSG_NEWSPDINFO
> Am i miss something?
'link' is always a valid pointer into that array.
next prev parent reply other threads:[~2019-03-05 7:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-04 3:47 [PATCH] net: xfrm: Fix potential oops in xfrm_user_rcv_msg and array out of bounds Su Yanjun
2019-03-05 6:49 ` Herbert Xu
[not found] ` <d401c74f-43cd-7abe-a02d-7397b09b1784@cn.fujitsu.com>
2019-03-05 7:31 ` Steffen Klassert [this message]
2019-03-05 7:39 ` Su Yanjun <suyj.fnst@cn.fujitsu.com>
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=20190305073117.GD14737@gauss3.secunet.de \
--to=steffen.klassert@secunet.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=suyj.fnst@cn.fujitsu.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