Skip to content

Commit 2673e19

Browse files
committed
Merge: CVE-2024-53213: net: usb: lan78xx: Fix double free issue with interrupt buffer allocation
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6170 JIRA: https://issues.redhat.com/browse/RHEL-72355 CVE: CVE-2024-53213 ``` net: usb: lan78xx: Fix double free issue with interrupt buffer allocation In lan78xx_probe(), the buffer `buf` was being freed twice: once implicitly through `usb_free_urb(dev->urb_intr)` with the `URB_FREE_BUFFER` flag and again explicitly by `kfree(buf)`. This caused a double free issue. To resolve this, reordered `kmalloc()` and `usb_alloc_urb()` calls to simplify the initialization sequence and removed the redundant `kfree(buf)`. Now, `buf` is allocated after `usb_alloc_urb()`, ensuring it is correctly managed by `usb_fill_int_urb()` and freed by `usb_free_urb()` as intended. Fixes: a6df95c ("lan78xx: Fix memory allocation bug") Cc: John Efstathiades <john.efstathiades@pebblebay.com> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://patch.msgid.link/20241116130558.1352230-1-o.rempel@pengutronix.de Signed-off-by: Jakub Kicinski <kuba@kernel.org> (cherry picked from commit 03819ab) ``` Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com> --- <small>Created 2025-01-14 11:45 UTC by backporter - [KWF FAQ](https://red.ht/kernel_workflow_doc) - [Slack #team-kernel-workflow](https://redhat-internal.slack.com/archives/C04LRUPMJQ5) - [Source](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/webhook/utils/backporter.py) - [Documentation](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/docs/README.backporter.md) - [Report an issue](https://gitlab.com/cki-project/kernel-workflow/-/issues/new?issue%5Btitle%5D=backporter%20webhook%20issue)</small> Approved-by: José Ignacio Tornos Martínez <jtornosm@redhat.com> Approved-by: mheib <mheib@redhat.com> Approved-by: Michal Schmidt <mschmidt@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Patrick Talbert <ptalbert@redhat.com>
2 parents a42c50c + 1f4777d commit 2673e19

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

drivers/net/usb/lan78xx.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4412,37 +4412,38 @@ static int lan78xx_probe(struct usb_interface *intf,
44124412

44134413
period = ep_intr->desc.bInterval;
44144414
maxp = usb_maxpacket(dev->udev, dev->pipe_intr);
4415-
buf = kmalloc(maxp, GFP_KERNEL);
4416-
if (!buf) {
4415+
4416+
dev->urb_intr = usb_alloc_urb(0, GFP_KERNEL);
4417+
if (!dev->urb_intr) {
44174418
ret = -ENOMEM;
44184419
goto out5;
44194420
}
44204421

4421-
dev->urb_intr = usb_alloc_urb(0, GFP_KERNEL);
4422-
if (!dev->urb_intr) {
4422+
buf = kmalloc(maxp, GFP_KERNEL);
4423+
if (!buf) {
44234424
ret = -ENOMEM;
4424-
goto out6;
4425-
} else {
4426-
usb_fill_int_urb(dev->urb_intr, dev->udev,
4427-
dev->pipe_intr, buf, maxp,
4428-
intr_complete, dev, period);
4429-
dev->urb_intr->transfer_flags |= URB_FREE_BUFFER;
4425+
goto free_urbs;
44304426
}
44314427

4428+
usb_fill_int_urb(dev->urb_intr, dev->udev,
4429+
dev->pipe_intr, buf, maxp,
4430+
intr_complete, dev, period);
4431+
dev->urb_intr->transfer_flags |= URB_FREE_BUFFER;
4432+
44324433
dev->maxpacket = usb_maxpacket(dev->udev, dev->pipe_out);
44334434

44344435
/* Reject broken descriptors. */
44354436
if (dev->maxpacket == 0) {
44364437
ret = -ENODEV;
4437-
goto out6;
4438+
goto free_urbs;
44384439
}
44394440

44404441
/* driver requires remote-wakeup capability during autosuspend. */
44414442
intf->needs_remote_wakeup = 1;
44424443

44434444
ret = lan78xx_phy_init(dev);
44444445
if (ret < 0)
4445-
goto out7;
4446+
goto free_urbs;
44464447

44474448
ret = register_netdev(netdev);
44484449
if (ret != 0) {
@@ -4464,10 +4465,8 @@ static int lan78xx_probe(struct usb_interface *intf,
44644465

44654466
out8:
44664467
phy_disconnect(netdev->phydev);
4467-
out7:
4468+
free_urbs:
44684469
usb_free_urb(dev->urb_intr);
4469-
out6:
4470-
kfree(buf);
44714470
out5:
44724471
lan78xx_unbind(dev, intf);
44734472
out4:

0 commit comments

Comments
 (0)