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

From: Bartosz Golaszewski
Date: Wed Jan 18 2023 - 10:07:33 EST


On Wed, Jan 18, 2023 at 3:59 PM Hillf Danton <hdanton@xxxxxxxx> wrote:
>
> On Thu, 29 Dec 2022 17:00:45 +0100 Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
> >
> > @@ -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