Skip to content

Commit d841588

Browse files
CIQ Kernel Automationroxanan1996
authored andcommitted
net/sched: cls_u32: use skb_header_pointer_careful()
jira VULN-176127 cve CVE-2026-23204 commit-author Eric Dumazet <edumazet@google.com> commit cabd1a9 skb_header_pointer() does not fully validate negative @offset values. Use skb_header_pointer_careful() instead. GangMin Kim provided a report and a repro fooling u32_classify(): BUG: KASAN: slab-out-of-bounds in u32_classify+0x1180/0x11b0 net/sched/cls_u32.c:221 Fixes: fbc2e7d ("cls_u32: use skb_header_pointer() to dereference data safely") Reported-by: GangMin Kim <km.kim1503@gmail.com> Closes: https://lore.kernel.org/netdev/CANn89iJkyUZ=mAzLzC4GdcAgLuPnUoivdLaOs6B9rq5_erj76w@mail.gmail.com/T/ Signed-off-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20260128141539.3404400-3-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> (cherry picked from commit cabd1a9) Signed-off-by: CIQ Kernel Automation <ciq_kernel_automation@ciq.com>
1 parent 759dc8f commit d841588

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

net/sched/cls_u32.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,8 @@ static int u32_classify(struct sk_buff *skb, const struct tcf_proto *tp,
153153
int toff = off + key->off + (off2 & key->offmask);
154154
__be32 *data, hdata;
155155

156-
if (skb_headroom(skb) + toff > INT_MAX)
157-
goto out;
158-
159-
data = skb_header_pointer(skb, toff, 4, &hdata);
156+
data = skb_header_pointer_careful(skb, toff, 4,
157+
&hdata);
160158
if (!data)
161159
goto out;
162160
if ((*data ^ key->val) & key->mask) {
@@ -206,8 +204,9 @@ static int u32_classify(struct sk_buff *skb, const struct tcf_proto *tp,
206204
if (ht->divisor) {
207205
__be32 *data, hdata;
208206

209-
data = skb_header_pointer(skb, off + n->sel.hoff, 4,
210-
&hdata);
207+
data = skb_header_pointer_careful(skb,
208+
off + n->sel.hoff,
209+
4, &hdata);
211210
if (!data)
212211
goto out;
213212
sel = ht->divisor & u32_hash_fold(*data, &n->sel,
@@ -221,7 +220,7 @@ static int u32_classify(struct sk_buff *skb, const struct tcf_proto *tp,
221220
if (n->sel.flags & TC_U32_VAROFFSET) {
222221
__be16 *data, hdata;
223222

224-
data = skb_header_pointer(skb,
223+
data = skb_header_pointer_careful(skb,
225224
off + n->sel.offoff,
226225
2, &hdata);
227226
if (!data)

0 commit comments

Comments
 (0)