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] [thread-next>] [day] [month] [year] [list]
Message-ID: <jbkzqczxnnf5el6xxyumeyoact7iw3js6reoand3clrpjyyblf@fhxvbg7fu6n5>
Date: Fri, 7 Nov 2025 21:43:37 -0800
From: Dmitry Torokhov <dmitry.torokhov@...il.com>
To: Duoming Zhou <duoming@....edu.cn>
Cc: linux-input@...r.kernel.org, linux-kernel@...r.kernel.org, 
	kuba@...nel.org, alexander.deucher@....com, pali@...nel.org, 
	hverkuil+cisco@...nel.org, akpm@...ux-foundation.org, andriy.shevchenko@...ux.intel.com, 
	tglx@...utronix.de, mingo@...nel.org, Jonathan.Cameron@...wei.com
Subject: Re: [PATCH] Input: psmouse - fix use-after-free bugs due to
 rescheduled delayed works

Hi Duoming,

On Sat, Nov 08, 2025 at 12:56:09PM +0800, Duoming Zhou wrote:
> The flush_workqueue() in psmouse_disconnect() only blocks and waits for
> work items that were already queued to the workqueue prior to its
> invocation. Any work items submitted after flush_workqueue() is called
> are not included in the set of tasks that the flush operation awaits.
> This means that after flush_workqueue() has finished executing, the
> resync_work and dev3_register_work could be rescheduled again, resulting
> in the following two use-after-free scenarios:
> 
> 1. The psmouse structure is deallocated in psmouse_disconnect(), while
> resync_work remains active and attempts to dereference the already
> freed psmouse in psmouse_resync().
> 
> CPU 0                   | CPU 1
> psmouse_disconnect()    | psmouse_receive_byte()
>                         |   if(psmouse->state == ...)
>   psmouse_set_state()   |
>   flush_workqueue()     |
>                         |   psmouse_queue_work() //reschedule
>   kfree(psmouse); //FREE|
>                         | psmouse_resync()
>                         |   psmouse = container_of(); //USE
>                         |   psmouse-> //USE

Before flushing the workqueue we set psmouse state to PSMOUSE_CMD_MODE,
but psmouse_queue_work() is only called from psmouse_receive_byte() if
the mouse is PSMOUSE_ACTIVE. Therefore there is no chance that work will
be scheduled while psmouse instance is being freed.

For ALPS, the work is a "single shot", so will not get rescheduled.

However I think that the changes are improvement to the code. Please
split in 2 (for psmouse-base and alps separately) and drop mentions of
UAF in psmouse but rather mention that disable_delayed_work_sync() is
more robust and efficient. I think if we switch to it we should be able
to get rid of kpsmoused workqueue and use default system workqueue.

Thanks.

-- 
Dmitry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ