kmsan-handle-memory-sent-to-from-usb.patch removed from -mm tree
The quilt patch titled
Subject: kmsan: handle memory sent to/from USB
has been removed from the -mm tree. Its filename was
kmsan-handle-memory-sent-to-from-usb.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Alexander Potapenko <[email protected]>
Subject: kmsan: handle memory sent to/from USB
Date: Thu, 15 Sep 2022 17:03:57 +0200
Depending on the value of is_out kmsan_handle_urb() KMSAN either marks the data copied to the kernel from a USB device as initialized, or checks the data sent to the device for being initialized.
Signed-off-by Alexander Potapenko <[email protected]>
Cc Alexander Viro <[email protected]>
Cc Alexei Starovoitov <[email protected]>
Cc Andrey Konovalov <[email protected]>
Cc Andrey Konovalov <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Christoph Lameter <[email protected]>
Cc David Rientjes <[email protected]>
Cc Dmitry Vyukov <[email protected]>
Cc Eric Biggers <[email protected]>
Cc Eric Biggers <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Herbert Xu <[email protected]>
Cc Ilya Leoshkevich <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jens Axboe <[email protected]>
Cc Joonsoo Kim <[email protected]>
Cc Kees Cook <[email protected]>
Cc Marco Elver <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Cc Pekka Enberg <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Petr Mladek <[email protected]>
Cc Stephen Rothwell <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Vegard Nossum <[email protected]>
Cc Vlastimil Babka <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
drivers/usb/core/urb.c | 2 ++ include/linux/kmsan.h | 15 +++++++++++++++ mm/kmsan/hooks.c | 16 ++++++++++++++++ 3 files changed, 33 insertions(+)
drivers/usb/core/urb.c renamed from drivers/usb/core/urb.c~kmsan-handle-memory-sent-to-from-usb +2 -0
@@ -8,6 +8,7 @@#include <linux/bitops.h> #include <linux/slab.h> #include <linux/log2.h> +#include <linux/kmsan.h> #include <linux/usb.h> #include <linux/wait.h> #include <linux/usb/hcd.h>
@@ -426,6 +427,7 @@ int usb_submit_urb(struct urb *urb, gfp_URB_SETUP_MAP_SINGLE |URB_SETUP_MAP_LOCAL | URB_DMA_SG_COMBINED); urb->transfer_flags |= (is_out ?URB_DIR_OUT :URB_DIR_IN ); +kmsan_handle_urb (urb, is_out);if (xfertype !=USB_ENDPOINT_XFER_CONTROL && dev->state <USB_STATE_CONFIGURED )
include/linux/kmsan.h renamed from include/linux/kmsan.h~kmsan-handle-memory-sent-to-from-usb +15 -0
@@ -18,6 +18,7 @@ struct page;struct kmem_cache ;struct task_struct ;struct scatterlist ; +struct urb ;#ifdef CONFIG_KMSAN
@@ -203,6 +204,16 @@ void kmsan_handle_dma(struct page *page,void kmsan_handle_dma_sg (struct scatterlist *sg,int nents,enum dma_data_direction dir); +/** +* kmsan_handle_urb() - Handle a USB data transfer. +* @urb: struct urb pointer. +* @is_out: data transfer direction (true means output to hardware). +* +* If @is_out is true, KMSAN checks the transfer buffer of @urb. Otherwise, +* KMSAN initializes the transfer buffer. +*/ +void kmsan_handle_urb (const struct urb *urb,bool is_out); +#else static inline void kmsan_init_shadow (void )
@@ -295,6 +306,10 @@ static inline void kmsan_handle_dma_sg(s { } +static inline void kmsan_handle_urb (const struct urb *urb,bool is_out) +{ +} +#endif #endif /* _LINUX_KMSAN_H */
mm/kmsan/hooks.c renamed from mm/kmsan/hooks.c~kmsan-handle-memory-sent-to-from-usb +16 -0
@@ -18,6 +18,7 @@#include <linux/scatterlist.h> #include <linux/slab.h> #include <linux/uaccess.h> +#include <linux/usb.h> #include "../internal.h" #include "../slab.h"
@@ -245,6 +246,21 @@ void kmsan_copy_to_user(void __user *to, }EXPORT_SYMBOL (kmsan_copy_to_user); +/* Helper function to check an URB. */ +void kmsan_handle_urb (const struct urb *urb,bool is_out) +{ +if (!urb) +return ; +if (is_out) +kmsan_internal_check_memory (urb->transfer_buffer, + urb->transfer_buffer_length, +/*user_addr*/ 0 ,REASON_SUBMIT_URB ); +else +kmsan_internal_unpoison_memory (urb->transfer_buffer, + urb->transfer_buffer_length, +/*checked*/ false); +} +static void kmsan_handle_dma_page (const void *addr,size_t size,enum dma_data_direction dir) {
_
Patches currently in -mm which might be from [email protected] are