netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* net_tx_action race condition?
@ 2014-11-24 13:29 Angelo Rizzi
  2014-11-24 15:08 ` Herbert Xu
  2014-11-24 15:33 ` Eric Dumazet
  0 siblings, 2 replies; 5+ messages in thread
From: Angelo Rizzi @ 2014-11-24 13:29 UTC (permalink / raw)
  To: netdev

[-- Attachment #1: Type: text/plain, Size: 936 bytes --]

Hi Daniel,
Here attached the patch file you required.
The problem i've found is on the declaration of 'struct softnet_data 
*sd' in function 'net_tx_action'
What happens to me (i have an embedded system based on FPGA and a NIOS2 
cpu) is that, due to compiler optimization, the content of 
'sd->completion_queue' is saved in a CPU register before interrupt 
disabling (when the instruction 'if (sd->completion_queue) {' is 
executed) and then the register contents is used for interrupt-disabled 
assignment ('clist = sd->completion_queue') instead of re-read the 
variable contents.
This seems to lead to a race condition when an interrupt modifies the 
content of 'sd->completion_queue' between these two instructions.
What i have done to avoid this situation is to change the declaration of 
'struct softnet_data *sd' to 'volatile struct softnet_data *sd' and now 
everything seems to be ok.
I hope this will help.

Regards,
Angelo


[-- Attachment #2: net_tx_action_patch --]
[-- Type: text/plain, Size: 438 bytes --]

--- linux-2.6.32.64/net/core/dev.c.orig	2014-11-24 12:52:36.103335551 +0100
+++ linux-2.6.32.64/net/core/dev.c	2014-11-24 12:52:58.863949715 +0100
@@ -2069,7 +2069,7 @@ EXPORT_SYMBOL(netif_rx_ni);
 
 static void net_tx_action(struct softirq_action *h)
 {
-	struct softnet_data *sd = &__get_cpu_var(softnet_data);
+	volatile struct softnet_data *sd = &__get_cpu_var(softnet_data);
 
 	if (sd->completion_queue) {
 		struct sk_buff *clist;

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-03-28 16:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <BY2PR05MB712796CB064F3202FEFA328B3A30@BY2PR05MB712.namprd05.prod.outlook.com>
2018-03-28 16:32 ` net_tx_action race condition? Eric Dumazet
2014-11-24 13:29 Angelo Rizzi
2014-11-24 15:08 ` Herbert Xu
2014-11-24 15:33 ` Eric Dumazet
2014-11-24 17:19   ` Angelo Rizzi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).