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: <CAHp75VdpkswJiuA9ems_7o8i9W8HWN4BredO7qsaR6HjO5TxdQ@mail.gmail.com>
Date: Thu, 17 Jul 2025 08:57:45 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Abdelrahman Fekry <abdelrahmanfekry375@...il.com>
Cc: hansg@...nel.org, mchehab@...nel.org, sakari.ailus@...ux.intel.com, 
	andy@...nel.org, gregkh@...uxfoundation.org, linux-media@...r.kernel.org, 
	linux-kernel@...r.kernel.org, linux-staging@...ts.linux.dev, 
	linux-kernel-mentees@...ts.linux.dev, skhan@...uxfoundation.org, 
	dan.carpenter@...aro.org
Subject: Re: [PATCH v2] staging: media: atomisp: add missing mutex lock in atomisp_s_fmt_cap

On Thu, Jul 17, 2025 at 4:30 AM Abdelrahman Fekry
<abdelrahmanfekry375@...il.com> wrote:
>
> The function atomisp_set_fmt() modifies shared device state and expects
> callers to hold the isp->mutex for synchronization. While most internal
> callers correctly lock the mutex before invoking atomisp_set_fmt(), the
> V4L2 ioctl handler atomisp_s_fmt_cap() does not.
>
> This results in an unsafe execution path for VIDIOC_S_FMT ioctls
> (e.g. via v4l2-ctl), where shared structures such as pipe->pix and
> pipe->frame_info may be modified concurrently without proper protection.
>
> - Fix this by explicitly locking isp->mutex in atomisp_s_fmt_cap().

...

>  #include <linux/delay.h>
>  #include <linux/pci.h>
> +#include <linux/cleanup.h>

Keep it ordered.

...

> +       int ret;
>
> -       return atomisp_set_fmt(vdev, f);
> +       scoped_guard(mutex, &isp->mutex)
> +       {
> +               ret = atomisp_set_fmt(vdev, f);
> +       }
> +       return ret;

As Dan said, this should just add a (one line) guard()() and no other
lines being touched.

>  }

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ