Message ID | 4A6EF0BF.2050801@gmail.com |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
> Hmm... > > Real bug may be fixed by followed patch ? (yet untested, sorry...) > > [PATCH] net: net_assign_generic() fix > > memcpy() should take into account size of pointers, > not only number of pointers to copy. > > Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Acked-by: Pavel Emelyanov <xemul@openvz.org> > --- > diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c > index b7292a2..1972830 100644 > --- a/net/core/net_namespace.c > +++ b/net/core/net_namespace.c > @@ -488,7 +488,7 @@ int net_assign_generic(struct net *net, int id, void *data) > */ > > ng->len = id; > - memcpy(&ng->ptr, &old_ng->ptr, old_ng->len); > + memcpy(&ng->ptr, &old_ng->ptr, old_ng->len * sizeof(void*)); > > rcu_assign_pointer(net->gen, ng); > call_rcu(&old_ng->rcu, net_generic_release); > > -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Pavel Emelyanov a écrit : >> Hmm... >> >> Real bug may be fixed by followed patch ? (yet untested, sorry...) >> >> [PATCH] net: net_assign_generic() fix >> >> memcpy() should take into account size of pointers, >> not only number of pointers to copy. >> >> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> > > Acked-by: Pavel Emelyanov <xemul@openvz.org> Thanks. Still this doesnt explain the crash, because initial number of pointers is 13 (INITIAL_NET_GEN_PTRS) We probably never realloc this array, unless a module forgets to unregister_pernet_gen_device() and we load/unload it many times ? -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Eric Dumazet a écrit : > Pavel Emelyanov a écrit : >>> Hmm... >>> >>> Real bug may be fixed by followed patch ? (yet untested, sorry...) >>> >>> [PATCH] net: net_assign_generic() fix >>> >>> memcpy() should take into account size of pointers, >>> not only number of pointers to copy. >>> >>> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> >> Acked-by: Pavel Emelyanov <xemul@openvz.org> > > Thanks. > > Still this doesnt explain the crash, because initial number of pointers is 13 > (INITIAL_NET_GEN_PTRS) > > We probably never realloc this array, unless a module forgets to > unregister_pernet_gen_device() and we load/unload it many times ? > Seems drivers/net/pppol2tp.c is a suspect... It uses register_pernet_gen_device() from pppol2tp_init() but doesnt call unregister_pernet_gen_device() -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Eric Dumazet <eric.dumazet@gmail.com> Date: Tue, 28 Jul 2009 15:16:37 +0200 > Pavel Emelyanov a écrit : >>> Hmm... >>> >>> Real bug may be fixed by followed patch ? (yet untested, sorry...) >>> >>> [PATCH] net: net_assign_generic() fix >>> >>> memcpy() should take into account size of pointers, >>> not only number of pointers to copy. >>> >>> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> >> >> Acked-by: Pavel Emelyanov <xemul@openvz.org> > > Thanks. Applied, thanks! -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index b7292a2..1972830 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c @@ -488,7 +488,7 @@ int net_assign_generic(struct net *net, int id, void *data) */ ng->len = id; - memcpy(&ng->ptr, &old_ng->ptr, old_ng->len); + memcpy(&ng->ptr, &old_ng->ptr, old_ng->len * sizeof(void*)); rcu_assign_pointer(net->gen, ng); call_rcu(&old_ng->rcu, net_generic_release);