From ebfa0f9df07bba7da7d09a3a06379effb3448e6d Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Sat, 19 Mar 2022 20:56:18 -0400 Subject: [PATCH] Fixes for 4.14 Signed-off-by: Sasha Levin --- ...atm-eni-add-check-for-dma_map_single.patch | 37 ++++++ ...fix-return-value-of-__setup-handlers.patch | 82 ++++++++++++ ...hrd_pimreg-in-dev_is_mac_header_xmit.patch | 36 ++++++ ...lab-out-of-bounds-access-in-packet_r.patch | 119 ++++++++++++++++++ queue-4.14/series | 4 + 5 files changed, 278 insertions(+) create mode 100644 queue-4.14/atm-eni-add-check-for-dma_map_single.patch create mode 100644 queue-4.14/efi-fix-return-value-of-__setup-handlers.patch create mode 100644 queue-4.14/net-handle-arphrd_pimreg-in-dev_is_mac_header_xmit.patch create mode 100644 queue-4.14/net-packet-fix-slab-out-of-bounds-access-in-packet_r.patch diff --git a/queue-4.14/atm-eni-add-check-for-dma_map_single.patch b/queue-4.14/atm-eni-add-check-for-dma_map_single.patch new file mode 100644 index 00000000000..e037ddfd872 --- /dev/null +++ b/queue-4.14/atm-eni-add-check-for-dma_map_single.patch @@ -0,0 +1,37 @@ +From 80ad70c1791651dc0a9092531ad95c0d492b9488 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 14 Mar 2022 09:34:48 +0800 +Subject: atm: eni: Add check for dma_map_single + +From: Jiasheng Jiang + +[ Upstream commit 0f74b29a4f53627376cf5a5fb7b0b3fa748a0b2b ] + +As the potential failure of the dma_map_single(), +it should be better to check it and return error +if fails. + +Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") +Signed-off-by: Jiasheng Jiang +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/atm/eni.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c +index ffe519663687..e88fad45241f 100644 +--- a/drivers/atm/eni.c ++++ b/drivers/atm/eni.c +@@ -1114,6 +1114,8 @@ DPRINTK("iovcnt = %d\n",skb_shinfo(skb)->nr_frags); + } + paddr = dma_map_single(&eni_dev->pci_dev->dev,skb->data,skb->len, + DMA_TO_DEVICE); ++ if (dma_mapping_error(&eni_dev->pci_dev->dev, paddr)) ++ return enq_next; + ENI_PRV_PADDR(skb) = paddr; + /* prepare DMA queue entries */ + j = 0; +-- +2.34.1 + diff --git a/queue-4.14/efi-fix-return-value-of-__setup-handlers.patch b/queue-4.14/efi-fix-return-value-of-__setup-handlers.patch new file mode 100644 index 00000000000..4b421a1433e --- /dev/null +++ b/queue-4.14/efi-fix-return-value-of-__setup-handlers.patch @@ -0,0 +1,82 @@ +From 821b584d9061717516f6bc9d4e338e84c43ae85a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 28 Feb 2022 20:18:51 -0800 +Subject: efi: fix return value of __setup handlers + +From: Randy Dunlap + +[ Upstream commit 9feaf8b387ee0ece9c1d7add308776b502a35d0c ] + +When "dump_apple_properties" is used on the kernel boot command line, +it causes an Unknown parameter message and the string is added to init's +argument strings: + + Unknown kernel command line parameters "dump_apple_properties + BOOT_IMAGE=/boot/bzImage-517rc6 efivar_ssdt=newcpu_ssdt", will be + passed to user space. + + Run /sbin/init as init process + with arguments: + /sbin/init + dump_apple_properties + with environment: + HOME=/ + TERM=linux + BOOT_IMAGE=/boot/bzImage-517rc6 + efivar_ssdt=newcpu_ssdt + +Similarly when "efivar_ssdt=somestring" is used, it is added to the +Unknown parameter message and to init's environment strings, polluting +them (see examples above). + +Change the return value of the __setup functions to 1 to indicate +that the __setup options have been handled. + +Fixes: 58c5475aba67 ("x86/efi: Retrieve and assign Apple device properties") +Fixes: 475fb4e8b2f4 ("efi / ACPI: load SSTDs from EFI variables") +Signed-off-by: Randy Dunlap +Reported-by: Igor Zhbanov +Link: lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru +Cc: Ard Biesheuvel +Cc: linux-efi@vger.kernel.org +Cc: Lukas Wunner +Cc: Octavian Purdila +Cc: "Rafael J. Wysocki" +Cc: Matt Fleming +Link: https://lore.kernel.org/r/20220301041851.12459-1-rdunlap@infradead.org +Signed-off-by: Ard Biesheuvel +Signed-off-by: Sasha Levin +--- + drivers/firmware/efi/apple-properties.c | 2 +- + drivers/firmware/efi/efi.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/firmware/efi/apple-properties.c b/drivers/firmware/efi/apple-properties.c +index 9f6bcf173b0e..aa42d228762f 100644 +--- a/drivers/firmware/efi/apple-properties.c ++++ b/drivers/firmware/efi/apple-properties.c +@@ -30,7 +30,7 @@ static bool dump_properties __initdata; + static int __init dump_properties_enable(char *arg) + { + dump_properties = true; +- return 0; ++ return 1; + } + + __setup("dump_apple_properties", dump_properties_enable); +diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c +index a3dc6cb7326a..24365601fbbf 100644 +--- a/drivers/firmware/efi/efi.c ++++ b/drivers/firmware/efi/efi.c +@@ -230,7 +230,7 @@ static int __init efivar_ssdt_setup(char *str) + memcpy(efivar_ssdt, str, strlen(str)); + else + pr_warn("efivar_ssdt: name too long: %s\n", str); +- return 0; ++ return 1; + } + __setup("efivar_ssdt=", efivar_ssdt_setup); + +-- +2.34.1 + diff --git a/queue-4.14/net-handle-arphrd_pimreg-in-dev_is_mac_header_xmit.patch b/queue-4.14/net-handle-arphrd_pimreg-in-dev_is_mac_header_xmit.patch new file mode 100644 index 00000000000..25084f196d2 --- /dev/null +++ b/queue-4.14/net-handle-arphrd_pimreg-in-dev_is_mac_header_xmit.patch @@ -0,0 +1,36 @@ +From be343b041bda1b0a201fa2a1a451e4316569af61 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 15 Mar 2022 10:20:08 +0100 +Subject: net: handle ARPHRD_PIMREG in dev_is_mac_header_xmit() + +From: Nicolas Dichtel + +[ Upstream commit 4ee06de7729d795773145692e246a06448b1eb7a ] + +This kind of interface doesn't have a mac header. This patch fixes +bpf_redirect() to a PIM interface. + +Fixes: 27b29f63058d ("bpf: add bpf_redirect() helper") +Signed-off-by: Nicolas Dichtel +Link: https://lore.kernel.org/r/20220315092008.31423-1-nicolas.dichtel@6wind.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + include/linux/if_arp.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/include/linux/if_arp.h b/include/linux/if_arp.h +index 4125f60ee53b..a9b09c7c2ce0 100644 +--- a/include/linux/if_arp.h ++++ b/include/linux/if_arp.h +@@ -55,6 +55,7 @@ static inline bool dev_is_mac_header_xmit(const struct net_device *dev) + case ARPHRD_VOID: + case ARPHRD_NONE: + case ARPHRD_RAWIP: ++ case ARPHRD_PIMREG: + return false; + default: + return true; +-- +2.34.1 + diff --git a/queue-4.14/net-packet-fix-slab-out-of-bounds-access-in-packet_r.patch b/queue-4.14/net-packet-fix-slab-out-of-bounds-access-in-packet_r.patch new file mode 100644 index 00000000000..dd90e91f6df --- /dev/null +++ b/queue-4.14/net-packet-fix-slab-out-of-bounds-access-in-packet_r.patch @@ -0,0 +1,119 @@ +From d93e531ce7015d2d15773a9125e4eaa661c5cf74 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 12 Mar 2022 15:29:58 -0800 +Subject: net/packet: fix slab-out-of-bounds access in packet_recvmsg() + +From: Eric Dumazet + +[ Upstream commit c700525fcc06b05adfea78039de02628af79e07a ] + +syzbot found that when an AF_PACKET socket is using PACKET_COPY_THRESH +and mmap operations, tpacket_rcv() is queueing skbs with +garbage in skb->cb[], triggering a too big copy [1] + +Presumably, users of af_packet using mmap() already gets correct +metadata from the mapped buffer, we can simply make sure +to clear 12 bytes that might be copied to user space later. + +BUG: KASAN: stack-out-of-bounds in memcpy include/linux/fortify-string.h:225 [inline] +BUG: KASAN: stack-out-of-bounds in packet_recvmsg+0x56c/0x1150 net/packet/af_packet.c:3489 +Write of size 165 at addr ffffc9000385fb78 by task syz-executor233/3631 + +CPU: 0 PID: 3631 Comm: syz-executor233 Not tainted 5.17.0-rc7-syzkaller-02396-g0b3660695e80 #0 +Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 +Call Trace: + + __dump_stack lib/dump_stack.c:88 [inline] + dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 + print_address_description.constprop.0.cold+0xf/0x336 mm/kasan/report.c:255 + __kasan_report mm/kasan/report.c:442 [inline] + kasan_report.cold+0x83/0xdf mm/kasan/report.c:459 + check_region_inline mm/kasan/generic.c:183 [inline] + kasan_check_range+0x13d/0x180 mm/kasan/generic.c:189 + memcpy+0x39/0x60 mm/kasan/shadow.c:66 + memcpy include/linux/fortify-string.h:225 [inline] + packet_recvmsg+0x56c/0x1150 net/packet/af_packet.c:3489 + sock_recvmsg_nosec net/socket.c:948 [inline] + sock_recvmsg net/socket.c:966 [inline] + sock_recvmsg net/socket.c:962 [inline] + ____sys_recvmsg+0x2c4/0x600 net/socket.c:2632 + ___sys_recvmsg+0x127/0x200 net/socket.c:2674 + __sys_recvmsg+0xe2/0x1a0 net/socket.c:2704 + do_syscall_x64 arch/x86/entry/common.c:50 [inline] + do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 + entry_SYSCALL_64_after_hwframe+0x44/0xae +RIP: 0033:0x7fdfd5954c29 +Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 41 15 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48 +RSP: 002b:00007ffcf8e71e48 EFLAGS: 00000246 ORIG_RAX: 000000000000002f +RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007fdfd5954c29 +RDX: 0000000000000000 RSI: 0000000020000500 RDI: 0000000000000005 +RBP: 0000000000000000 R08: 000000000000000d R09: 000000000000000d +R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffcf8e71e60 +R13: 00000000000f4240 R14: 000000000000c1ff R15: 00007ffcf8e71e54 + + +addr ffffc9000385fb78 is located in stack of task syz-executor233/3631 at offset 32 in frame: + ____sys_recvmsg+0x0/0x600 include/linux/uio.h:246 + +this frame has 1 object: + [32, 160) 'addr' + +Memory state around the buggy address: + ffffc9000385fa80: 00 04 f3 f3 f3 f3 f3 00 00 00 00 00 00 00 00 00 + ffffc9000385fb00: 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1 00 +>ffffc9000385fb80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f3 + ^ + ffffc9000385fc00: f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00 f1 + ffffc9000385fc80: f1 f1 f1 00 f2 f2 f2 00 f2 f2 f2 00 00 00 00 00 +================================================================== + +Fixes: 0fb375fb9b93 ("[AF_PACKET]: Allow for > 8 byte hardware addresses.") +Signed-off-by: Eric Dumazet +Reported-by: syzbot +Link: https://lore.kernel.org/r/20220312232958.3535620-1-eric.dumazet@gmail.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + net/packet/af_packet.c | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c +index 1381bfcb3cf0..92394595920c 100644 +--- a/net/packet/af_packet.c ++++ b/net/packet/af_packet.c +@@ -2285,8 +2285,11 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, + copy_skb = skb_get(skb); + skb_head = skb->data; + } +- if (copy_skb) ++ if (copy_skb) { ++ memset(&PACKET_SKB_CB(copy_skb)->sa.ll, 0, ++ sizeof(PACKET_SKB_CB(copy_skb)->sa.ll)); + skb_set_owner_r(copy_skb, sk); ++ } + } + snaplen = po->rx_ring.frame_size - macoff; + if ((int)snaplen < 0) { +@@ -3442,6 +3445,8 @@ static int packet_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, + sock_recv_ts_and_drops(msg, sk, skb); + + if (msg->msg_name) { ++ const size_t max_len = min(sizeof(skb->cb), ++ sizeof(struct sockaddr_storage)); + int copy_len; + + /* If the address length field is there to be filled +@@ -3464,6 +3469,10 @@ static int packet_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, + msg->msg_namelen = sizeof(struct sockaddr_ll); + } + } ++ if (WARN_ON_ONCE(copy_len > max_len)) { ++ copy_len = max_len; ++ msg->msg_namelen = copy_len; ++ } + memcpy(msg->msg_name, &PACKET_SKB_CB(skb)->sa, copy_len); + } + +-- +2.34.1 + diff --git a/queue-4.14/series b/queue-4.14/series index f4831d031fd..61e5c301fb3 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -12,3 +12,7 @@ tcp-make-tcp_read_sock-more-robust.patch sfc-extend-the-locking-on-mcdi-seqno.patch kselftest-vm-fix-tests-build-with-old-libc.patch fs-sysfs_emit-remove-page_size-alignment-check.patch +efi-fix-return-value-of-__setup-handlers.patch +net-packet-fix-slab-out-of-bounds-access-in-packet_r.patch +atm-eni-add-check-for-dma_map_single.patch +net-handle-arphrd_pimreg-in-dev_is_mac_header_xmit.patch -- 2.47.3