public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sabrina Dubroca <sd@queasysnail.net>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Hangyu Hua <hbh25y@gmail.com>, Florian Westphal <fw@strlen.de>,
	borisp@nvidia.com, john.fastabend@gmail.com, davem@davemloft.net,
	edumazet@google.com, pabeni@redhat.com, davejwatson@fb.com,
	aviadye@mellanox.com, ilyal@mellanox.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: tls: fix possible race condition between do_tls_getsockopt_conf() and do_tls_setsockopt_conf()
Date: Fri, 24 Feb 2023 21:22:43 +0100	[thread overview]
Message-ID: <Y/kck0/+NB+Akpoy@hog> (raw)
In-Reply-To: <20230224105508.4892901f@kernel.org>

2023-02-24, 10:55:08 -0800, Jakub Kicinski wrote:
> On Fri, 24 Feb 2023 13:06:06 +0100 Florian Westphal wrote:
> > Hangyu Hua <hbh25y@gmail.com> wrote:
> > > ctx->crypto_send.info is not protected by lock_sock in
> > > do_tls_getsockopt_conf(). A race condition between do_tls_getsockopt_conf()
> > > and do_tls_setsockopt_conf() can cause a NULL point dereference or
> > > use-after-free read when memcpy.  
> > 
> > Its good practice to quote the relevant parts of the splat here.
> 
> Right, the bug and the fix seem completely bogus.
> Please make sure the bugs are real and the fixes you sent actually 
> fix them.

I suggested a change of locking in do_tls_getsockopt_conf this
morning [1]. The issue reported last seemed valid, but this patch is not
at all what I had in mind.
[1] https://lore.kernel.org/all/Y/ht6gQL+u6fj3dG@hog/

do_tls_setsockopt_conf fills crypto_info immediately from what
userspace gives us (and clears it on exit in case of failure), which
getsockopt could see since it's not locking the socket when it checks
TLS_CRYPTO_INFO_READY. So getsockopt would progress up to the point it
finally locks the socket, but if setsockopt failed, we could have
cleared TLS_CRYPTO_INFO_READY and freed iv/rec_seq.

-- 
Sabrina


  reply	other threads:[~2023-02-24 20:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-24 10:58 [PATCH] net: tls: fix possible race condition between do_tls_getsockopt_conf() and do_tls_setsockopt_conf() Hangyu Hua
2023-02-24 12:06 ` Florian Westphal
2023-02-24 18:55   ` Jakub Kicinski
2023-02-24 20:22     ` Sabrina Dubroca [this message]
2023-02-24 21:06       ` Jakub Kicinski
2023-02-24 21:48         ` Sabrina Dubroca
2023-02-24 22:17           ` Jakub Kicinski
2023-02-27  3:26             ` Hangyu Hua
2023-02-27 19:07               ` Jakub Kicinski
2023-02-28  1:48                 ` Hangyu Hua

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=Y/kck0/+NB+Akpoy@hog \
    --to=sd@queasysnail.net \
    --cc=aviadye@mellanox.com \
    --cc=borisp@nvidia.com \
    --cc=davejwatson@fb.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=hbh25y@gmail.com \
    --cc=ilyal@mellanox.com \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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