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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241008142125.81471-1-kuniyu@amazon.com>
Date: Tue, 8 Oct 2024 07:21:25 -0700
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <edumazet@...gle.com>
CC: <davem@...emloft.net>, <dsahern@...nel.org>, <kuba@...nel.org>,
	<kuni1840@...il.com>, <kuniyu@...zon.com>, <martin.lau@...nel.org>,
	<netdev@...r.kernel.org>, <pabeni@...hat.com>
Subject: Re: [PATCH v1 net] tcp/dccp: Don't use timer_pending() in reqsk_queue_unlink().

From: Eric Dumazet <edumazet@...gle.com>
Date: Tue, 8 Oct 2024 11:54:21 +0200
> On Tue, Oct 8, 2024 at 1:53 AM Kuniyuki Iwashima <kuniyu@...zon.com> wrote:
> >
> > From: Jakub Kicinski <kuba@...nel.org>
> > Date: Mon, 7 Oct 2024 16:26:10 -0700
> > > On Mon, 7 Oct 2024 07:15:57 -0700 Kuniyuki Iwashima wrote:
> > > > Martin KaFai Lau reported use-after-free [0] in reqsk_timer_handler().
> > > >
> > > >   """
> > > >   We are seeing a use-after-free from a bpf prog attached to
> > > >   trace_tcp_retransmit_synack. The program passes the req->sk to the
> > > >   bpf_sk_storage_get_tracing kernel helper which does check for null
> > > >   before using it.
> > > >   """
> > >
> > > I think this crashes a bunch of selftests, example:
> > >
> > > https://netdev-3.bots.linux.dev/vmksft-nf-dbg/results/805581/8-nft-queue-sh/stderr
> >
> > Oops, sorry, I copy-and-pasted __inet_csk_reqsk_queue_drop()
> > for different reqsk.  I'll squash the diff below.
> >
> > ---8<---
> > diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
> > index 36f03d51356e..433c80dc57d5 100644
> > --- a/net/ipv4/inet_connection_sock.c
> > +++ b/net/ipv4/inet_connection_sock.c
> > @@ -1188,7 +1190,7 @@ static void reqsk_timer_handler(struct timer_list *t)
> >         }
> >
> >  drop:
> > -       __inet_csk_reqsk_queue_drop(sk_listener, nreq, true);
> > +       __inet_csk_reqsk_queue_drop(sk_listener, oreq, true);
> >         reqsk_put(req);
> >  }
> >
> > ---8<---
> >
> > Thanks!
> 
> Just to clarify. In the old times rsk_timer was pinned, right ?
> 
> 83fccfc3940c4 ("inet: fix potential deadlock in reqsk_queue_unlink()")
> was fine I think.
> 
> So the bug was added recently ?
> 
> Can we give a precise Fixes: tag ?

TIMER_PINNED was used in reqsk_queue_hash_req() in v6.4 mentioned
by Martin and still used in the latest net-next.

$ git blame -L:reqsk_queue_hash_req net/ipv4/inet_connection_sock.c v6.4
079096f103fac (Eric Dumazet             2015-10-02 11:43:32 -0700 1095) static void reqsk_queue_hash_req(struct request_sock *req,
079096f103fac (Eric Dumazet             2015-10-02 11:43:32 -0700 1096)                                  unsigned long timeout)
fa76ce7328b28 (Eric Dumazet             2015-03-19 19:04:20 -0700 1097) {
59f379f9046a9 (Kees Cook                2017-10-16 17:29:19 -0700 1098)         timer_setup(&req->rsk_timer, reqsk_timer_handler, TIMER_PINNED);

Maybe the connection was localhost, or unlikely but RPS was
configured after SYN+ACK, or setup like ff46e3b44219 was used ??

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ