All of lore.kernel.org
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Abhishek Shah <abhishek.shah@columbia.edu>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	netdev@vger.kernel.org, pabeni@redhat.com,
	steffen.klassert@secunet.com, linux-kernel@vger.kernel.org,
	Gabriel Ryan <gabe@cs.columbia.edu>,
	Fan Du <fan.du@windriver.com>
Subject: Re: Race 1 in net/xfrm/xfrm_algo.c
Date: Fri, 29 Jul 2022 10:30:31 +0800	[thread overview]
Message-ID: <YuNGR/5U5pSo6YM3@gondor.apana.org.au> (raw)
In-Reply-To: <CAEHB249ygptvp9wpynMF7zZ2Kcet0+bwLVuVg5UReZHOU1+8HA@mail.gmail.com>

On Thu, Jul 28, 2022 at 08:00:00PM -0400, Abhishek Shah wrote:
> Dear Herbert,
> 
> Thanks for your quick reply and sorry for not being more clear about the
> inconsistencies. We identified security implications when algorithms
> disappear or reappear during the execution of *compose_sadb_supported*.
> 
> In more detail,
> 
> 1) If after *xfrm_count_pfkey_auth_supported* has finished counting the
> available algos, a secondary thread changes the availability of an algo
> through *xfrm_probe_algs*, it will return an incorrect number of available
> algorithms. If an algo was added during the racing access, the code
> allocates a buffer that is smaller than the number of available algorithms
> at net/key/af_key.c#L1619
> <https://elixir.bootlin.com/linux/v5.18-rc5/source/net/key/af_key.c#L1619>.
> This will result in an out of bounds write when the buffer is later
> populated at net/key/af_key.c#L1657
> <https://elixir.bootlin.com/linux/v5.18-rc5/source/net/key/af_key.c#L1657>.

OK this is a real bug caused by this commit:

commit 283bc9f35bbbcb0e9ab4e6d2427da7f9f710d52d
Author: Fan Du <fan.du@windriver.com>
Date:   Thu Nov 7 17:47:50 2013 +0800

    xfrm: Namespacify xfrm state/policy locks

It neglected to convert xfrm_probe_algs to namespaces so the
previous assumption of exclusive ownership of xfrm_algo_list
by the current afkey request is no longer true.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

  parent reply	other threads:[~2022-07-29  2:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAEHB24-9hXY+TgQKxJB4bE9a9dFD9C+Lan+ShBwpvwaHVAGMFg@mail.gmail.com>
2022-07-22  3:16 ` Race 1 in net/xfrm/xfrm_algo.c Herbert Xu
     [not found]   ` <CAEHB249ygptvp9wpynMF7zZ2Kcet0+bwLVuVg5UReZHOU1+8HA@mail.gmail.com>
2022-07-29  2:30     ` Herbert Xu [this message]
2022-08-04 10:03       ` [PATCH] af_key: Do not call xfrm_probe_algs in parallel Herbert Xu
2022-08-09  5:47         ` Steffen Klassert
2022-08-22 16:19         ` Gabriel Ryan

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=YuNGR/5U5pSo6YM3@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=abhishek.shah@columbia.edu \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fan.du@windriver.com \
    --cc=gabe@cs.columbia.edu \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --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 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.