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: <54104FE6.4030404@redhat.com>
Date:	Wed, 10 Sep 2014 10:19:34 -0300
From:	Marcelo Ricardo Leitner <mleitner@...hat.com>
To:	martin@...tingkelly.com
CC:	David Miller <davem@...emloft.net>, netdev@...r.kernel.org,
	paulmck@...ux.vnet.ibm.com, stephen@...workplumber.org
Subject: Re: Question about synchronize_net() in AF_PACKET close()

Em 09-09-2014 19:00, David Miller escreveu:
> From: Martin Kelly <martin@...tingkelly.com>
> Date: Tue, 9 Sep 2014 14:44:56 -0700
>
>> In net/packet/af_packet.c, I noticed the following few lines within
>> packet_release:
>>
>>           synchronize_net();
>>           /*
>>            *      Now the socket is dead. No more input will appear.
>>            */
>>           sock_orphan(sk);
>>           sock->sk = NULL;
>>
>>  From testing and code analysis, I have found that it appears to be safe
>> to move sock_orphan and sock->sk = NULL before the synchronize_net()
>> call like so:
>>
>>           /*
>>            *      Now the socket is dead. No more input will appear.
>>            */
>>           sock_orphan(sk);
>>           sock->sk = NULL;
>>           synchronize_net();
>>
>> Could some RCU and/or networking experts chime in about whether this a
>> safe operation? For all I know, there is some deep, fundamental reason
>> why those lines are in the order they are. On the other hand, perhaps
>> there is not.
>
> The synchronize_net() is also there to protect against the prot hook
> which can run asynchronously from the core packet input path on any
> cpu.
>
> You probably want to reference commit:
>
> commit 808f5114a9206fee855117d416440e1071ab375c
> Author: stephen hemminger <shemminger@...tta.com>
> Date:   Mon Feb 22 07:57:18 2010 +0000
>
>      packet: convert socket list to RCU (v3)
>
> which put the synchronize_net() there in the first place.

And also http://patchwork.ozlabs.org/patch/181605/
Which was an attempt on improving it.

Marcelo

--
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