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: <20241205004720.92043-1-kuniyu@amazon.com>
Date: Thu, 5 Dec 2024 09:47:20 +0900
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <edumazet@...gle.com>
CC: <davem@...emloft.net>, <ebiederm@...ssion.com>, <jmaloy@...hat.com>,
	<kuba@...nel.org>, <kuni1840@...il.com>, <kuniyu@...zon.com>,
	<netdev@...r.kernel.org>, <pabeni@...hat.com>, <syzkaller@...glegroups.com>,
	<tipc-discussion@...ts.sourceforge.net>, <ying.xue@...driver.com>
Subject: Re: [PATCH v2 net] tipc: Fix use-after-free of kernel socket in cleanup_bearer().

From: Eric Dumazet <edumazet@...gle.com>
Date: Wed, 4 Dec 2024 17:09:40 +0100
> On Wed, Dec 4, 2024 at 5:00 PM Kuniyuki Iwashima <kuniyu@...zon.com> wrote:
> >
> > From: Eric Dumazet <edumazet@...gle.com>
> > Date: Wed, 4 Dec 2024 16:01:10 +0100
> > > > diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c
> > > > index 439f75539977..b7e25e7e9933 100644
> > > > --- a/net/tipc/udp_media.c
> > > > +++ b/net/tipc/udp_media.c
> > > > @@ -814,10 +814,10 @@ static void cleanup_bearer(struct work_struct *work)
> > > >                 kfree_rcu(rcast, rcu);
> > > >         }
> > > >
> > > > -       atomic_dec(&tipc_net(sock_net(ub->ubsock->sk))->wq_count);
> > > >         dst_cache_destroy(&ub->rcast.dst_cache);
> > > >         udp_tunnel_sock_release(ub->ubsock);
> > > >         synchronize_net();
> > > > +       atomic_dec(&tipc_net(sock_net(ub->ubsock->sk))->wq_count);
> > >
> > > Note that ub->ubsock->sk is NULL at this point.
> > >
> > > I am testing the following fix, does it make sense to you ?
> >
> > Ah yes, net needs to be cached before sock_release().
> >
> > Thanks for catching this !
> >
> 
> 
> BTW the following construct in tipc_exit_net()
> 
> while (atomic_read(&tn->wq_count))
>      cond_resched();
> 
> should really be replaced by a completion or something like that :/

Agreed.

Also, synchronize_net() in cleanup_bearer() looks unnecessary
given udp_tunnel_sock_release() sets NULL to sk_user_data and
calls synchronize_rcu(), and tipc_udp_recv() doesn't work then.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ