summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMenglong Dong <imagedong@tencent.com>2022-05-13 11:03:36 +0800
committerDavid S. Miller <davem@davemloft.net>2022-05-16 10:47:43 +0100
commita3af33abd9210c93dc829b4fdd7a19f63f168a25 (patch)
tree7f4c61b9ab4241fd95cb616c8d95ad56632687ec /net
parent3aba103006bcc4a7472b7c9506b3bc065ffb7992 (diff)
downloadlinux-a3af33abd9210c93dc829b4fdd7a19f63f168a25.tar.bz2
net: dm: check the boundary of skb drop reasons
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@tencent.com> Reviewed-by: Hao Peng <flyingpeng@tencent.com> Signed-off-by: Menglong Dong <imagedong@tencent.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/drop_monitor.c2
1 files changed, 1 insertions, 1 deletions
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;