From: Sabrina Dubroca <sd@queasysnail.net>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: netdev@vger.kernel.org, Steffen Klassert <steffen.klassert@secunet.com>
Subject: Re: [PATCH net] xfrm: fix stack access out of bounds with CONFIG_XFRM_SUB_POLICY
Date: Fri, 21 Apr 2017 14:05:31 +0200 [thread overview]
Message-ID: <20170421120531.GA12502@bistromath.localdomain> (raw)
In-Reply-To: <20170421110643.GA13809@gondor.apana.org.au>
2017-04-21, 19:06:44 +0800, Herbert Xu wrote:
> On Fri, Apr 21, 2017 at 12:14:51PM +0200, Sabrina Dubroca wrote:
> > When CONFIG_XFRM_SUB_POLICY=y, xfrm_dst stores a copy of the flowi for
> > that dst. Unfortunately, the code that allocates and fills this copy
> > doesn't care about what type of flowi (flowi, flowi4, flowi6) gets
> > passed. In multiple code paths (from raw_sendmsg, from TCP when
> > replying to a FIN, in vxlan, geneve, and gre), the flowi that gets
> > passed to xfrm is actually an on-stack flowi4, so we end up reading
> > memory on the stack past the end of the flowi4 struct.
> >
> > Since xfrm_dst->origin isn't used anywhere, just get rid of it.
> > xfrm_dst->partner isn't used either, so get rid of that too.
> >
> > Fixes: ca116922afa8 ("xfrm: Eliminate "fl" and "pol" args to xfrm_bundle_ok().")
>
> The commit you refer to here doesn't seem to have caused this bug.
You're right. I had a note about that but it got lost. The bug
(ignoring what flavor of flowi is passed) is older than that (from the
introduction of subpolicies, I suspect, but I would have to dig more
into the history), but this commit removed the last uses of
origin/partner.
Looking into raw_sendmsg(), this code may have been safe before
9d6ec938019c ("ipv4: Use flowi4 in public route lookup interfaces."),
since full flowi were used.
If we want a fix for kernels that don't have ca116922afa8, we would
probably need to take the size of the flowi* struct depending on the
address family passed to xfrm_resolve_and_create_bundle().
I'm not sure how to proceed here, any advice?
Thanks,
--
Sabrina
next prev parent reply other threads:[~2017-04-21 12:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-21 10:14 [PATCH net] xfrm: fix stack access out of bounds with CONFIG_XFRM_SUB_POLICY Sabrina Dubroca
2017-04-21 11:06 ` Herbert Xu
2017-04-21 12:05 ` Sabrina Dubroca [this message]
2017-04-24 7:59 ` Herbert Xu
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=20170421120531.GA12502@bistromath.localdomain \
--to=sd@queasysnail.net \
--cc=herbert@gondor.apana.org.au \
--cc=netdev@vger.kernel.org \
--cc=steffen.klassert@secunet.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