]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.14-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 9 Sep 2023 21:54:20 +0000 (22:54 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 9 Sep 2023 21:54:20 +0000 (22:54 +0100)
added patches:
dccp-fix-out-of-bounds-access-in-dccp-error-handler.patch
net-handle-arphrd_ppp-in-dev_is_mac_header_xmit.patch
pstore-ram-check-start-of-empty-przs-during-init.patch
x.509-if-signature-is-unsupported-skip-validation.patch

queue-4.14/dccp-fix-out-of-bounds-access-in-dccp-error-handler.patch [new file with mode: 0644]
queue-4.14/net-handle-arphrd_ppp-in-dev_is_mac_header_xmit.patch [new file with mode: 0644]
queue-4.14/pstore-ram-check-start-of-empty-przs-during-init.patch [new file with mode: 0644]
queue-4.14/series
queue-4.14/x.509-if-signature-is-unsupported-skip-validation.patch [new file with mode: 0644]

diff --git a/queue-4.14/dccp-fix-out-of-bounds-access-in-dccp-error-handler.patch b/queue-4.14/dccp-fix-out-of-bounds-access-in-dccp-error-handler.patch
new file mode 100644 (file)
index 0000000..ccf2a80
--- /dev/null
@@ -0,0 +1,84 @@
+From 977ad86c2a1bcaf58f01ab98df5cc145083c489c Mon Sep 17 00:00:00 2001
+From: Jann Horn <jannh@google.com>
+Date: Fri, 25 Aug 2023 15:32:41 +0200
+Subject: dccp: Fix out of bounds access in DCCP error handler
+
+From: Jann Horn <jannh@google.com>
+
+commit 977ad86c2a1bcaf58f01ab98df5cc145083c489c upstream.
+
+There was a previous attempt to fix an out-of-bounds access in the DCCP
+error handlers, but that fix assumed that the error handlers only want
+to access the first 8 bytes of the DCCP header. Actually, they also look
+at the DCCP sequence number, which is stored beyond 8 bytes, so an
+explicit pskb_may_pull() is required.
+
+Fixes: 6706a97fec96 ("dccp: fix out of bound access in dccp_v4_err()")
+Fixes: 1aa9d1a0e7ee ("ipv6: dccp: fix out of bound access in dccp_v6_err()")
+Cc: stable@vger.kernel.org
+Signed-off-by: Jann Horn <jannh@google.com>
+Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/dccp/ipv4.c |   13 +++++++++----
+ net/dccp/ipv6.c |   15 ++++++++++-----
+ 2 files changed, 19 insertions(+), 9 deletions(-)
+
+--- a/net/dccp/ipv4.c
++++ b/net/dccp/ipv4.c
+@@ -247,12 +247,17 @@ static void dccp_v4_err(struct sk_buff *
+       int err;
+       struct net *net = dev_net(skb->dev);
+-      /* Only need dccph_dport & dccph_sport which are the first
+-       * 4 bytes in dccp header.
++      /* For the first __dccp_basic_hdr_len() check, we only need dh->dccph_x,
++       * which is in byte 7 of the dccp header.
+        * Our caller (icmp_socket_deliver()) already pulled 8 bytes for us.
++       *
++       * Later on, we want to access the sequence number fields, which are
++       * beyond 8 bytes, so we have to pskb_may_pull() ourselves.
+        */
+-      BUILD_BUG_ON(offsetofend(struct dccp_hdr, dccph_sport) > 8);
+-      BUILD_BUG_ON(offsetofend(struct dccp_hdr, dccph_dport) > 8);
++      dh = (struct dccp_hdr *)(skb->data + offset);
++      if (!pskb_may_pull(skb, offset + __dccp_basic_hdr_len(dh)))
++              return -EINVAL;
++      iph = (struct iphdr *)skb->data;
+       dh = (struct dccp_hdr *)(skb->data + offset);
+       sk = __inet_lookup_established(net, &dccp_hashinfo,
+--- a/net/dccp/ipv6.c
++++ b/net/dccp/ipv6.c
+@@ -71,7 +71,7 @@ static inline __u64 dccp_v6_init_sequenc
+ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
+                       u8 type, u8 code, int offset, __be32 info)
+ {
+-      const struct ipv6hdr *hdr = (const struct ipv6hdr *)skb->data;
++      const struct ipv6hdr *hdr;
+       const struct dccp_hdr *dh;
+       struct dccp_sock *dp;
+       struct ipv6_pinfo *np;
+@@ -80,12 +80,17 @@ static void dccp_v6_err(struct sk_buff *
+       __u64 seq;
+       struct net *net = dev_net(skb->dev);
+-      /* Only need dccph_dport & dccph_sport which are the first
+-       * 4 bytes in dccp header.
++      /* For the first __dccp_basic_hdr_len() check, we only need dh->dccph_x,
++       * which is in byte 7 of the dccp header.
+        * Our caller (icmpv6_notify()) already pulled 8 bytes for us.
++       *
++       * Later on, we want to access the sequence number fields, which are
++       * beyond 8 bytes, so we have to pskb_may_pull() ourselves.
+        */
+-      BUILD_BUG_ON(offsetofend(struct dccp_hdr, dccph_sport) > 8);
+-      BUILD_BUG_ON(offsetofend(struct dccp_hdr, dccph_dport) > 8);
++      dh = (struct dccp_hdr *)(skb->data + offset);
++      if (!pskb_may_pull(skb, offset + __dccp_basic_hdr_len(dh)))
++              return -EINVAL;
++      hdr = (const struct ipv6hdr *)skb->data;
+       dh = (struct dccp_hdr *)(skb->data + offset);
+       sk = __inet6_lookup_established(net, &dccp_hashinfo,
diff --git a/queue-4.14/net-handle-arphrd_ppp-in-dev_is_mac_header_xmit.patch b/queue-4.14/net-handle-arphrd_ppp-in-dev_is_mac_header_xmit.patch
new file mode 100644 (file)
index 0000000..5aa3d58
--- /dev/null
@@ -0,0 +1,38 @@
+From a4f39c9f14a634e4cd35fcd338c239d11fcc73fc Mon Sep 17 00:00:00 2001
+From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
+Date: Wed, 23 Aug 2023 15:41:02 +0200
+Subject: net: handle ARPHRD_PPP in dev_is_mac_header_xmit()
+
+From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
+
+commit a4f39c9f14a634e4cd35fcd338c239d11fcc73fc upstream.
+
+The goal is to support a bpf_redirect() from an ethernet device (ingress)
+to a ppp device (egress).
+The l2 header is added automatically by the ppp driver, thus the ethernet
+header should be removed.
+
+CC: stable@vger.kernel.org
+Fixes: 27b29f63058d ("bpf: add bpf_redirect() helper")
+Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
+Tested-by: Siwar Zitouni <siwar.zitouni@6wind.com>
+Reviewed-by: Guillaume Nault <gnault@redhat.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ include/linux/if_arp.h |    4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/include/linux/if_arp.h
++++ b/include/linux/if_arp.h
+@@ -56,6 +56,10 @@ static inline bool dev_is_mac_header_xmi
+       case ARPHRD_NONE:
+       case ARPHRD_RAWIP:
+       case ARPHRD_PIMREG:
++      /* PPP adds its l2 header automatically in ppp_start_xmit().
++       * This makes it look like an l3 device to __bpf_redirect() and tcf_mirred_init().
++       */
++      case ARPHRD_PPP:
+               return false;
+       default:
+               return true;
diff --git a/queue-4.14/pstore-ram-check-start-of-empty-przs-during-init.patch b/queue-4.14/pstore-ram-check-start-of-empty-przs-during-init.patch
new file mode 100644 (file)
index 0000000..e76efab
--- /dev/null
@@ -0,0 +1,60 @@
+From fe8c3623ab06603eb760444a032d426542212021 Mon Sep 17 00:00:00 2001
+From: Enlin Mu <enlin.mu@unisoc.com>
+Date: Tue, 1 Aug 2023 14:04:32 +0800
+Subject: pstore/ram: Check start of empty przs during init
+
+From: Enlin Mu <enlin.mu@unisoc.com>
+
+commit fe8c3623ab06603eb760444a032d426542212021 upstream.
+
+After commit 30696378f68a ("pstore/ram: Do not treat empty buffers as
+valid"), initialization would assume a prz was valid after seeing that
+the buffer_size is zero (regardless of the buffer start position). This
+unchecked start value means it could be outside the bounds of the buffer,
+leading to future access panics when written to:
+
+ sysdump_panic_event+0x3b4/0x5b8
+ atomic_notifier_call_chain+0x54/0x90
+ panic+0x1c8/0x42c
+ die+0x29c/0x2a8
+ die_kernel_fault+0x68/0x78
+ __do_kernel_fault+0x1c4/0x1e0
+ do_bad_area+0x40/0x100
+ do_translation_fault+0x68/0x80
+ do_mem_abort+0x68/0xf8
+ el1_da+0x1c/0xc0
+ __raw_writeb+0x38/0x174
+ __memcpy_toio+0x40/0xac
+ persistent_ram_update+0x44/0x12c
+ persistent_ram_write+0x1a8/0x1b8
+ ramoops_pstore_write+0x198/0x1e8
+ pstore_console_write+0x94/0xe0
+ ...
+
+To avoid this, also check if the prz start is 0 during the initialization
+phase. If not, the next prz sanity check case will discover it (start >
+size) and zap the buffer back to a sane state.
+
+Fixes: 30696378f68a ("pstore/ram: Do not treat empty buffers as valid")
+Cc: Yunlong Xing <yunlong.xing@unisoc.com>
+Cc: stable@vger.kernel.org
+Signed-off-by: Enlin Mu <enlin.mu@unisoc.com>
+Link: https://lore.kernel.org/r/20230801060432.1307717-1-yunlong.xing@unisoc.com
+[kees: update commit log with backtrace and clarifications]
+Signed-off-by: Kees Cook <keescook@chromium.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/pstore/ram_core.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/fs/pstore/ram_core.c
++++ b/fs/pstore/ram_core.c
+@@ -492,7 +492,7 @@ static int persistent_ram_post_init(stru
+       sig ^= PERSISTENT_RAM_SIG;
+       if (prz->buffer->sig == sig) {
+-              if (buffer_size(prz) == 0) {
++              if (buffer_size(prz) == 0 && buffer_start(prz) == 0) {
+                       pr_debug("found existing empty buffer\n");
+                       return 0;
+               }
index b57976cd25ab5368a0aa876c21c04c685c6f0e36..9c8e831f4d0631e34e0c1152828291607656d50f 100644 (file)
@@ -113,3 +113,7 @@ ntb-fix-calculation-ntb_transport_tx_free_entry.patch
 revert-pci-mark-nvidia-t4-gpus-to-avoid-bus-reset.patch
 procfs-block-chmod-on-proc-thread-self-comm.patch
 parisc-fix-proc-cpuinfo-output-for-lscpu.patch
+dccp-fix-out-of-bounds-access-in-dccp-error-handler.patch
+x.509-if-signature-is-unsupported-skip-validation.patch
+net-handle-arphrd_ppp-in-dev_is_mac_header_xmit.patch
+pstore-ram-check-start-of-empty-przs-during-init.patch
diff --git a/queue-4.14/x.509-if-signature-is-unsupported-skip-validation.patch b/queue-4.14/x.509-if-signature-is-unsupported-skip-validation.patch
new file mode 100644 (file)
index 0000000..4713892
--- /dev/null
@@ -0,0 +1,45 @@
+From ef5b52a631f8c18353e80ccab8408b963305510c Mon Sep 17 00:00:00 2001
+From: Thore Sommer <public@thson.de>
+Date: Tue, 15 Aug 2023 14:29:42 +0300
+Subject: X.509: if signature is unsupported skip validation
+
+From: Thore Sommer <public@thson.de>
+
+commit ef5b52a631f8c18353e80ccab8408b963305510c upstream.
+
+When the hash algorithm for the signature is not available the digest size
+is 0 and the signature in the certificate is marked as unsupported.
+
+When validating a self-signed certificate, this needs to be checked,
+because otherwise trying to validate the signature will fail with an
+warning:
+
+Loading compiled-in X.509 certificates
+WARNING: CPU: 0 PID: 1 at crypto/rsa-pkcs1pad.c:537 \
+pkcs1pad_verify+0x46/0x12c
+...
+Problem loading in-kernel X.509 certificate (-22)
+
+Signed-off-by: Thore Sommer <public@thson.de>
+Cc: stable@vger.kernel.org # v4.7+
+Fixes: 6c2dc5ae4ab7 ("X.509: Extract signature digest and make self-signed cert checks earlier")
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ crypto/asymmetric_keys/x509_public_key.c |    5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- a/crypto/asymmetric_keys/x509_public_key.c
++++ b/crypto/asymmetric_keys/x509_public_key.c
+@@ -138,6 +138,11 @@ int x509_check_for_self_signed(struct x5
+       if (strcmp(cert->pub->pkey_algo, cert->sig->pkey_algo) != 0)
+               goto out;
++      if (cert->unsupported_sig) {
++              ret = 0;
++              goto out;
++      }
++
+       ret = public_key_verify_signature(cert->pub, cert->sig);
+       if (ret < 0) {
+               if (ret == -ENOPKG) {