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]
Date:	Thu, 5 Nov 2015 22:20:14 +0100
From:	William Dauchy <wdauchy@...il.com>
To:	Francesco Ruggeri <fruggeri@...stanetworks.com>
Cc:	edumazet@...gle.com, "David S. Miller" <davem@...emloft.net>,
	netdev@...r.kernel.org, noureddine@...sta.com, fruggeri@...sta.com
Subject: Re: [PATCH 1/1] packet: race condition in packet_bind

Hi Francesco,

On Thu, Nov 5, 2015 at 5:16 PM, Francesco Ruggeri
<fruggeri@...stanetworks.com> wrote:
> There is a race conditions between packet_notifier and packet_bind{_spkt}.
>
> It happens if packet_notifier(NETDEV_UNREGISTER) executes between the
> time packet_bind{_spkt} takes a reference on the new netdevice and the
> time packet_do_bind sets po->ifindex.
> In this case the notification can be missed.
> If this happens during a dev_change_net_namespace this can result in the
> netdevice to be moved to the new namespace while the packet_sock in the
> old namespace still holds a reference on it. When the netdevice is later
> deleted in the new namespace the deletion hangs since the packet_sock
> is not found in the new namespace' &net->packet.sklist.
> It can be reproduced with the script below.
>
> This patch makes packet_do_bind check again for the presence of the
> netdevice in the packet_sock's namespace after the synchronize_net
> in unregister_prot_hook.
> More in general it also uses the rcu lock for the duration of the bind
> to stop dev_change_net_namespace/rollback_registered_many from
> going past the synchronize_net following unlist_netdevice, so that
> no NETDEV_UNREGISTER notifications can happen on the new netdevice
> while the bind is executing. In order to do this some code from
> packet_bind{_spkt} is consolidated into packet_do_dev.

I was triggering the same kind of race but was unable to reproduce it reliably.

Tested on both v3.14.x and v4.1.x, looks good to me as well.

Thanks a lot for this work (and the attached test),
-- 
William
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ