lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <65962a67329cc_2bb2020850@john.notmuch>
Date: Wed, 03 Jan 2024 19:47:51 -0800
From: John Fastabend <john.fastabend@...il.com>
To: Martin KaFai Lau <martin.lau@...ux.dev>, 
 Jakub Sitnicki <jakub@...udflare.com>, 
 John Fastabend <john.fastabend@...il.com>
Cc: rivendell7@...il.com, 
 kuniyu@...zon.com, 
 bpf@...r.kernel.org, 
 netdev@...r.kernel.org
Subject: Re: [PATCH bpf 1/5] bpf: sockmap, fix proto update hook to avoid dup
 calls

Martin KaFai Lau wrote:
> On 1/2/24 4:00 AM, Jakub Sitnicki wrote:
> > On Thu, Dec 21, 2023 at 03:23 PM -08, John Fastabend wrote:
> >> When sockets are added to a sockmap or sockhash we allocate and init a
> >> psock. Then update the proto ops with sock_map_init_proto the flow is
> >>
> >>    sock_hash_update_common
> >>      sock_map_link
> >>        psock = sock_map_psock_get_checked() <-returns existing psock
> >>        sock_map_init_proto(sk, psock)       <- updates sk_proto
> >>
> >> If the socket is already in a map this results in the sock_map_init_proto
> >> being called multiple times on the same socket. We do this because when
> >> a socket is added to multiple maps this might result in a new set of BPF
> >> programs being attached to the socket requiring an updated ops struct.
> >>
> >> This creates a rule where it must be safe to call psock_update_sk_prot
> >> multiple times. When we added a fix for UAF through unix sockets in patch
> >> 4dd9a38a753fc we broke this rule by adding a sock_hold in that path
> >> to ensure the sock is not released. The result is if a af_unix stream sock
> >> is placed in multiple maps it results in a memory leak because we call
> >> sock_hold multiple times with only a single sock_put on it.
> >>
> >> Fixes: 4dd9a38a753fc ("bpf: sockmap, fix proto update hook to avoid dup calls")
> 
> The Fixes tag looks wrong ;)
> 
> I changed it to
> 
> Fixes: 8866730aed51 ("bpf, sockmap: af_unix stream sockets need to hold ref for 
> pair sock")
> 
> >> Rebported-by: Xingwei Lee <xrivendell7@...il.com>
> > 
> > Nit: Typo ^
> 
> yep. fixed.
> 
> Also added the missing "test_sockmap_pass_prog__destroy(skel)" to the 
> sockmap_basic.c selftest.

Thanks! Appreciate it Martin.

> 
> Applied. Thanks for the fixes and the review.
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ