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]
Date:   Thu, 16 Feb 2023 10:53:41 +0900
From:   sangsup lee <k1rh4.lee@...il.com>
To:     Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
Cc:     Amol Maheshwari <amahesh@....qualcomm.com>,
        Arnd Bergmann <arnd@...db.de>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-arm-msm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] misc: fastrpc: Fix a Use after-free-bug by race condition

As I'm not an expert for the fastrpc driver, I'm not sure about the patch code.
But I think the bug should be patched.
Please suggest a proper patch.

Best regards,

2023년 2월 16일 (목) 오전 10:41, Sangsup Lee <k1rh4.lee@...il.com>님이 작성:
>
> This patch adds mutex_lock for fixing an Use-after-free bug.
> fastrpc_req_munmap_impl can be called concurrently in multi-threded environments.
> The buf which is allocated by list_for_each_safe can be used after another thread frees it.
>
> Signed-off-by: Sangsup Lee <k1rh4.lee@...il.com>
> ---
>  drivers/misc/fastrpc.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index 5310606113fe..c4b5fa4a50a6 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
> @@ -1806,10 +1806,12 @@ static int fastrpc_req_munmap(struct fastrpc_user *fl, char __user *argp)
>         struct fastrpc_buf *buf = NULL, *iter, *b;
>         struct fastrpc_req_munmap req;
>         struct device *dev = fl->sctx->dev;
> +       int err;
>
>         if (copy_from_user(&req, argp, sizeof(req)))
>                 return -EFAULT;
>
> +       mutex_lock(&fl->mutex);
>         spin_lock(&fl->lock);
>         list_for_each_entry_safe(iter, b, &fl->mmaps, node) {
>                 if ((iter->raddr == req.vaddrout) && (iter->size == req.size)) {
> @@ -1822,10 +1824,13 @@ static int fastrpc_req_munmap(struct fastrpc_user *fl, char __user *argp)
>         if (!buf) {
>                 dev_err(dev, "mmap\t\tpt 0x%09llx [len 0x%08llx] not in list\n",
>                         req.vaddrout, req.size);
> +               mutex_unlock(&fl->mutex);
>                 return -EINVAL;
>         }
>
> -       return fastrpc_req_munmap_impl(fl, buf);
> +       err = fastrpc_req_munmap_impl(fl, buf);
> +       mutex_unlock(&fl->mutex);
> +       return err;
>  }
>
>  static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp)
> --
> 2.25.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ