From: Jussi Maki <hidden> Date: 2021-08-12 14:53:20
The new vlan+srcmac xmit policy is not implementable with XDP since
in many cases the 802.1Q payload is not present in the packet. This
can be for example due to hardware offload or in the case of veth
due to use of skbuffs internally.
This also fixes the NULL deref with the vlan+srcmac xmit policy
reported by Jonathan Toppins by additionally checking the skb
pointer.
Fixes: a815bde56b15 ("net, bonding: Refactor bond_xmit_hash for use with xdp_buff")
Reported-by: Jonathan Toppins <redacted>
Signed-off-by: Jussi Maki <redacted>
---
drivers/net/bonding/bond_main.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
@@ -322,9 +322,15 @@ static bool bond_xdp_check(struct bonding *bond)switch(BOND_MODE(bond)){caseBOND_MODE_ROUNDROBIN:caseBOND_MODE_ACTIVEBACKUP:+returntrue;caseBOND_MODE_8023AD:caseBOND_MODE_XOR:-returntrue;+/* vlan+srcmac is not supported with XDP as in most cases the 802.1q+*payloadisnotinthepacketduetohardwareoffload.+*/+if(bond->params.xmit_policy!=BOND_XMIT_POLICY_VLAN_SRCMAC)+returntrue;+fallthrough;default:returnfalse;}
From: Nikolay Aleksandrov <hidden> Date: 2021-08-12 15:01:45
On 12/08/2021 17:52, Jussi Maki wrote:
The new vlan+srcmac xmit policy is not implementable with XDP since
in many cases the 802.1Q payload is not present in the packet. This
can be for example due to hardware offload or in the case of veth
due to use of skbuffs internally.
This also fixes the NULL deref with the vlan+srcmac xmit policy
reported by Jonathan Toppins by additionally checking the skb
pointer.
Fixes: a815bde56b15 ("net, bonding: Refactor bond_xmit_hash for use with xdp_buff")
Reported-by: Jonathan Toppins <redacted>
Signed-off-by: Jussi Maki <redacted>
---
drivers/net/bonding/bond_main.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
Hi Jussi,
Could you please share the null ptr deref trace?
I'm curious how we can get a null skb at that point.
Also how are the xdp and null ptr deref changes related ?
Thanks,
Nik
From: Jussi Maki <hidden> Date: 2021-08-12 15:12:24
On Thu, Aug 12, 2021 at 5:01 PM Nikolay Aleksandrov [off-list ref] wrote:
Hi Jussi,
Could you please share the null ptr deref trace?
I'm curious how we can get a null skb at that point.
Hi Nik, this was reported by Jonathan here:
https://lore.kernel.org/bpf/20210728234350.28796-1-joamaki@gmail.com/T/#m07a73b1886a9213feb7112ce2a0d6dfde84fd27a.
I didn't reproduce the null ptr deref as it was fairly obvious how it
can happen, e.g. by having a bond with xmit_policy=vlan+srcmac. The
hashing functions were refactored to be used for both xdp_buff and
skbuff uses and the skb pointer became optional (was meant to be used
when packet was non-linear), but I missed fixing the vlan hashing
function. Partially the reason leading to this was that the
xmit_policy is very new and the bpf vmtest infra still uses an older
iproute2 version which didn't support it, so this was untested. What
is not tested is broken as usual.
Also how are the xdp and null ptr deref changes related ?
They're related in that looking into the null ptr deref here I
realized that vlan+srcmac didn't make sense with XDP since we have no
guarantee that the vlan id is in the ethernet header. So this patch
both fixes the deref by checking the skb pointer for NULL and it
disallows the whole xmit policy for XDP for the aforementioned reason.
Hope this makes sense.
From: Nikolay Aleksandrov <hidden> Date: 2021-08-12 15:21:32
On 12/08/2021 18:12, Jussi Maki wrote:
On Thu, Aug 12, 2021 at 5:01 PM Nikolay Aleksandrov [off-list ref] wrote:
quoted
Hi Jussi,
Could you please share the null ptr deref trace?
I'm curious how we can get a null skb at that point.
Hi Nik, this was reported by Jonathan here:
https://lore.kernel.org/bpf/20210728234350.28796-1-joamaki@gmail.com/T/#m07a73b1886a9213feb7112ce2a0d6dfde84fd27a.
I didn't reproduce the null ptr deref as it was fairly obvious how it
can happen, e.g. by having a bond with xmit_policy=vlan+srcmac. The
hashing functions were refactored to be used for both xdp_buff and
skbuff uses and the skb pointer became optional (was meant to be used
when packet was non-linear), but I missed fixing the vlan hashing
function. Partially the reason leading to this was that the
xmit_policy is very new and the bpf vmtest infra still uses an older
iproute2 version which didn't support it, so this was untested. What
is not tested is broken as usual.
quoted
Also how are the xdp and null ptr deref changes related ?
They're related in that looking into the null ptr deref here I
realized that vlan+srcmac didn't make sense with XDP since we have no
guarantee that the vlan id is in the ethernet header. So this patch
both fixes the deref by checking the skb pointer for NULL and it
disallows the whole xmit policy for XDP for the aforementioned reason.
Hope this makes sense.
Oh, I had totally missed the bond xdp patch-set, all makes sense now.
Thanks,
Nik
From: Jonathan Toppins <hidden> Date: 2021-08-13 19:40:22
On 8/12/21 10:52 AM, Jussi Maki wrote:
The new vlan+srcmac xmit policy is not implementable with XDP since
in many cases the 802.1Q payload is not present in the packet. This
can be for example due to hardware offload or in the case of veth
due to use of skbuffs internally.
This also fixes the NULL deref with the vlan+srcmac xmit policy
reported by Jonathan Toppins by additionally checking the skb
pointer.
Fixes: a815bde56b15 ("net, bonding: Refactor bond_xmit_hash for use with xdp_buff")
Reported-by: Jonathan Toppins <redacted>
Signed-off-by: Jussi Maki <redacted>
Looks good, thanks.
Reviewed-by: Jonathan Toppins <redacted>
@@ -322,9 +322,15 @@ static bool bond_xdp_check(struct bonding *bond)switch(BOND_MODE(bond)){caseBOND_MODE_ROUNDROBIN:caseBOND_MODE_ACTIVEBACKUP:+returntrue;caseBOND_MODE_8023AD:caseBOND_MODE_XOR:-returntrue;+/* vlan+srcmac is not supported with XDP as in most cases the 802.1q+*payloadisnotinthepacketduetohardwareoffload.+*/+if(bond->params.xmit_policy!=BOND_XMIT_POLICY_VLAN_SRCMAC)+returntrue;+fallthrough;default:returnfalse;}
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
On Thu, 12 Aug 2021 14:52:41 +0000 you wrote:
The new vlan+srcmac xmit policy is not implementable with XDP since
in many cases the 802.1Q payload is not present in the packet. This
can be for example due to hardware offload or in the case of veth
due to use of skbuffs internally.
This also fixes the NULL deref with the vlan+srcmac xmit policy
reported by Jonathan Toppins by additionally checking the skb
pointer.
[...]