From: Eric Dumazet <eric.dumazet@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Patrick McHardy <kaber@trash.net>
Subject: [PATCH] vlan: Fix register_vlan_dev() error path
Date: Tue, 17 Nov 2009 15:41:26 +0100 [thread overview]
Message-ID: <4B02B616.3020801@gmail.com> (raw)
In-Reply-To: <20091117.002037.229474882.davem@davemloft.net>
David Miller a écrit :
> Eric, please make allocation failure cause the vlan_setup()
> to fail and propagate -EFAULT back to the caller.
Sure ! (You meant -ENOMEM probably...)
While testing my new patch in OOM situations, I found following bug
in vlan code, that gave me crashes or infinite loops.
[PATCH] vlan: Fix register_vlan_dev() error path
In case register_netdevice() returns an error, and a new vlan_group was
allocated and inserted in vlan_group_hash[] we call vlan_group_free() without
deleting group from hash table. Future lookups can give infinite loops or crashes.
We must delete the vlan_group using RCU safe procedure.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
net/8021q/vlan.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 8836575..a29c5ab 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -281,8 +281,11 @@ out_uninit_applicant:
if (ngrp)
vlan_gvrp_uninit_applicant(real_dev);
out_free_group:
- if (ngrp)
- vlan_group_free(ngrp);
+ if (ngrp) {
+ hlist_del_rcu(&ngrp->hlist);
+ /* Free the group, after all cpu's are done. */
+ call_rcu(&ngrp->rcu, vlan_rcu_free);
+ }
return err;
}
next prev parent reply other threads:[~2009-11-17 14:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-16 13:37 [PATCH 2/2 net-next-2.6] vlan: Precise RX stats accounting Eric Dumazet
2009-11-17 8:20 ` David Miller
2009-11-17 14:41 ` Eric Dumazet [this message]
2009-11-17 14:45 ` [PATCH] vlan: Fix register_vlan_dev() error path David Miller
2009-11-17 14:53 ` [PATCH 2/2 net-next-2.6] vlan: Precise RX stats accounting Eric Dumazet
2009-11-18 7:53 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B02B616.3020801@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.