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]
Message-ID: <20210324040229.45gxaqfkfqjwleed@vireshk-i7>
Date:   Wed, 24 Mar 2021 09:32:29 +0530
From:   Viresh Kumar <viresh.kumar@...aro.org>
To:     Jie Deng <jie.deng@...el.com>
Cc:     linux-i2c@...r.kernel.org,
        virtualization@...ts.linux-foundation.org,
        linux-kernel@...r.kernel.org, mst@...hat.com, wsa@...nel.org,
        jasowang@...hat.com, wsa+renesas@...g-engineering.com,
        andriy.shevchenko@...ux.intel.com, conghui.chen@...el.com,
        arnd@...db.de, kblaiech@...lanox.com,
        jarkko.nikula@...ux.intel.com, Sergey.Semin@...kalelectronics.ru,
        rppt@...nel.org, loic.poulain@...aro.org, tali.perry1@...il.com,
        u.kleine-koenig@...gutronix.de, bjorn.andersson@...aro.org,
        yu1.wang@...el.com, shuo.a.liu@...el.com, stefanha@...hat.com,
        pbonzini@...hat.com
Subject: Re: [PATCH v10] i2c: virtio: add a virtio i2c frontend driver

On 24-03-21, 12:00, Jie Deng wrote:
> 
> On 2021/3/24 11:52, Viresh Kumar wrote:
> > On 24-03-21, 08:53, Jie Deng wrote:
> > > On 2021/3/23 17:38, Viresh Kumar wrote:
> > > > On 23-03-21, 14:31, Viresh Kumar wrote:
> > > > > On 23-03-21, 22:19, Jie Deng wrote:
> > > > > > +static int virtio_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
> > > > > > +{
> > > > > > +	struct virtio_i2c *vi = i2c_get_adapdata(adap);
> > > > > > +	struct virtqueue *vq = vi->vq;
> > > > > > +	struct virtio_i2c_req *reqs;
> > > > > > +	unsigned long time_left;
> > > > > > +	int ret, nr;
> > > > > > +
> > > > > > +	reqs = kcalloc(num, sizeof(*reqs), GFP_KERNEL);
> > > > > > +	if (!reqs)
> > > > > > +		return -ENOMEM;
> > > > > > +
> > > > > > +	mutex_lock(&vi->lock);
> > > > > > +
> > > > > > +	ret = virtio_i2c_send_reqs(vq, reqs, msgs, num);
> > > > > > +	if (ret == 0)
> > > > > > +		goto err_unlock_free;
> > > > > > +
> > > > > > +	nr = ret;
> > > > > > +	reinit_completion(&vi->completion);
> > > > > I think I may have found a possible bug here. This reinit_completion() must
> > > > > happen before we call virtio_i2c_send_reqs(). It is certainly possible (surely
> > > > > in corner cases) that virtio_i2c_msg_done() may get called right after
> > > > > virtio_i2c_send_reqs() and before we were able to call reinit_completion(). And
> > > > > in that case we will never see the completion happen at all.
> > > > > 
> > > > > > +	virtqueue_kick(vq);
> > > > I may have misread this. Can the actually start before virtqueue_kick() is
> > > > called ?
> > I didn't write it properly here. I wanted to say,
> > 
> > "Can the _transfer_ actually start before virtqueue_kick() is called ?"
> 
> 
> It can't start until the virtqueue_kick() is called. Call virtqueue_kick
> then wait.

Great, thanks for the confirmation. The code is fine then.

-- 
viresh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ