]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commit
USB: ldusb: fix ring-buffer locking
authorJohan Hovold <johan@kernel.org>
Tue, 22 Oct 2019 14:32:02 +0000 (16:32 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 12 Nov 2019 17:47:16 +0000 (18:47 +0100)
commit3dbbc5363baeb78ba83611ff1a06a21bbb07193f
tree895b53d6410b53c26c2ef6d1fef84f0c7eda903f
parenta543e256e2b24bb45251b826f31186f2a7215353
USB: ldusb: fix ring-buffer locking

BugLink: https://bugs.launchpad.net/bugs/1851550
commit d98ee2a19c3334e9343df3ce254b496f1fc428eb upstream.

The custom ring-buffer implementation was merged without any locking or
explicit memory barriers, but a spinlock was later added by commit
9d33efd9a791 ("USB: ldusb bugfix").

The lock did not cover the update of the tail index once the entry had
been processed, something which could lead to memory corruption on
weakly ordered architectures or due to compiler optimisations.

Specifically, a completion handler running on another CPU might observe
the incremented tail index and update the entry before ld_usb_read() is
done with it.

Fixes: 2824bd250f0b ("[PATCH] USB: add ldusb driver")
Fixes: 9d33efd9a791 ("USB: ldusb bugfix")
Cc: stable <stable@vger.kernel.org> # 2.6.13
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20191022143203.5260-2-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Connor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/usb/misc/ldusb.c