Re: [PATCH v2 2/2] i2c: dev: don't allow user-space to deadlock the kernel

Bartosz Golaszewski
2023-01-18T15:07:28Z

On Wed, Jan 18, 2023 at 3:59 PM Hillf Danton <hdanton@sina.com> wrote:
>
> On Thu, 29 Dec 2022 17:00:45 +0100 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > @@ -44,8 +45,14 @@ struct i2c_dev {
> > struct i2c_adapter *adap;
> > struct device dev;
> > struct cdev cdev;
> > + struct rw_semaphore sem;
>
> int state;
> #define STATE_RELEASED 1
> #define STATE_DETACHED 2
> > };
>
> Because syscalls like read, write and ioctl have completed upon release,
> serializing the release and detach pathes is a cure to the issue.
>

Please elaborate because I have no idea what you mean by that.

Bart