lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251103111915.18191A14-hca@linux.ibm.com>
Date: Mon, 3 Nov 2025 12:19:15 +0100
From: Heiko Carstens <hca@...ux.ibm.com>
To: Duoming Zhou <duoming@....edu.cn>, Jan Hoeppner <hoeppner@...ux.ibm.com>
Cc: linux-s390@...r.kernel.org, linux-kernel@...r.kernel.org,
        gor@...ux.ibm.com, agordeev@...ux.ibm.com, borntraeger@...ux.ibm.com,
        svens@...ux.ibm.com, mingo@...nel.org, tglx@...utronix.de
Subject: Re: [PATCH] s390/tape: fix use-after-free bugs caused by tape_dnr
 delayed work

[full quote below - adding Jan]

On Mon, Nov 03, 2025 at 02:05:44PM +0800, Duoming Zhou wrote:
> The delayed work tape_dnr is initialized in tape_alloc_device(), which
> is called from tape_generic_probe(), and is scheduled in the following
> scenarios:
> 
> 1. Starting an I/O operation fails with -EBUSY in __tape_start_io().
> 2. Canceling an I/O operation fails with -EBUSY in __tape_cancel_io().
> 3. A deferred error condition is detected in __tape_do_irq().
> 
> When the tape device is detached via tape_generic_remove(), the
> tape_device structure might be deallocated after the final call to
> tape_put_device(). However, if the delayed work tape_dnr is still
> pending or executing at the time of detachment, it could lead to
> use-after-free bugs when the work function tape_delayed_next_request()
> accesses the already freed tape_device memory.
> 
> The race condition can occur as follows:
> 
> CPU 0(detach thread)      | CPU 1 (delayed work)
> tape_generic_remove()     |
>   tape_put_device(device) | tape_delayed_next_request
>                           |   device = container_of(...) // USE
>                           |   device-> // USE
> 
> Add disable_delayed_work_sync() in tape_generic_remove() to guarantee
> proper cancellation of the delayed work item before tape_device is
> deallocated.
> 
> This bug is identified by static analysis.
> 
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Duoming Zhou <duoming@....edu.cn>
> ---
>  drivers/s390/char/tape_core.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/s390/char/tape_core.c b/drivers/s390/char/tape_core.c
> index 6ec812280221..722dc4737a87 100644
> --- a/drivers/s390/char/tape_core.c
> +++ b/drivers/s390/char/tape_core.c
> @@ -625,6 +625,7 @@ tape_generic_remove(struct ccw_device *cdev)
>  	}
>  	DBF_LH(3, "(%08x): tape_generic_remove(%p)\n", device->cdev_id, cdev);
>  
> +	disable_delayed_work_sync(&device->tape_dnr);
>  	spin_lock_irq(get_ccwdev_lock(device->cdev));
>  	switch (device->tape_state) {
>  		case TS_INIT:

Jan, could you please have a look at this?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ