net: gro: set the last skb->next to NULL when it get merged
Subsystems (2)
PATCH 1/1 net: gro: set the last skb->next to NULL when it get merged
From: Jason Xing <[email protected]>
Setting the @next of the last skb to NULL to prevent the panic in future when someone does something to the last of the gro list but its @next is invalid.
For example, without the fix (commit: ece23711dd95), a panic could happen with the clsact loaded when skb is redirected and then validated in validate_xmit_skb_list() which could access the error addr of the @next of the last skb. Thus, "general protection fault" would appear after that.
--- net/core/skbuff.c | 1 + 1 file changed, 1 insertion(+)
net/core/skbuff.c +1 -0
@@ -4396,6 +4396,7 @@ int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb)skb_shinfo (p)->frag_list = skb; else NAPI_GRO_CB(p)->last->next = skb; + skb->next = NULL; NAPI_GRO_CB(p)->last = skb; __skb_header_release(skb); lp = p;
Signature · 1 line
1.8.3.1
Quoted 22 lines · On Tue, Oct 26, 2021 at 9:19 PM <[email protected]> wrote:
From: Jason Xing <[email protected]>
Setting the @next of the last skb to NULL to prevent the panic in future when someone does something to the last of the gro list but its @next is invalid.
For example, without the fix (commit:
ece23711dd95), a panic could happen with the clsact loaded when skb is redirected and then validated invalidate_xmit_skb_list()which could access the error addr of the @next of the last skb. Thus, "general protection fault" would appear after that.Signed-off-by Jason Xing <[email protected]>--- net/core/skbuff.c | 1 + 1 file changed, 1 insertion(+)net/core/skbuff.c +0
-0
net/core/skbuff.c int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb) · line 4400
Quoted 5 lines
net/core/skbuff.c +1
-0@@ -4396,6 +4396,7 @@ int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb)skb_shinfo (p)->frag_list = skb; else NAPI_GRO_CB(p)->last->next = skb; + skb->next = NULL; NAPI_GRO_CB(p)->last = skb;
Besides, I'm a little bit confused that this operation inserts the newest skb into the tail of the flow, so the tail of flow is the newest, head oldest. The patch (commit: 600adc18) introduces the flush of the oldest when the flow is full to lower the latency, but actually it fetches the tail of the flow. Do I get something wrong here? I feel it is really odd.
Thanks,
Jason
Quoted 5 lines
net/core/skbuff.c +0
-1__skb_header_release (skb); lp = p; --1.8.3.1
Quoted 19 lines · Jason Xing
Quoted 17 lines · On Tue, Oct 26, 2021 at 9:19 PM <[email protected]> wrote:
From: Jason Xing <[email protected]>
Setting the @next of the last skb to NULL to prevent the panic in future when someone does something to the last of the gro list but its @next is invalid.
For example, without the fix (commit:
ece23711dd95), a panic could happen with the clsact loaded when skb is redirected and then validated invalidate_xmit_skb_list()which could access the error addr of the @next of the last skb. Thus, "general protection fault" would appear after that.Signed-off-by Jason Xing <[email protected]>--- net/core/skbuff.c | 1 + 1 file changed, 1 insertion(+)
Quoted 16 lines
net/core/skbuff.c int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb) · line 4400
Quoted 10 lines
net/core/skbuff.c +1
-0@@ -4396,6 +4396,7 @@ int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb)skb_shinfo (p)->frag_list = skb; else NAPI_GRO_CB(p)->last->next = skb; + skb->next = NULL; NAPI_GRO_CB(p)->last = skb;Besides, I'm a little bit confused that this operation inserts the newest skb into the tail of the flow, so the tail of flow is the newest, head oldest. The patch (commit:
600adc18) introduces the flush of the oldest when the flow is full to lower the latency, but actually it fetches the tail of the flow. Do I get something wrong here? I feel
I have to update this part. The commit 600adc18 evicts and flushes the oldest flow. But for the current kernel, when "napi->gro_hash[hash].count >= MAX_GRO_SKBS" happens, the gro_flush_oldest() flushes the oldest skb of one certain flow, actually it is the newest skb because it is at the end of the list.
Quoted 10 lines
it is really odd.
Thanks,
JasonQuoted 5 lines
net/core/skbuff.c +0
-1__skb_header_release (skb); lp = p; --1.8.3.1
Quoted 38 lines · Jason Xing
Quoted 19 lines · Jason Xing
Quoted 17 lines · On Tue, Oct 26, 2021 at 9:19 PM <[email protected]> wrote:
From: Jason Xing <[email protected]>
Setting the @next of the last skb to NULL to prevent the panic in future when someone does something to the last of the gro list but its @next is invalid.
For example, without the fix (commit:
ece23711dd95), a panic could happen with the clsact loaded when skb is redirected and then validated invalidate_xmit_skb_list()which could access the error addr of the @next of the last skb. Thus, "general protection fault" would appear after that.Signed-off-by Jason Xing <[email protected]>--- net/core/skbuff.c | 1 + 1 file changed, 1 insertion(+)Quoted 16 lines
net/core/skbuff.c int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb) · line 4400
Quoted 10 lines
net/core/skbuff.c +1
-0@@ -4396,6 +4396,7 @@ int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb)skb_shinfo (p)->frag_list = skb; else NAPI_GRO_CB(p)->last->next = skb; + skb->next = NULL; NAPI_GRO_CB(p)->last = skb;Besides, I'm a little bit confused that this operation inserts the newest skb into the tail of the flow, so the tail of flow is the newest, head oldest. The patch (commit:
600adc18) introduces the flush of the oldest when the flow is full to lower the latency, but actually it fetches the tail of the flow. Do I get something wrong here? I feel
Quoted 5 lines
I have to update this part. The commit
600adc18evicts and flushes the oldest flow. But for the current kernel, when "napi->gro_hash[hash].count >=MAX_GRO_SKBS" happens, thegro_flush_oldest()flushes the oldest skb of one certain flow, actually it is the newest skb because it is at the end of the list.
I just submitted another patch to explain how it happens, please help me review both patches.
Thanks again,
Jason
Quoted 11 lines
Quoted 11 lines
it is really odd.
Thanks,
JasonQuoted 5 lines
net/core/skbuff.c +0
-1__skb_header_release (skb); lp = p; --1.8.3.1
Quoted 39 lines · Jason Xing
Quoted 38 lines · Jason Xing
Quoted 35 lines · Jason Xing
Quoted 22 lines · On Tue, Oct 26, 2021 at 9:19 PM <[email protected]> wrote:
From: Jason Xing <[email protected]>
Setting the @next of the last skb to NULL to prevent the panic in future when someone does something to the last of the gro list but its @next is invalid.
For example, without the fix (commit:
ece23711dd95), a panic could happen with the clsact loaded when skb is redirected and then validated invalidate_xmit_skb_list()which could access the error addr of the @next of the last skb. Thus, "general protection fault" would appear after that.Signed-off-by Jason Xing <[email protected]>--- net/core/skbuff.c | 1 + 1 file changed, 1 insertion(+)net/core/skbuff.c +0
-0net/core/skbuff.c int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb) · line 4400
Quoted 5 lines
net/core/skbuff.c +1
-0@@ -4396,6 +4396,7 @@ int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb)skb_shinfo (p)->frag_list = skb; else NAPI_GRO_CB(p)->last->next = skb; + skb->next = NULL; NAPI_GRO_CB(p)->last = skb;Besides, I'm a little bit confused that this operation inserts the newest skb into the tail of the flow, so the tail of flow is the newest, head oldest. The patch (commit:
600adc18) introduces the flush of the oldest when the flow is full to lower the latency, but actually it fetches the tail of the flow. Do I get something wrong here? I feel
Quoted 5 lines
Quoted 5 lines
I have to update this part. The commit
600adc18evicts and flushes the oldest flow. But for the current kernel, when "napi->gro_hash[hash].count >=MAX_GRO_SKBS" happens, thegro_flush_oldest()flushes the oldest skb of one certain flow, actually it is the newest skb because it is at the end of the list.
it seems the below is more matched with the gro_flush_oldest() instead of the above code block:
https://elixir.bootlin.com/linux/v5.15-rc3/source/net/core/dev.c#L6118
Quoted 22 lines
I just submitted another patch to explain how it happens, please help me review both patches.
Thanks again,
JasonQuoted 11 lines
Quoted 11 lines
it is really odd.
Thanks,
JasonQuoted 5 lines
net/core/skbuff.c +0
-1__skb_header_release (skb); lp = p; --1.8.3.1
.
Quoted 47 lines · Yunsheng Lin
Quoted 39 lines · Jason Xing
Quoted 38 lines · Jason Xing
Quoted 35 lines · Jason Xing
Quoted 22 lines · On Tue, Oct 26, 2021 at 9:19 PM <[email protected]> wrote:
From: Jason Xing <[email protected]>
Setting the @next of the last skb to NULL to prevent the panic in future when someone does something to the last of the gro list but its @next is invalid.
For example, without the fix (commit:
ece23711dd95), a panic could happen with the clsact loaded when skb is redirected and then validated invalidate_xmit_skb_list()which could access the error addr of the @next of the last skb. Thus, "general protection fault" would appear after that.Signed-off-by Jason Xing <[email protected]>--- net/core/skbuff.c | 1 + 1 file changed, 1 insertion(+)net/core/skbuff.c +0
-0net/core/skbuff.c int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb) · line 4400
Quoted 5 lines
net/core/skbuff.c +1
-0@@ -4396,6 +4396,7 @@ int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb)skb_shinfo (p)->frag_list = skb; else NAPI_GRO_CB(p)->last->next = skb; + skb->next = NULL; NAPI_GRO_CB(p)->last = skb;Besides, I'm a little bit confused that this operation inserts the newest skb into the tail of the flow, so the tail of flow is the newest, head oldest. The patch (commit:
600adc18) introduces the flush of the oldest when the flow is full to lower the latency, but actually it fetches the tail of the flow. Do I get something wrong here? I feelQuoted 5 lines
Quoted 5 lines
I have to update this part. The commit
600adc18evicts and flushes the oldest flow. But for the current kernel, when "napi->gro_hash[hash].count >=MAX_GRO_SKBS" happens, thegro_flush_oldest()flushes the oldest skb of one certain flow, actually it is the newest skb because it is at the end of the list.
Quoted 4 lines
it seems the below is more matched with the
gro_flush_oldest()instead of the above code block:
https://elixir.bootlin.com/linux/v5.15-rc3/source/net/core/dev.c#L6118
What you said is the @skb->list but not the list between skbs which is connected by skb->next when the new incoming skb needs to get merged. The @skb->list->next/prev is not the same as @skb->next.
Quoted 22 lines
Quoted 22 lines
I just submitted another patch to explain how it happens, please help me review both patches.
Thanks again,
JasonQuoted 11 lines
Quoted 11 lines
it is really odd.
Thanks,
JasonQuoted 5 lines
net/core/skbuff.c +0
-1__skb_header_release (skb); lp = p; --1.8.3.1
.
Quoted 49 lines · Jason Xing
Quoted 47 lines · Yunsheng Lin
Quoted 44 lines · Jason Xing
Quoted 43 lines · Jason Xing
Quoted 19 lines · Jason Xing
Quoted 17 lines · On Tue, Oct 26, 2021 at 9:19 PM <[email protected]> wrote:
From: Jason Xing <[email protected]>
Setting the @next of the last skb to NULL to prevent the panic in future when someone does something to the last of the gro list but its @next is invalid.
For example, without the fix (commit:
ece23711dd95), a panic could happen with the clsact loaded when skb is redirected and then validated invalidate_xmit_skb_list()which could access the error addr of the @next of the last skb. Thus, "general protection fault" would appear after that.Signed-off-by Jason Xing <[email protected]>--- net/core/skbuff.c | 1 + 1 file changed, 1 insertion(+)Quoted 16 lines
net/core/skbuff.c int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb) · line 4400
Quoted 10 lines
net/core/skbuff.c +1
-0@@ -4396,6 +4396,7 @@ int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb)skb_shinfo (p)->frag_list = skb; else NAPI_GRO_CB(p)->last->next = skb; + skb->next = NULL; NAPI_GRO_CB(p)->last = skb;Besides, I'm a little bit confused that this operation inserts the newest skb into the tail of the flow, so the tail of flow is the newest, head oldest. The patch (commit:
600adc18) introduces the flush of the oldest when the flow is full to lower the latency, but actually it fetches the tail of the flow. Do I get something wrong here? I feelI have to update this part. The commit
600adc18evicts and flushes the oldest flow. But for the current kernel, when "napi->gro_hash[hash].count >=MAX_GRO_SKBS" happens, thegro_flush_oldest()flushes the oldest skb of one certain flow, actually it is the newest skb because it is at the end of the list.
Quoted 15 lines
Quoted 4 lines
it seems the below is more matched with the
gro_flush_oldest()instead of the above code block:
https://elixir.bootlin.com/linux/v5.15-rc3/source/net/core/dev.c#L6118What you said is the @skb->list but not the list between skbs which is connected by
skb->nextwhen the new incoming skb needs to get merged. The @skb->list->next/prev is not the same as @skb->next.Quoted 6 lines
Quoted 6 lines
I just submitted another patch to explain how it happens, please help me review both patches.
Emm, I think you're right, Yunsheng. The gro_flush_oldest() fetches the list of @skb->list.
Do you think the tail of skb's next pointer should be set to NULL?
Thanks,
Jason
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Thanks again,
JasonQuoted 11 lines
Quoted 11 lines
it is really odd.
Thanks,
JasonQuoted 5 lines
net/core/skbuff.c +0
-1__skb_header_release (skb); lp = p; --1.8.3.1
.
Quoted 37 lines · Jason Xing
Quoted 19 lines · Jason Xing
Quoted 17 lines · On Tue, Oct 26, 2021 at 9:19 PM <[email protected]> wrote:
From: Jason Xing <[email protected]>
Setting the @next of the last skb to NULL to prevent the panic in future when someone does something to the last of the gro list but its @next is invalid.
For example, without the fix (commit:
ece23711dd95), a panic could happen with the clsact loaded when skb is redirected and then validated invalidate_xmit_skb_list()which could access the error addr of the @next of the last skb. Thus, "general protection fault" would appear after that.Signed-off-by Jason Xing <[email protected]>--- net/core/skbuff.c | 1 + 1 file changed, 1 insertion(+)Quoted 16 lines
net/core/skbuff.c int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb) · line 4400
Quoted 10 lines
net/core/skbuff.c +1
-0@@ -4396,6 +4396,7 @@ int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb)skb_shinfo (p)->frag_list = skb; else NAPI_GRO_CB(p)->last->next = skb; + skb->next = NULL; NAPI_GRO_CB(p)->last = skb;Besides, I'm a little bit confused that this operation inserts the newest skb into the tail of the flow, so the tail of flow is the newest, head oldest. The patch (commit:
600adc18) introduces the flush of the oldest when the flow is full to lower the latency, but actually it fetches the tail of the flow. Do I get something wrong here? I feel
Quoted 5 lines
I have to update this part. The commit
600adc18evicts and flushes the oldest flow. But for the current kernel, when "napi->gro_hash[hash].count >=MAX_GRO_SKBS" happens, thegro_flush_oldest()flushes the oldest skb of one certain flow, actually it is the newest skb because it is at the end of the list.
GRO only keeps one skb per flow in the main hash/lru.
I think you are not understanding GRO correctly.
Quoted 11 lines · On 10/26/21 6:18 AM, [email protected] wrote:
From: Jason Xing <[email protected]>
Setting the @next of the last skb to NULL to prevent the panic in future when someone does something to the last of the gro list but its @next is invalid.
For example, without the fix (commit:
ece23711dd95), a panic could happen with the clsact loaded when skb is redirected and then validated invalidate_xmit_skb_list()which could access the error addr of the @next of the last skb. Thus, "general protection fault" would appear after that.
If this a bug, please provide a Fixes: tag
Quoted 10 lines
Signed-off-by Jason Xing <[email protected]>--- net/core/skbuff.c | 1 + 1 file changed, 1 insertion(+)net/core/skbuff.c +0
-0
net/core/skbuff.c int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb) · line 4399
Quoted 4 lines
net/core/skbuff.c +1
-0@@ -4396,6 +4396,7 @@ int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb)skb_shinfo (p)->frag_list = skb; else NAPI_GRO_CB(p)->last->next = skb; + skb->next = NULL;
Really at this point skb->next must be already NULL.
Please provide a stack trace so that we fix the caller instead of adding more code in GRO layer.
Quoted 4 lines
net/core/skbuff.c +0
-0NAPI_GRO_CB (p)->last = skb;__skb_header_release (skb); lp = p;