Skip to content

Commit 0aa7dea

Browse files
Jiri Slabydavem330
authored andcommitted
NET: wimax, fix use after free
Stanse found that i2400m_rx frees skb, but still uses skb->len even though it has skb_len defined. So use skb_len properly in the code. And also define it unsinged int rather than size_t to solve compilation warnings. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> Cc: linux-wimax@intel.com Acked-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ec622ab commit 0aa7dea

File tree

1 file changed

+13
-13
lines changed
  • drivers/net/wimax/i2400m

1 file changed

+13
-13
lines changed

drivers/net/wimax/i2400m/rx.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,35 +1244,35 @@ int i2400m_rx(struct i2400m *i2400m, struct sk_buff *skb)
12441244
int i, result;
12451245
struct device *dev = i2400m_dev(i2400m);
12461246
const struct i2400m_msg_hdr *msg_hdr;
1247-
size_t pl_itr, pl_size, skb_len;
1247+
size_t pl_itr, pl_size;
12481248
unsigned long flags;
1249-
unsigned num_pls, single_last;
1249+
unsigned num_pls, single_last, skb_len;
12501250

12511251
skb_len = skb->len;
1252-
d_fnstart(4, dev, "(i2400m %p skb %p [size %zu])\n",
1252+
d_fnstart(4, dev, "(i2400m %p skb %p [size %u])\n",
12531253
i2400m, skb, skb_len);
12541254
result = -EIO;
12551255
msg_hdr = (void *) skb->data;
1256-
result = i2400m_rx_msg_hdr_check(i2400m, msg_hdr, skb->len);
1256+
result = i2400m_rx_msg_hdr_check(i2400m, msg_hdr, skb_len);
12571257
if (result < 0)
12581258
goto error_msg_hdr_check;
12591259
result = -EIO;
12601260
num_pls = le16_to_cpu(msg_hdr->num_pls);
12611261
pl_itr = sizeof(*msg_hdr) + /* Check payload descriptor(s) */
12621262
num_pls * sizeof(msg_hdr->pld[0]);
12631263
pl_itr = ALIGN(pl_itr, I2400M_PL_ALIGN);
1264-
if (pl_itr > skb->len) { /* got all the payload descriptors? */
1264+
if (pl_itr > skb_len) { /* got all the payload descriptors? */
12651265
dev_err(dev, "RX: HW BUG? message too short (%u bytes) for "
12661266
"%u payload descriptors (%zu each, total %zu)\n",
1267-
skb->len, num_pls, sizeof(msg_hdr->pld[0]), pl_itr);
1267+
skb_len, num_pls, sizeof(msg_hdr->pld[0]), pl_itr);
12681268
goto error_pl_descr_short;
12691269
}
12701270
/* Walk each payload payload--check we really got it */
12711271
for (i = 0; i < num_pls; i++) {
12721272
/* work around old gcc warnings */
12731273
pl_size = i2400m_pld_size(&msg_hdr->pld[i]);
12741274
result = i2400m_rx_pl_descr_check(i2400m, &msg_hdr->pld[i],
1275-
pl_itr, skb->len);
1275+
pl_itr, skb_len);
12761276
if (result < 0)
12771277
goto error_pl_descr_check;
12781278
single_last = num_pls == 1 || i == num_pls - 1;
@@ -1290,16 +1290,16 @@ int i2400m_rx(struct i2400m *i2400m, struct sk_buff *skb)
12901290
if (i < i2400m->rx_pl_min)
12911291
i2400m->rx_pl_min = i;
12921292
i2400m->rx_num++;
1293-
i2400m->rx_size_acc += skb->len;
1294-
if (skb->len < i2400m->rx_size_min)
1295-
i2400m->rx_size_min = skb->len;
1296-
if (skb->len > i2400m->rx_size_max)
1297-
i2400m->rx_size_max = skb->len;
1293+
i2400m->rx_size_acc += skb_len;
1294+
if (skb_len < i2400m->rx_size_min)
1295+
i2400m->rx_size_min = skb_len;
1296+
if (skb_len > i2400m->rx_size_max)
1297+
i2400m->rx_size_max = skb_len;
12981298
spin_unlock_irqrestore(&i2400m->rx_lock, flags);
12991299
error_pl_descr_check:
13001300
error_pl_descr_short:
13011301
error_msg_hdr_check:
1302-
d_fnend(4, dev, "(i2400m %p skb %p [size %zu]) = %d\n",
1302+
d_fnend(4, dev, "(i2400m %p skb %p [size %u]) = %d\n",
13031303
i2400m, skb, skb_len, result);
13041304
return result;
13051305
}

0 commit comments

Comments
 (0)