Re: slab corruption with current -git (was Re: [git pull] vfs pile 1 (splice))
On Mon, Oct 10, 2016 at 10:39 PM, Linus Torvaldswrote: > > I guess I will have to double-check that the slub corruption is gone > still with that fixed. So I'm not getting any warnings now from SLUB debugging. So the original bug seems to not have re-surfaced, and the registration bug is gone, so now the unregistration doesn't warn about anything either. But I only rebooted three times. Linus -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: slab corruption with current -git (was Re: [git pull] vfs pile 1 (splice))
On Sun, Oct 9, 2016 at 8:41 PM, Linus Torvaldswrote: > This COMPLETELY UNTESTED patch tries to fix the nf_hook_entry code to do this. > > I repeat: it's ENTIRELY UNTESTED. Gaah. That patch was subtle garbage. The "add to list" thing did this: rcu_assign_pointer(entry->next, p); rcu_assign_pointer(*pp, p); which is not so subtly broken - that second assignment just assigns "p" to "*pp", but that was what *pp already contained. Too much cut-and-paste. That also explains why I then get the NOT FOUND case, because the add never actually worked. It *should* be rcu_assign_pointer(entry->next, p); rcu_assign_pointer(*pp, entry); and then the warnings about "not found" are gone. Duh. I guess I will have to double-check that the slub corruption is gone still with that fixed. Anyway, new version of the patch (just that one line changed) attached. Linus net/netfilter/core.c | 108 --- 1 file changed, 33 insertions(+), 75 deletions(-) diff --git a/net/netfilter/core.c b/net/netfilter/core.c index c9d90eb64046..fcb5d1df11e9 100644 --- a/net/netfilter/core.c +++ b/net/netfilter/core.c @@ -65,49 +65,24 @@ static DEFINE_MUTEX(nf_hook_mutex); #define nf_entry_dereference(e) \ rcu_dereference_protected(e, lockdep_is_held(_hook_mutex)) -static struct nf_hook_entry *nf_hook_entry_head(struct net *net, - const struct nf_hook_ops *reg) +static struct nf_hook_entry __rcu **nf_hook_entry_head(struct net *net, const struct nf_hook_ops *reg) { - struct nf_hook_entry *hook_head = NULL; - if (reg->pf != NFPROTO_NETDEV) - hook_head = nf_entry_dereference(net->nf.hooks[reg->pf] -[reg->hooknum]); - else if (reg->hooknum == NF_NETDEV_INGRESS) { + return net->nf.hooks[reg->pf]+reg->hooknum; + #ifdef CONFIG_NETFILTER_INGRESS + if (reg->hooknum == NF_NETDEV_INGRESS) { if (reg->dev && dev_net(reg->dev) == net) - hook_head = - nf_entry_dereference( - reg->dev->nf_hooks_ingress); -#endif + return >dev->nf_hooks_ingress; } - return hook_head; -} - -/* must hold nf_hook_mutex */ -static void nf_set_hooks_head(struct net *net, const struct nf_hook_ops *reg, - struct nf_hook_entry *entry) -{ - switch (reg->pf) { - case NFPROTO_NETDEV: -#ifdef CONFIG_NETFILTER_INGRESS - /* We already checked in nf_register_net_hook() that this is -* used from ingress. -*/ - rcu_assign_pointer(reg->dev->nf_hooks_ingress, entry); #endif - break; - default: - rcu_assign_pointer(net->nf.hooks[reg->pf][reg->hooknum], - entry); - break; - } + return NULL; } int nf_register_net_hook(struct net *net, const struct nf_hook_ops *reg) { - struct nf_hook_entry *hooks_entry; - struct nf_hook_entry *entry; + struct nf_hook_entry __rcu **pp; + struct nf_hook_entry *entry, *p; if (reg->pf == NFPROTO_NETDEV) { #ifndef CONFIG_NETFILTER_INGRESS @@ -119,6 +94,10 @@ int nf_register_net_hook(struct net *net, const struct nf_hook_ops *reg) return -EINVAL; } + pp = nf_hook_entry_head(net, reg); + if (!pp) + return -EINVAL; + entry = kmalloc(sizeof(*entry), GFP_KERNEL); if (!entry) return -ENOMEM; @@ -128,26 +107,15 @@ int nf_register_net_hook(struct net *net, const struct nf_hook_ops *reg) entry->next = NULL; mutex_lock(_hook_mutex); - hooks_entry = nf_hook_entry_head(net, reg); - - if (hooks_entry && hooks_entry->orig_ops->priority > reg->priority) { - /* This is the case where we need to insert at the head */ - entry->next = hooks_entry; - hooks_entry = NULL; - } - - while (hooks_entry && - reg->priority >= hooks_entry->orig_ops->priority && - nf_entry_dereference(hooks_entry->next)) { - hooks_entry = nf_entry_dereference(hooks_entry->next); - } - if (hooks_entry) { - entry->next = nf_entry_dereference(hooks_entry->next); - rcu_assign_pointer(hooks_entry->next, entry); - } else { - nf_set_hooks_head(net, reg, entry); + /* Find the spot in the list */ + while ((p = nf_entry_dereference(*pp)) != NULL) { + if (reg->priority < p->orig_ops->priority) + break; + pp = >next; } + rcu_assign_pointer(entry->next, p); + rcu_assign_pointer(*pp, entry);
Re: slab corruption with current -git (was Re: [git pull] vfs pile 1 (splice))
Linus Torvaldswrites: > On Mon, Oct 10, 2016 at 9:28 AM, Linus Torvalds > wrote: >> >> So as I already answered to Dave, I'm not actually sure that this was >> the buggy code, or that my patch would make any difference at all. > > My patch does seem to fix things, and in fact the warning about "hook > not found" now triggers. > > So I think the bug really was that the singly-linked list handling > code did not correctly handle the case of not finding the entry, and > then freed (incorrectly) the last one that wasn't actually unlinked. > > In fact, I get quite a few warnings (56 total) about 30 seconds after > logging in: > > [ 54.213170] WARNING: CPU: 1 PID: 111 at net/netfilter/core.c:151 > nf_unregister_net_hook+0x8e/0x170 > ... repeat 54 times ... > [ 54.445520] WARNING: CPU: 7 PID: 111 at net/netfilter/core.c:151 > nf_unregister_net_hook+0x8e/0x170 > > and looking in the journal, the first one is (again) immediately > preceded by that systemd-hostnamed service stopping: > > Oct 10 11:45:47 i7 audit[1546]: USER_LOGIN > ... > Oct 10 11:46:11 i7 audit[1]: SERVICE_STOP pid=1 uid=0 > auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 > msg='unit=fprintd comm="systemd" exe="/usr/lib/systemd/systemd" > hostname=? addr=? terminal=? res=success' > Oct 10 11:46:13 i7 pulseaudio[1697]: [pulseaudio] bluez5-util.c: > GetManagedObjects() failed: org.freedesktop.DBus.Error.NoReply: Did > not receive a reply. Possible causes include: the remote application > did not send a reply, the message bus security policy blocked the > reply, the reply timeout expir > Oct 10 11:46:13 i7 dbus-daemon[1003]: [system] Failed to activate > service 'org.bluez': timed out > Oct 10 11:46:20 i7 audit[1]: SERVICE_STOP pid=1 uid=0 > auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 > msg='unit=systemd-hostnamed comm="systemd" > exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? > res=success' > Oct 10 11:46:20 i7 kernel: [ cut here ] > Oct 10 11:46:20 i7 kernel: WARNING: CPU: 1 PID: 111 at > net/netfilter/core.c:151 nf_unregister_net_hook+0x8e/0x170 > > so I do think it's something to do with some network startup service > thing (perhaps dhcp, perhaps chrome, who knows) as I do my initial > login. > > David - I think that also explains what was wrong with the old code. > In the old code, this loop: > > while (hooks_entry && nf_entry_dereference(hooks_entry->next)) { > > would exit with "hooks_entry" pointing to the last list entry (because > ->next was NULL). Nothing was ever unlinked in the loop itself, > because it never actually found a matching entry, but then after the > loop it would free that last entry because it *thought* that was the > match. > > My list rewrite fixes that. > > Anyway, I'm assuming it will come to me from the networking tree after > more testing by the maintainers. You can add my > > Signed-off-by: Linus Torvalds > > to the patch, though. > > David, if you want me to just commit that thing directly, I can > obviously do so, but I do think somebody should look at > > (a) that I actually got the priority list ordering right on the > insertion side It looks correct. Reviewed-by: Aaron Conole > (b) what it is that makes it try to unregister that hook that isn't > on the list in the first place This is a still problem, I think. I wasn't able to reproduce the issue on a fedora-23 VM. My fedora 24 bare-metal system does trigger this, though. Not sure what changed in userspace/kernel interaction side (not an excuse, but just an observation). > but on the whole I consider this issue explained and solved. I'll > continue to run with my patch on my machine (just not committed). Okay. Very sorry for this, again. > Linus -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: slab corruption with current -git (was Re: [git pull] vfs pile 1 (splice))
On Mon, Oct 10, 2016 at 9:28 AM, Linus Torvaldswrote: > > So as I already answered to Dave, I'm not actually sure that this was > the buggy code, or that my patch would make any difference at all. My patch does seem to fix things, and in fact the warning about "hook not found" now triggers. So I think the bug really was that the singly-linked list handling code did not correctly handle the case of not finding the entry, and then freed (incorrectly) the last one that wasn't actually unlinked. In fact, I get quite a few warnings (56 total) about 30 seconds after logging in: [ 54.213170] WARNING: CPU: 1 PID: 111 at net/netfilter/core.c:151 nf_unregister_net_hook+0x8e/0x170 ... repeat 54 times ... [ 54.445520] WARNING: CPU: 7 PID: 111 at net/netfilter/core.c:151 nf_unregister_net_hook+0x8e/0x170 and looking in the journal, the first one is (again) immediately preceded by that systemd-hostnamed service stopping: Oct 10 11:45:47 i7 audit[1546]: USER_LOGIN ... Oct 10 11:46:11 i7 audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=fprintd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success' Oct 10 11:46:13 i7 pulseaudio[1697]: [pulseaudio] bluez5-util.c: GetManagedObjects() failed: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expir Oct 10 11:46:13 i7 dbus-daemon[1003]: [system] Failed to activate service 'org.bluez': timed out Oct 10 11:46:20 i7 audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=systemd-hostnamed comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success' Oct 10 11:46:20 i7 kernel: [ cut here ] Oct 10 11:46:20 i7 kernel: WARNING: CPU: 1 PID: 111 at net/netfilter/core.c:151 nf_unregister_net_hook+0x8e/0x170 so I do think it's something to do with some network startup service thing (perhaps dhcp, perhaps chrome, who knows) as I do my initial login. David - I think that also explains what was wrong with the old code. In the old code, this loop: while (hooks_entry && nf_entry_dereference(hooks_entry->next)) { would exit with "hooks_entry" pointing to the last list entry (because ->next was NULL). Nothing was ever unlinked in the loop itself, because it never actually found a matching entry, but then after the loop it would free that last entry because it *thought* that was the match. My list rewrite fixes that. Anyway, I'm assuming it will come to me from the networking tree after more testing by the maintainers. You can add my Signed-off-by: Linus Torvalds to the patch, though. David, if you want me to just commit that thing directly, I can obviously do so, but I do think somebody should look at (a) that I actually got the priority list ordering right on the insertion side (b) what it is that makes it try to unregister that hook that isn't on the list in the first place but on the whole I consider this issue explained and solved. I'll continue to run with my patch on my machine (just not committed). Linus -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: slab corruption with current -git (was Re: [git pull] vfs pile 1 (splice))
On Mon, Oct 10, 2016 at 6:49 AM, Aaron Conolewrote: > > Okay, I'm looking it over. Sorry for the mess. So as I already answered to Dave, I'm not actually sure that this was the buggy code, or that my patch would make any difference at all. I never got a good reproducer for the bug: I spent much of the weekend rebooting, because it seems to happen only just after a reboot, as I log in and start my usual thing. I initially blamed some off filesystem or block layer issue ("Oh, it only happens with a cold cache"), partly because the initial non-poisoned slub oopses happened in filesystem code. But I now think it's netfilter, and I *think* that what triggers it is something like the bluetooth subsystem giving up or something. What I do when I log into a new session tends to be to go to the kernel subdirectory in one or two terminals, and fire up chrome to read email. And the problem either happened within half a minute of me doing that, or it never happens at all. Which is why I ended up rebooting a *lot*. Just running the kernel never triggered it. (It took me some time to figure that out, which is basically why I did almost no pull requests the whole weekend) The journal entries for that invalid kernel access is somewhat suggestive: Oct 09 13:24:03 i7 dbus-daemon[1030]: [system] Failed to activate service 'org.bluez': timed out Oct 09 13:24:09 i7 audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=systemd-hostnamed comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success' Oct 09 13:24:09 i7 kernel: general protection fault: [#1] SMP so it happened just as *some* network setup thing was finishing off (I don't think it was systemd-hostnamed itself that necessarily matters, but clearly something was finishing up as the netfilter problem occurred. > I'll review it, and test it. Can you tell me what steps you took to > reproduce the oops? See above: I can't actually really "reproduce" it. It's probably highly timing-dependent, and it is not unlikely that it's also very much about specific setup. I'm running plain Fedora 24, I boot up, log in, start two or three terminals, fire up chrome, and ... So far I've seen the problem maybe 5-6 times, but a couple of those were just silent hangs (I may have rebooted too quickly for things to hit the disk, or the oops may just have killed the machine too hard). Two I got the oops inside slub code, and I only have one successful slub poisoning oops from netfilter. (Part of the reason I only have one is that once I got that, I stopped rebooting, and instead started looking at the netfilter code and started to do some merge window pulls again because I felt that this is *probably* the core reason, and I cant' afford to not do pulls during the merge window for _too_ long). Linus -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: slab corruption with current -git (was Re: [git pull] vfs pile 1 (splice))
Linus Torvaldswrites: > On Sun, Oct 9, 2016 at 7:49 PM, Linus Torvalds > wrote: >> >> There is one *correct* way to remove an entry from a singly linked >> list, and it looks like this: >> >> struct entry **pp, *p; >> >> pp = >> while ((p = *pp) != NULL) { >> if (right_entry(p)) { >> *pp = p->next; >> break; >> } >> pp = >next; >> } >> >> and that's it. Nothing else. Sorry, I should have done that. > This COMPLETELY UNTESTED patch tries to fix the nf_hook_entry code to do this. > > I repeat: it's ENTIRELY UNTESTED. I just converted the insertion and > deletion to the proper pattern, but I could easily have gotten the > insertion priority test the wrong way around entirely, for example. Or > it could simply have some other completely broken bug in it. It > compiles for me, but that's all I actually checked. Okay, I'm looking it over. Sorry for the mess. > Note that the "correct way" of doing list operations also almost > inevitably is the shortest way by far, since it gets rid of all the > special cases. So the patch looks nice. It gets rid of the magic > "nf_set_hooks_head()" thing too, because once you do list following > right, the head is no different from any other pointer in the list. > > So the patch stats look good: > > net/netfilter/core.c | 108 > --- > 1 file changed, 33 insertions(+), 75 deletions(-) > > but again, it's entirely *entirely* untested. Please consider this > just a "this is generally how list insert/delete operations should be > done, avoiding special cases for the first entry". I'll review it, and test it. Can you tell me what steps you took to reproduce the oops? I'll enable slab debugging and try to reproduce without and with this patch (and I'll also look into David's recent email as well). Are you simply creating and removing network namespaces (I did test that, but I should have done a better job)? > ALSO NOTE! The code assumes that the "nf_hook_mutex" locking only > protects the actual *lists*, and that the address to the list can be > looked up without holding the lock. That's generally how things are > done, and it simplifies error handling (because you can do the "there > is no such list at all" test before you do anything else. But again, I > don't actually know the code, and if there is something that actually > expands the number of lists etc that depends on that mutex, then the > list head lookup may need to be inside the lock too. That should be correct, the nf_hook_mutex is only for protecting the lists. >Linus -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: slab corruption with current -git (was Re: [git pull] vfs pile 1 (splice))
On Sun, Oct 9, 2016 at 7:49 PM, Linus Torvaldswrote: > > There is one *correct* way to remove an entry from a singly linked > list, and it looks like this: > > struct entry **pp, *p; > > pp = > while ((p = *pp) != NULL) { > if (right_entry(p)) { > *pp = p->next; > break; > } > pp = >next; > } > > and that's it. Nothing else. This COMPLETELY UNTESTED patch tries to fix the nf_hook_entry code to do this. I repeat: it's ENTIRELY UNTESTED. I just converted the insertion and deletion to the proper pattern, but I could easily have gotten the insertion priority test the wrong way around entirely, for example. Or it could simply have some other completely broken bug in it. It compiles for me, but that's all I actually checked. Note that the "correct way" of doing list operations also almost inevitably is the shortest way by far, since it gets rid of all the special cases. So the patch looks nice. It gets rid of the magic "nf_set_hooks_head()" thing too, because once you do list following right, the head is no different from any other pointer in the list. So the patch stats look good: net/netfilter/core.c | 108 --- 1 file changed, 33 insertions(+), 75 deletions(-) but again, it's entirely *entirely* untested. Please consider this just a "this is generally how list insert/delete operations should be done, avoiding special cases for the first entry". ALSO NOTE! The code assumes that the "nf_hook_mutex" locking only protects the actual *lists*, and that the address to the list can be looked up without holding the lock. That's generally how things are done, and it simplifies error handling (because you can do the "there is no such list at all" test before you do anything else. But again, I don't actually know the code, and if there is something that actually expands the number of lists etc that depends on that mutex, then the list head lookup may need to be inside the lock too. Linus net/netfilter/core.c | 108 --- 1 file changed, 33 insertions(+), 75 deletions(-) diff --git a/net/netfilter/core.c b/net/netfilter/core.c index c9d90eb64046..814258641fcc 100644 --- a/net/netfilter/core.c +++ b/net/netfilter/core.c @@ -65,49 +65,24 @@ static DEFINE_MUTEX(nf_hook_mutex); #define nf_entry_dereference(e) \ rcu_dereference_protected(e, lockdep_is_held(_hook_mutex)) -static struct nf_hook_entry *nf_hook_entry_head(struct net *net, - const struct nf_hook_ops *reg) +static struct nf_hook_entry __rcu **nf_hook_entry_head(struct net *net, const struct nf_hook_ops *reg) { - struct nf_hook_entry *hook_head = NULL; - if (reg->pf != NFPROTO_NETDEV) - hook_head = nf_entry_dereference(net->nf.hooks[reg->pf] -[reg->hooknum]); - else if (reg->hooknum == NF_NETDEV_INGRESS) { + return net->nf.hooks[reg->pf]+reg->hooknum; + #ifdef CONFIG_NETFILTER_INGRESS + if (reg->hooknum == NF_NETDEV_INGRESS) { if (reg->dev && dev_net(reg->dev) == net) - hook_head = - nf_entry_dereference( - reg->dev->nf_hooks_ingress); -#endif + return >dev->nf_hooks_ingress; } - return hook_head; -} - -/* must hold nf_hook_mutex */ -static void nf_set_hooks_head(struct net *net, const struct nf_hook_ops *reg, - struct nf_hook_entry *entry) -{ - switch (reg->pf) { - case NFPROTO_NETDEV: -#ifdef CONFIG_NETFILTER_INGRESS - /* We already checked in nf_register_net_hook() that this is -* used from ingress. -*/ - rcu_assign_pointer(reg->dev->nf_hooks_ingress, entry); #endif - break; - default: - rcu_assign_pointer(net->nf.hooks[reg->pf][reg->hooknum], - entry); - break; - } + return NULL; } int nf_register_net_hook(struct net *net, const struct nf_hook_ops *reg) { - struct nf_hook_entry *hooks_entry; - struct nf_hook_entry *entry; + struct nf_hook_entry __rcu **pp; + struct nf_hook_entry *entry, *p; if (reg->pf == NFPROTO_NETDEV) { #ifndef CONFIG_NETFILTER_INGRESS @@ -119,6 +94,10 @@ int nf_register_net_hook(struct net *net, const struct nf_hook_ops *reg) return -EINVAL; } + pp = nf_hook_entry_head(net, reg); + if (!pp) + return -EINVAL; + entry = kmalloc(sizeof(*entry), GFP_KERNEL); if (!entry) return -ENOMEM; @@ -128,26 +107,15 @@ int nf_register_net_hook(struct net *net, const struct nf_hook_ops *reg) entry->next = NULL;
Re: slab corruption with current -git (was Re: [git pull] vfs pile 1 (splice))
On Sun, Oct 9, 2016 at 6:35 PM, Aaron Conolewrote: > > I was just about to build and test something similar: So I haven't actually tested that one, but looking at the code, it really looks very bogus. In fact, that code just looks like crap. It does *not* do a proper "remove singly linked list entry". It's exactly the kind of code that I rail against, and that people should never write. Any code that can't even traverse a linked list is not worth looking at. There is one *correct* way to remove an entry from a singly linked list, and it looks like this: struct entry **pp, *p; pp = while ((p = *pp) != NULL) { if (right_entry(p)) { *pp = p->next; break; } pp = >next; } and that's it. Nothing else. The above code exits the loop with "p" containing the entry that was removed, or NULL if nothing was. It can't get any simpler than that, but more importantly, anything more complicated than that is WRONG. Seriously, nothing else is acceptable. In particular, any linked list traversal that makes a special case of the first entry or the last entry should not be allowed to exist. Note how there is not a single special case in the above correct code. It JustWorks(tm). That nf_unregister_net_hook() code has all the signs of exactly that kind of broken list-handling code: special-casing the head of the loop, and having the loop condition test both current and that odd "next to next" pointer etc. It's all very very wrong. So I really see two options: - do that singly-linked list traversal right (and I'm serious: nothing but the code above can ever be right) - don't make up your own list handling code at all, and use the standard linux list code. So either e3b37f11e6e4 needs to be reverted, or it needs to be taught to use real list handling. If the code doesn't want to use the regular list.h (either the doubly linked one, or the hlist one), it needs to at least learn to do list removal right. Linus -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: slab corruption with current -git (was Re: [git pull] vfs pile 1 (splice))
Florian Westphalwrites: > Linus Torvalds wrote: >> On Sun, Oct 9, 2016 at 12:11 PM, Linus Torvalds >> wrote: >> > >> > Anyway, I don't think I can bisect it, but I'll try to narrow it down >> > a *bit* at least. >> > >> > Not doing any more pulls on this unstable base, I've been puttering >> > around in trying to clean up some stupid printk logging issues >> > instead. >> >> So I finally got a oops with slub debugging enabled. It doesn't really >> narrow things down, though, it kind of extends on the possible >> suspects. Now adding David Miller and Pablo, because it looks like it >> may be netfilter that does something bad and corrupts memory. > > Quite possible, the netns interactions are not nice :-/ > >> Without further ado, here's the new oops: >> >>general protection fault: [#1] SMP >>CPU: 7 PID: 169 Comm: kworker/u16:7 Not tainted >> 4.8.0-11288-gb66484cd7470 #1 >>Hardware name: System manufacturer System Product Name/Z170-K, BIOS > .. >>Call Trace: >> netfilter_net_exit+0x2f/0x60 >> ops_exit_list.isra.4+0x38/0x60 >> cleanup_net+0x1ba/0x2a0 >> process_one_work+0x1f1/0x480 >> worker_thread+0x48/0x4d0 >> ? process_one_work+0x480/0x480 > > .. > >> like it's a pointer loaded from a free'd allocation. >> >> The code disassembles to >> >>0: 0f b6 ca movzbl %dl,%ecx >>3: 48 8d 84 c8 00 01 00 lea0x100(%rax,%rcx,8),%rax >>a: 00 >>b: 49 8b 5c c5 00 mov0x0(%r13,%rax,8),%rbx >> 10: 48 85 db test %rbx,%rbx >> 13: 0f 84 cb 00 00 00 je 0xe4 >> 19: 4c 3b 63 40 cmp0x40(%rbx),%r12 >> 1d: 48 8b 03 mov(%rbx),%rax >> 20: 0f 84 e9 00 00 00 je 0x10f >> 26: 48 85 c0 test %rax,%rax >> 29: 74 26 je 0x51 >> 2b:* 4c 3b 60 40 cmp0x40(%rax),%r12 <-- trapping instruction >> 2f: 75 08 jne0x39 >> 31: e9 ef 00 00 00 jmpq 0x125 >> 36: 48 89 d8 mov%rbx,%rax >> 39: 48 8b 18 mov(%rax),%rbx >> 3c: 48 85 db test %rbx,%rbx >> >> and that oopsing instruction seems to be the compare of >> "hooks_entry->orig_ops" from hooks_entry in this expression: >> >> if (hooks_entry && hooks_entry->orig_ops == reg) { >> >> so hooks_entry() is bogus. It was gotten from >> >> hooks_entry = nf_hook_entry_head(net, reg); >> >> but that's as far as I dug. And yes, I do have >> CONFIG_NETFILTER_INGRESS=y in case that matters. >> >> And all this code has changed pretty radically in commit e3b37f11e6e4 >> ("netfilter: replace list_head with single linked list"), and there >> was clearly already something wrong with that code, with commit >> 5119e4381a90 ("netfilter: Fix potential null pointer dereference") >> adding the test against NULL. But I suspect that only hid the "oops, >> it's actually not NULL, it loaded some uninitialized value" problem. >> >> Over to the networking guys.. Ideas? > > Sorry, not off the top of my head. > Pablo is currently travelling back home from netdev 1.2 in Tokyo, > I can help starting Wednesday when I am back. > > One shot in the dark (not even compile tested; wonder if we can end up > zapping bogus hook ...) > I was just about to build and test something similar: diff --git a/net/netfilter/core.c b/net/netfilter/core.c index c9d90eb..e84103f 100644 --- a/net/netfilter/core.c +++ b/net/netfilter/core.c @@ -189,7 +189,7 @@ void nf_unregister_net_hook(struct net *net, const struct nf_hook_ops *reg) unlock: mutex_unlock(_hook_mutex); - if (!hooks_entry) { + if (!hooks_entry || hooks_entry->orig_ops != reg) { WARN(1, "nf_unregister_net_hook: hook not found!\n"); return; } -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: slab corruption with current -git (was Re: [git pull] vfs pile 1 (splice))
Linus Torvaldswrote: > On Sun, Oct 9, 2016 at 12:11 PM, Linus Torvalds > wrote: > > > > Anyway, I don't think I can bisect it, but I'll try to narrow it down > > a *bit* at least. > > > > Not doing any more pulls on this unstable base, I've been puttering > > around in trying to clean up some stupid printk logging issues > > instead. > > So I finally got a oops with slub debugging enabled. It doesn't really > narrow things down, though, it kind of extends on the possible > suspects. Now adding David Miller and Pablo, because it looks like it > may be netfilter that does something bad and corrupts memory. Quite possible, the netns interactions are not nice :-/ > Without further ado, here's the new oops: > >general protection fault: [#1] SMP >CPU: 7 PID: 169 Comm: kworker/u16:7 Not tainted 4.8.0-11288-gb66484cd7470 > #1 >Hardware name: System manufacturer System Product Name/Z170-K, BIOS .. >Call Trace: > netfilter_net_exit+0x2f/0x60 > ops_exit_list.isra.4+0x38/0x60 > cleanup_net+0x1ba/0x2a0 > process_one_work+0x1f1/0x480 > worker_thread+0x48/0x4d0 > ? process_one_work+0x480/0x480 .. > like it's a pointer loaded from a free'd allocation. > > The code disassembles to > >0: 0f b6 ca movzbl %dl,%ecx >3: 48 8d 84 c8 00 01 00 lea0x100(%rax,%rcx,8),%rax >a: 00 >b: 49 8b 5c c5 00 mov0x0(%r13,%rax,8),%rbx > 10: 48 85 db test %rbx,%rbx > 13: 0f 84 cb 00 00 00 je 0xe4 > 19: 4c 3b 63 40 cmp0x40(%rbx),%r12 > 1d: 48 8b 03 mov(%rbx),%rax > 20: 0f 84 e9 00 00 00 je 0x10f > 26: 48 85 c0 test %rax,%rax > 29: 74 26 je 0x51 > 2b:* 4c 3b 60 40 cmp0x40(%rax),%r12 <-- trapping instruction > 2f: 75 08 jne0x39 > 31: e9 ef 00 00 00 jmpq 0x125 > 36: 48 89 d8 mov%rbx,%rax > 39: 48 8b 18 mov(%rax),%rbx > 3c: 48 85 db test %rbx,%rbx > > and that oopsing instruction seems to be the compare of > "hooks_entry->orig_ops" from hooks_entry in this expression: > > if (hooks_entry && hooks_entry->orig_ops == reg) { > > so hooks_entry() is bogus. It was gotten from > > hooks_entry = nf_hook_entry_head(net, reg); > > but that's as far as I dug. And yes, I do have > CONFIG_NETFILTER_INGRESS=y in case that matters. > > And all this code has changed pretty radically in commit e3b37f11e6e4 > ("netfilter: replace list_head with single linked list"), and there > was clearly already something wrong with that code, with commit > 5119e4381a90 ("netfilter: Fix potential null pointer dereference") > adding the test against NULL. But I suspect that only hid the "oops, > it's actually not NULL, it loaded some uninitialized value" problem. > > Over to the networking guys.. Ideas? Sorry, not off the top of my head. Pablo is currently travelling back home from netdev 1.2 in Tokyo, I can help starting Wednesday when I am back. One shot in the dark (not even compile tested; wonder if we can end up zapping bogus hook ...) diff --git a/net/netfilter/core.c b/net/netfilter/core.c index c9d90eb..fd6a2ce 100644 --- a/net/netfilter/core.c +++ b/net/netfilter/core.c @@ -189,6 +189,9 @@ void nf_unregister_net_hook(struct net *net, const struct nf_hook_ops *reg) unlock: mutex_unlock(_hook_mutex); + + WARN_ON(hooks_entry && hooks_entry->orig_ops != reg); + if (!hooks_entry) { WARN(1, "nf_unregister_net_hook: hook not found!\n"); return; -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html