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: <20150309084101.GC22567@redhat.com>
Date:	Mon, 9 Mar 2015 09:41:01 +0100
From:	"Michael S. Tsirkin" <mst@...hat.com>
To:	linux-kernel@...r.kernel.org
Cc:	virtualization@...ts.linux-foundation.org,
	Rusty Russell <rusty@...tcorp.com.au>, kvm@...r.kernel.org,
	qemu-devel@...gnu.org, Ohad Ben-Cohen <ohad@...ery.com>
Subject: Re: [PATCH] virtio_rpmsg: set DRIVER_OK before using device

On Sat, Mar 07, 2015 at 08:06:56PM +0100, Michael S. Tsirkin wrote:
> virtio spec requires that all drivers set DRIVER_OK
> before using devices. While rpmsg isn't yet
> included in the virtio 1 spec, previous spec versions
> also required this.
> 
> virtio rpmsg violates this rule: is calls kick
> before setting DRIVER_OK.
> 
> The fix isn't trivial since simply calling virtio_device_ready earlier
> would mean we might get an interrupt in parallel with adding buffers.
> 
> Instead, split kick out to prepare+notify calls.  prepare before
> virtio_device_ready - when we know we won't get interrupts. notify right
> afterwards.
> 
> Signed-off-by: Michael S. Tsirkin <mst@...hat.com>
> ---

Ohad, can you review and ack pls?

> Note: compile-tested only.
> 
>  drivers/rpmsg/virtio_rpmsg_bus.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
> index 92f6af6..73354ee 100644
> --- a/drivers/rpmsg/virtio_rpmsg_bus.c
> +++ b/drivers/rpmsg/virtio_rpmsg_bus.c
> @@ -951,6 +951,7 @@ static int rpmsg_probe(struct virtio_device *vdev)
>  	void *bufs_va;
>  	int err = 0, i;
>  	size_t total_buf_space;
> +	bool notify;
>  
>  	vrp = kzalloc(sizeof(*vrp), GFP_KERNEL);
>  	if (!vrp)
> @@ -1030,8 +1031,22 @@ static int rpmsg_probe(struct virtio_device *vdev)
>  		}
>  	}
>  
> +	/*
> +	 * Prepare to kick but don't notify yet - we can't do this before
> +	 * device is ready.
> +	 */
> +	notify = virtqueue_kick_prepare(vrp->rvq);
> +
> +	/* From this point on, we can notify and get callbacks. */
> +	virtio_device_ready(vdev);
> +
>  	/* tell the remote processor it can start sending messages */
> -	virtqueue_kick(vrp->rvq);
> +	/*
> +	 * this might be concurrent with callbacks, but we are only
> +	 * doing notify, not a full kick here, so that's ok.
> +	 */
> +	if (notify)
> +		virtqueue_notify(vrp->rvq);
>  
>  	dev_info(&vdev->dev, "rpmsg host is online\n");
>  
> -- 
> MST
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ