Subject: Re: [PATCH] atm: Fix use-after-free bug in atm_dev_register()

From: Jakub Kicinski <[email-masked]>
Date: Mon, 5 Dec 2022 18:08:42 -0800

On Tue, 6 Dec 2022 00:08:32 +0200 Nir Levy wrote:
> From 5cb38a02b10a2f52bf7f7eef67fa4abc0974b21b Mon Sep 17 00:00:00 2001
> From: Nir Levy <[email-masked]>
> Date: Fri, 25 Nov 2022 21:06:48 +0200
> Subject: [PATCH net] net: atm: Fix use-after-free bug in atm_dev_register()
> 
> When device_register() return failed in atm_register_sysfs,
> the program will return to atm_dev_register and will kfree
> the device. As the comment of device_register() says,
> put_device() needs to be used to give up the reference
> in the error path. Using kfree instead triggers a UAF,
> as shown by the following KASAN report, obtained by causing
> device_register() to fail. This patch calls put_device
> when atm_register_sysfs has failed, and call kfree
> only when atm_proc_dev_register has failed.

Please make a fresh submission, it doesn't have to be in the same
thread (in fact that's discouraged).