This is a note to let you know that I've just added the patch titled ipack: ipoctal: fix stack information leak to the 4.4-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: ipack-ipoctal-fix-stack-information-leak.patch and it can be found in the queue-4.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From a89936cce87d60766a75732a9e7e25c51164f47c Mon Sep 17 00:00:00 2001 From: Johan Hovold <johan@xxxxxxxxxx> Date: Fri, 17 Sep 2021 13:46:17 +0200 Subject: ipack: ipoctal: fix stack information leak From: Johan Hovold <johan@xxxxxxxxxx> commit a89936cce87d60766a75732a9e7e25c51164f47c upstream. The tty driver name is used also after registering the driver and must specifically not be allocated on the stack to avoid leaking information to user space (or triggering an oops). Drivers should not try to encode topology information in the tty device name but this one snuck in through staging without anyone noticing and another driver has since copied this malpractice. Fixing the ABI is a separate issue, but this at least plugs the security hole. Fixes: ba4dc61fe8c5 ("Staging: ipack: add support for IP-OCTAL mezzanine board") Cc: stable@xxxxxxxxxxxxxxx # 3.5 Acked-by: Samuel Iglesias Gonsalvez <siglesias@xxxxxxxxxx> Signed-off-by: Johan Hovold <johan@xxxxxxxxxx> Link: https://lore.kernel.org/r/20210917114622.5412-2-johan@xxxxxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/ipack/devices/ipoctal.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) --- a/drivers/ipack/devices/ipoctal.c +++ b/drivers/ipack/devices/ipoctal.c @@ -269,7 +269,6 @@ static int ipoctal_inst_slot(struct ipoc int res; int i; struct tty_driver *tty; - char name[20]; struct ipoctal_channel *channel; struct ipack_region *region; void __iomem *addr; @@ -360,8 +359,11 @@ static int ipoctal_inst_slot(struct ipoc /* Fill struct tty_driver with ipoctal data */ tty->owner = THIS_MODULE; tty->driver_name = KBUILD_MODNAME; - sprintf(name, KBUILD_MODNAME ".%d.%d.", bus_nr, slot); - tty->name = name; + tty->name = kasprintf(GFP_KERNEL, KBUILD_MODNAME ".%d.%d.", bus_nr, slot); + if (!tty->name) { + res = -ENOMEM; + goto err_put_driver; + } tty->major = 0; tty->minor_start = 0; @@ -377,8 +379,7 @@ static int ipoctal_inst_slot(struct ipoc res = tty_register_driver(tty); if (res) { dev_err(&ipoctal->dev->dev, "Can't register tty driver.\n"); - put_tty_driver(tty); - return res; + goto err_free_name; } /* Save struct tty_driver for use it when uninstalling the device */ @@ -415,6 +416,13 @@ static int ipoctal_inst_slot(struct ipoc ipoctal_irq_handler, ipoctal); return 0; + +err_free_name: + kfree(tty->name); +err_put_driver: + put_tty_driver(tty); + + return res; } static inline int ipoctal_copy_write_buffer(struct ipoctal_channel *channel, @@ -704,6 +712,7 @@ static void __ipoctal_remove(struct ipoc } tty_unregister_driver(ipoctal->tty_drv); + kfree(ipoctal->tty_drv->name); put_tty_driver(ipoctal->tty_drv); kfree(ipoctal); } Patches currently in stable-queue which might be from johan@xxxxxxxxxx are queue-4.4/ipack-ipoctal-fix-stack-information-leak.patch queue-4.4/ipack-ipoctal-fix-tty-registration-race.patch queue-4.4/ipack-ipoctal-fix-module-reference-leak.patch queue-4.4/usb-serial-option-add-device-id-for-foxconn-t99w265.patch queue-4.4/usb-serial-cp210x-add-id-for-gw-instek-gdm-834x-digital-multimeter.patch queue-4.4/net-hso-fix-muxed-tty-registration.patch queue-4.4/usb-serial-mos7840-remove-duplicated-0xac24-device-id.patch queue-4.4/ipack-ipoctal-fix-missing-allocation-failure-check.patch queue-4.4/ipack-ipoctal-fix-tty-registration-error-handling.patch queue-4.4/usb-serial-option-add-telit-ln920-compositions.patch queue-4.4/usb-serial-option-remove-duplicate-usb-device-id.patch