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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2025010807-babble-album-7bfd@gregkh>
Date: Wed, 8 Jan 2025 07:07:59 +0100
From: Greg KH <gregkh@...uxfoundation.org>
To: Ling Xu <quic_lxu5@...cinc.com>
Cc: srinivas.kandagatla@...aro.org, amahesh@....qualcomm.com, arnd@...db.de,
	quic_kuiw@...cinc.com, quic_ekangupt@...cinc.com,
	linux-arm-msm@...r.kernel.org, dri-devel@...ts.freedesktop.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] misc: fastrpc: Fix race condition in MUNMAP

On Wed, Jan 08, 2025 at 10:18:02AM +0530, Ling Xu wrote:
> fastrpc_req_munmap involves two steps to unmap memory, first to locates
> a matching fastrpc buf in the list and second is to send request to DSP
> to unmap. There is a potential race condition between two operations
> which can lead to user-after-free scenario.
> Lock unmap request to avoid use-after-free.
> 
> Signed-off-by: Ling Xu <quic_lxu5@...cinc.com>
> ---
>  drivers/misc/fastrpc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index 7b7a22c91fe4..9ad092d3a705 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
> @@ -2117,7 +2117,9 @@ static long fastrpc_device_ioctl(struct file *file, unsigned int cmd,
>  		err = fastrpc_req_mmap(fl, argp);
>  		break;
>  	case FASTRPC_IOCTL_MUNMAP:
> +		mutex_lock(&fl->mutex);
>  		err = fastrpc_req_munmap(fl, argp);
> +		mutex_unlock(&fl->mutex);

Why do you grab a mutex here when this function grabs the spinlock too?
This feels like an odd fix, shouldn't the lock be in the function at the
very least?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ