[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220513030339.336580-2-imagedong@tencent.com>
Date: Fri, 13 May 2022 11:03:36 +0800
From: menglong8.dong@...il.com
To: kuba@...nel.org
Cc: nhorman@...driver.com, davem@...emloft.net, edumazet@...gle.com,
pabeni@...hat.com, yoshfuji@...ux-ipv6.org, dsahern@...nel.org,
imagedong@...cent.com, kafai@...com, talalahmad@...gle.com,
keescook@...omium.org, asml.silence@...il.com, willemb@...gle.com,
vasily.averin@...ux.dev, ilias.apalodimas@...aro.org,
luiz.von.dentz@...el.com, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org, Jiang Biao <benbjiang@...cent.com>,
Hao Peng <flyingpeng@...cent.com>
Subject: [PATCH net-next v3 1/4] net: dm: check the boundary of skb drop reasons
From: Menglong Dong <imagedong@...cent.com>
The 'reason' will be set to 'SKB_DROP_REASON_NOT_SPECIFIED' if it not
small that SKB_DROP_REASON_MAX in net_dm_packet_trace_kfree_skb_hit(),
but it can't avoid it to be 0, which is invalid and can cause NULL
pointer in drop_reasons.
Therefore, reset it to SKB_DROP_REASON_NOT_SPECIFIED when 'reason <= 0'.
Reviewed-by: Jiang Biao <benbjiang@...cent.com>
Reviewed-by: Hao Peng <flyingpeng@...cent.com>
Signed-off-by: Menglong Dong <imagedong@...cent.com>
---
net/core/drop_monitor.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index b89e3e95bffc..41cac0e4834e 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -517,7 +517,7 @@ static void net_dm_packet_trace_kfree_skb_hit(void *ignore,
if (!nskb)
return;
- if ((unsigned int)reason >= SKB_DROP_REASON_MAX)
+ if (unlikely(reason >= SKB_DROP_REASON_MAX || reason <= 0))
reason = SKB_DROP_REASON_NOT_SPECIFIED;
cb = NET_DM_SKB_CB(nskb);
cb->reason = reason;
--
2.36.1
Powered by blists - more mailing lists