lkml.org 
[lkml]   [2023]   [Feb]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] net: tls: fix possible race condition between do_tls_getsockopt_conf() and do_tls_setsockopt_conf()
    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

    \
     
     \ /
      Last update: 2023-03-27 00:35    [W:4.441 / U:0.036 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site