Michael J Dilmore <michael.j.dilmore@xxxxxxxxx> wrote:That did cross my mind but I read that Linus that was quite averse to BUG_ON anywhere in the kernel so thought it might be have been worth doing.
On 21/06/17 22:56, David Miller wrote:In general, yes, but in this case, the condition should be
From: Michael D <michael.j.dilmore@xxxxxxxxx>Ok this is starting to make sense now - went a bit off track but think my
Date: Wed, 21 Jun 2017 22:41:07 +0100
I don't think you can stop it being dereferenced... you just need toWhat's all of this about an "attacker"?
prevent an attacker from exploiting the null pointer dereference
vulnerability right? And this is done by returning the function right
away?
If there is a bug, we dererence a NULL pointer, and we should
fix that bug.
The BUG_ON() helps us see where the problem is while at the
same time stopping the kernel before the NULL deref happens.
general thinking is ok - i.e. if we return the function with an error code
before the dereference then this basically does the same thing as BUG_ON
but without crashing the kernel.
Something like:
if (WARN_ON(!new_active_slave) {
netdev_dbg("Can't add new active slave - pointer null");
return ERROR_CODE
}
impossible to hit, so BUG_ON seems appropriate.
If bond_slave_get_rtnl/rcu() returns NULL for an actual bonding
slave, other code paths (bond_fill_slave_info, bond_handle_frame) will
likely crash before getting to this one.
-J
---
-Jay Vosburgh, jay.vosburgh@xxxxxxxxxxxxx