]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.1-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 22 Apr 2025 08:53:03 +0000 (10:53 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 22 Apr 2025 08:53:03 +0000 (10:53 +0200)
added patches:
drm-amd-display-stop-amdgpu_dm-initialize-when-link-nums-greater-than-max_links.patch
landlock-add-the-errata-interface.patch
revert-loongarch-bpf-fix-off-by-one-error-in-build_prologue.patch

queue-6.1/drm-amd-display-stop-amdgpu_dm-initialize-when-link-nums-greater-than-max_links.patch [new file with mode: 0644]
queue-6.1/landlock-add-the-errata-interface.patch [new file with mode: 0644]
queue-6.1/revert-loongarch-bpf-fix-off-by-one-error-in-build_prologue.patch [new file with mode: 0644]
queue-6.1/series

diff --git a/queue-6.1/drm-amd-display-stop-amdgpu_dm-initialize-when-link-nums-greater-than-max_links.patch b/queue-6.1/drm-amd-display-stop-amdgpu_dm-initialize-when-link-nums-greater-than-max_links.patch
new file mode 100644 (file)
index 0000000..aa48614
--- /dev/null
@@ -0,0 +1,60 @@
+From cf8b16857db702ceb8d52f9219a4613363e2b1cf Mon Sep 17 00:00:00 2001
+From: Hersen Wu <hersenxs.wu@amd.com>
+Date: Wed, 24 Apr 2024 16:15:15 -0400
+Subject: drm/amd/display: Stop amdgpu_dm initialize when link nums greater than max_links
+
+From: Hersen Wu <hersenxs.wu@amd.com>
+
+commit cf8b16857db702ceb8d52f9219a4613363e2b1cf upstream.
+
+[Why]
+Coverity report OVERRUN warning. There are
+only max_links elements within dc->links. link
+count could up to AMDGPU_DM_MAX_DISPLAY_INDEX 31.
+
+[How]
+Make sure link count less than max_links.
+
+Reviewed-by: Harry Wentland <harry.wentland@amd.com>
+Acked-by: Tom Chung <chiahsuan.chung@amd.com>
+Signed-off-by: Hersen Wu <hersenxs.wu@amd.com>
+Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+[Minor conflict resolved due to code context change. And the macro MAX_LINKS
+ is introduced by Commit 60df5628144b ("drm/amd/display: handle invalid
+ connector indices") after 6.10. So here we still use the original array
+ length MAX_PIPES * 2]
+Signed-off-by: Jianqi Ren <jianqi.ren.cn@windriver.com>
+Signed-off-by: He Zhe <zhe.he@windriver.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |   14 +++++++-------
+ 1 file changed, 7 insertions(+), 7 deletions(-)
+
+--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+@@ -4499,17 +4499,17 @@ static int amdgpu_dm_initialize_drm_devi
+               }
+       }
++      if (link_cnt > (MAX_PIPES * 2)) {
++              DRM_ERROR(
++                      "KMS: Cannot support more than %d display indexes\n",
++                              MAX_PIPES * 2);
++              goto fail;
++      }
++
+       /* loops over all connectors on the board */
+       for (i = 0; i < link_cnt; i++) {
+               struct dc_link *link = NULL;
+-              if (i > AMDGPU_DM_MAX_DISPLAY_INDEX) {
+-                      DRM_ERROR(
+-                              "KMS: Cannot support more than %d display indexes\n",
+-                                      AMDGPU_DM_MAX_DISPLAY_INDEX);
+-                      continue;
+-              }
+-
+               aconnector = kzalloc(sizeof(*aconnector), GFP_KERNEL);
+               if (!aconnector)
+                       goto fail;
diff --git a/queue-6.1/landlock-add-the-errata-interface.patch b/queue-6.1/landlock-add-the-errata-interface.patch
new file mode 100644 (file)
index 0000000..7e379f2
--- /dev/null
@@ -0,0 +1,336 @@
+From 15383a0d63dbcd63dc7e8d9ec1bf3a0f7ebf64ac Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= <mic@digikod.net>
+Date: Tue, 18 Mar 2025 17:14:37 +0100
+Subject: landlock: Add the errata interface
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Mickaël Salaün <mic@digikod.net>
+
+commit 15383a0d63dbcd63dc7e8d9ec1bf3a0f7ebf64ac upstream.
+
+Some fixes may require user space to check if they are applied on the
+running kernel before using a specific feature.  For instance, this
+applies when a restriction was previously too restrictive and is now
+getting relaxed (e.g. for compatibility reasons).  However, non-visible
+changes for legitimate use (e.g. security fixes) do not require an
+erratum.
+
+Because fixes are backported down to a specific Landlock ABI, we need a
+way to avoid cherry-pick conflicts.  The solution is to only update a
+file related to the lower ABI impacted by this issue.  All the ABI files
+are then used to create a bitmask of fixes.
+
+The new errata interface is similar to the one used to get the supported
+Landlock ABI version, but it returns a bitmask instead because the order
+of fixes may not match the order of versions, and not all fixes may
+apply to all versions.
+
+The actual errata will come with dedicated commits.  The description is
+not actually used in the code but serves as documentation.
+
+Create the landlock_abi_version symbol and use its value to check errata
+consistency.
+
+Update test_base's create_ruleset_checks_ordering tests and add errata
+tests.
+
+This commit is backportable down to the first version of Landlock.
+
+Fixes: 3532b0b4352c ("landlock: Enable user space to infer supported features")
+Cc: Günther Noack <gnoack@google.com>
+Cc: stable@vger.kernel.org
+Link: https://lore.kernel.org/r/20250318161443.279194-3-mic@digikod.net
+Signed-off-by: Mickaël Salaün <mic@digikod.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ include/uapi/linux/landlock.h                |    2 
+ security/landlock/errata.h                   |   87 +++++++++++++++++++++++++++
+ security/landlock/setup.c                    |   30 +++++++++
+ security/landlock/setup.h                    |    3 
+ security/landlock/syscalls.c                 |   22 +++++-
+ tools/testing/selftests/landlock/base_test.c |   46 +++++++++++++-
+ 6 files changed, 185 insertions(+), 5 deletions(-)
+ create mode 100644 security/landlock/errata.h
+
+--- a/include/uapi/linux/landlock.h
++++ b/include/uapi/linux/landlock.h
+@@ -38,9 +38,11 @@ struct landlock_ruleset_attr {
+  *
+  * - %LANDLOCK_CREATE_RULESET_VERSION: Get the highest supported Landlock ABI
+  *   version.
++ * - %LANDLOCK_CREATE_RULESET_ERRATA: Get a bitmask of fixed issues.
+  */
+ /* clang-format off */
+ #define LANDLOCK_CREATE_RULESET_VERSION                       (1U << 0)
++#define LANDLOCK_CREATE_RULESET_ERRATA                        (1U << 1)
+ /* clang-format on */
+ /**
+--- /dev/null
++++ b/security/landlock/errata.h
+@@ -0,0 +1,87 @@
++/* SPDX-License-Identifier: GPL-2.0-only */
++/*
++ * Landlock - Errata information
++ *
++ * Copyright Â© 2025 Microsoft Corporation
++ */
++
++#ifndef _SECURITY_LANDLOCK_ERRATA_H
++#define _SECURITY_LANDLOCK_ERRATA_H
++
++#include <linux/init.h>
++
++struct landlock_erratum {
++      const int abi;
++      const u8 number;
++};
++
++/* clang-format off */
++#define LANDLOCK_ERRATUM(NUMBER) \
++      { \
++              .abi = LANDLOCK_ERRATA_ABI, \
++              .number = NUMBER, \
++      },
++/* clang-format on */
++
++/*
++ * Some fixes may require user space to check if they are applied on the running
++ * kernel before using a specific feature.  For instance, this applies when a
++ * restriction was previously too restrictive and is now getting relaxed (for
++ * compatibility or semantic reasons).  However, non-visible changes for
++ * legitimate use (e.g. security fixes) do not require an erratum.
++ */
++static const struct landlock_erratum landlock_errata_init[] __initconst = {
++
++/*
++ * Only Sparse may not implement __has_include.  If a compiler does not
++ * implement __has_include, a warning will be printed at boot time (see
++ * setup.c).
++ */
++#ifdef __has_include
++
++#define LANDLOCK_ERRATA_ABI 1
++#if __has_include("errata/abi-1.h")
++#include "errata/abi-1.h"
++#endif
++#undef LANDLOCK_ERRATA_ABI
++
++#define LANDLOCK_ERRATA_ABI 2
++#if __has_include("errata/abi-2.h")
++#include "errata/abi-2.h"
++#endif
++#undef LANDLOCK_ERRATA_ABI
++
++#define LANDLOCK_ERRATA_ABI 3
++#if __has_include("errata/abi-3.h")
++#include "errata/abi-3.h"
++#endif
++#undef LANDLOCK_ERRATA_ABI
++
++#define LANDLOCK_ERRATA_ABI 4
++#if __has_include("errata/abi-4.h")
++#include "errata/abi-4.h"
++#endif
++#undef LANDLOCK_ERRATA_ABI
++
++/*
++ * For each new erratum, we need to include all the ABI files up to the impacted
++ * ABI to make all potential future intermediate errata easy to backport.
++ *
++ * If such change involves more than one ABI addition, then it must be in a
++ * dedicated commit with the same Fixes tag as used for the actual fix.
++ *
++ * Each commit creating a new security/landlock/errata/abi-*.h file must have a
++ * Depends-on tag to reference the commit that previously added the line to
++ * include this new file, except if the original Fixes tag is enough.
++ *
++ * Each erratum must be documented in its related ABI file, and a dedicated
++ * commit must update Documentation/userspace-api/landlock.rst to include this
++ * erratum.  This commit will not be backported.
++ */
++
++#endif
++
++      {}
++};
++
++#endif /* _SECURITY_LANDLOCK_ERRATA_H */
+--- a/security/landlock/setup.c
++++ b/security/landlock/setup.c
+@@ -6,11 +6,13 @@
+  * Copyright © 2018-2020 ANSSI
+  */
++#include <linux/bits.h>
+ #include <linux/init.h>
+ #include <linux/lsm_hooks.h>
+ #include "common.h"
+ #include "cred.h"
++#include "errata.h"
+ #include "fs.h"
+ #include "ptrace.h"
+ #include "setup.h"
+@@ -23,8 +25,36 @@ struct lsm_blob_sizes landlock_blob_size
+       .lbs_superblock = sizeof(struct landlock_superblock_security),
+ };
++int landlock_errata __ro_after_init;
++
++static void __init compute_errata(void)
++{
++      size_t i;
++
++#ifndef __has_include
++      /*
++       * This is a safeguard to make sure the compiler implements
++       * __has_include (see errata.h).
++       */
++      WARN_ON_ONCE(1);
++      return;
++#endif
++
++      for (i = 0; landlock_errata_init[i].number; i++) {
++              const int prev_errata = landlock_errata;
++
++              if (WARN_ON_ONCE(landlock_errata_init[i].abi >
++                               landlock_abi_version))
++                      continue;
++
++              landlock_errata |= BIT(landlock_errata_init[i].number - 1);
++              WARN_ON_ONCE(prev_errata == landlock_errata);
++      }
++}
++
+ static int __init landlock_init(void)
+ {
++      compute_errata();
+       landlock_add_cred_hooks();
+       landlock_add_ptrace_hooks();
+       landlock_add_fs_hooks();
+--- a/security/landlock/setup.h
++++ b/security/landlock/setup.h
+@@ -11,7 +11,10 @@
+ #include <linux/lsm_hooks.h>
++extern const int landlock_abi_version;
++
+ extern bool landlock_initialized;
++extern int landlock_errata;
+ extern struct lsm_blob_sizes landlock_blob_sizes;
+--- a/security/landlock/syscalls.c
++++ b/security/landlock/syscalls.c
+@@ -150,7 +150,9 @@ static const struct file_operations rule
+  *        the new ruleset.
+  * @size: Size of the pointed &struct landlock_ruleset_attr (needed for
+  *        backward and forward compatibility).
+- * @flags: Supported value: %LANDLOCK_CREATE_RULESET_VERSION.
++ * @flags: Supported value:
++ *         - %LANDLOCK_CREATE_RULESET_VERSION
++ *         - %LANDLOCK_CREATE_RULESET_ERRATA
+  *
+  * This system call enables to create a new Landlock ruleset, and returns the
+  * related file descriptor on success.
+@@ -159,6 +161,10 @@ static const struct file_operations rule
+  * 0, then the returned value is the highest supported Landlock ABI version
+  * (starting at 1).
+  *
++ * If @flags is %LANDLOCK_CREATE_RULESET_ERRATA and @attr is NULL and @size is
++ * 0, then the returned value is a bitmask of fixed issues for the current
++ * Landlock ABI version.
++ *
+  * Possible returned errors are:
+  *
+  * - %EOPNOTSUPP: Landlock is supported by the kernel but disabled at boot time;
+@@ -181,9 +187,15 @@ SYSCALL_DEFINE3(landlock_create_ruleset,
+               return -EOPNOTSUPP;
+       if (flags) {
+-              if ((flags == LANDLOCK_CREATE_RULESET_VERSION) && !attr &&
+-                  !size)
+-                      return LANDLOCK_ABI_VERSION;
++              if (attr || size)
++                      return -EINVAL;
++
++              if (flags == LANDLOCK_CREATE_RULESET_VERSION)
++                      return landlock_abi_version;
++
++              if (flags == LANDLOCK_CREATE_RULESET_ERRATA)
++                      return landlock_errata;
++
+               return -EINVAL;
+       }
+@@ -213,6 +225,8 @@ SYSCALL_DEFINE3(landlock_create_ruleset,
+       return ruleset_fd;
+ }
++const int landlock_abi_version = LANDLOCK_ABI_VERSION;
++
+ /*
+  * Returns an owned ruleset from a FD. It is thus needed to call
+  * landlock_put_ruleset() on the return value.
+--- a/tools/testing/selftests/landlock/base_test.c
++++ b/tools/testing/selftests/landlock/base_test.c
+@@ -98,10 +98,54 @@ TEST(abi_version)
+       ASSERT_EQ(EINVAL, errno);
+ }
++/*
++ * Old source trees might not have the set of Kselftest fixes related to kernel
++ * UAPI headers.
++ */
++#ifndef LANDLOCK_CREATE_RULESET_ERRATA
++#define LANDLOCK_CREATE_RULESET_ERRATA (1U << 1)
++#endif
++
++TEST(errata)
++{
++      const struct landlock_ruleset_attr ruleset_attr = {
++              .handled_access_fs = LANDLOCK_ACCESS_FS_READ_FILE,
++      };
++      int errata;
++
++      errata = landlock_create_ruleset(NULL, 0,
++                                       LANDLOCK_CREATE_RULESET_ERRATA);
++      /* The errata bitmask will not be backported to tests. */
++      ASSERT_LE(0, errata);
++      TH_LOG("errata: 0x%x", errata);
++
++      ASSERT_EQ(-1, landlock_create_ruleset(&ruleset_attr, 0,
++                                            LANDLOCK_CREATE_RULESET_ERRATA));
++      ASSERT_EQ(EINVAL, errno);
++
++      ASSERT_EQ(-1, landlock_create_ruleset(NULL, sizeof(ruleset_attr),
++                                            LANDLOCK_CREATE_RULESET_ERRATA));
++      ASSERT_EQ(EINVAL, errno);
++
++      ASSERT_EQ(-1,
++                landlock_create_ruleset(&ruleset_attr, sizeof(ruleset_attr),
++                                        LANDLOCK_CREATE_RULESET_ERRATA));
++      ASSERT_EQ(EINVAL, errno);
++
++      ASSERT_EQ(-1, landlock_create_ruleset(
++                            NULL, 0,
++                            LANDLOCK_CREATE_RULESET_VERSION |
++                                    LANDLOCK_CREATE_RULESET_ERRATA));
++      ASSERT_EQ(-1, landlock_create_ruleset(NULL, 0,
++                                            LANDLOCK_CREATE_RULESET_ERRATA |
++                                                    1 << 31));
++      ASSERT_EQ(EINVAL, errno);
++}
++
+ /* Tests ordering of syscall argument checks. */
+ TEST(create_ruleset_checks_ordering)
+ {
+-      const int last_flag = LANDLOCK_CREATE_RULESET_VERSION;
++      const int last_flag = LANDLOCK_CREATE_RULESET_ERRATA;
+       const int invalid_flag = last_flag << 1;
+       int ruleset_fd;
+       const struct landlock_ruleset_attr ruleset_attr = {
diff --git a/queue-6.1/revert-loongarch-bpf-fix-off-by-one-error-in-build_prologue.patch b/queue-6.1/revert-loongarch-bpf-fix-off-by-one-error-in-build_prologue.patch
new file mode 100644 (file)
index 0000000..98d233f
--- /dev/null
@@ -0,0 +1,48 @@
+From 836c0c20a1872b299b8612b9daa75d4b85521b9e Mon Sep 17 00:00:00 2001
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Date: Tue, 22 Apr 2025 10:50:27 +0200
+Subject: Revert "LoongArch: BPF: Fix off-by-one error in build_prologue()"
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+This reverts commit e9ccb262b39a which is
+commit 7e2586991e36663c9bc48c828b83eab180ad30a9 upstream.
+
+It breaks the build.
+
+Link: https://lore.kernel.org/r/90288944-3f5b-45b7-ae7d-c7a54398db55@roeck-us.neta
+Reported-by: Guenter Roeck <linux@roeck-us.net>
+Cc: Vincent Li <vincent.mc.li@gmail.com>
+Cc: Hengqi Chen <hengqi.chen@gmail.com>
+Cc: Huacai Chen <chenhuacai@loongson.cn>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/loongarch/net/bpf_jit.c |    2 --
+ arch/loongarch/net/bpf_jit.h |    5 -----
+ 2 files changed, 7 deletions(-)
+
+--- a/arch/loongarch/net/bpf_jit.c
++++ b/arch/loongarch/net/bpf_jit.c
+@@ -142,8 +142,6 @@ static void build_prologue(struct jit_ct
+        */
+       if (seen_tail_call(ctx) && seen_call(ctx))
+               move_reg(ctx, TCC_SAVED, REG_TCC);
+-      else
+-              emit_insn(ctx, nop);
+       ctx->stack_size = stack_adjust;
+ }
+--- a/arch/loongarch/net/bpf_jit.h
++++ b/arch/loongarch/net/bpf_jit.h
+@@ -25,11 +25,6 @@ struct jit_data {
+       struct jit_ctx ctx;
+ };
+-static inline void emit_nop(union loongarch_instruction *insn)
+-{
+-      insn->word = INSN_NOP;
+-}
+-
+ #define emit_insn(ctx, func, ...)                                             \
+ do {                                                                          \
+       if (ctx->image != NULL) {                                               \
index c5c1fa5baddd3eeda6e0219d08decc238bbd3b37..7bb707b94ae7b48a7e1494fff5214d718b147d18 100644 (file)
@@ -272,3 +272,6 @@ btrfs-fix-qgroup-reserve-leaks-in-cow_file_range.patch
 btrfs-zoned-fix-zone-activation-with-missing-devices.patch
 btrfs-zoned-fix-zone-finishing-with-missing-devices.patch
 revert-xen-swiotlb-mark-xen_swiotlb_fixup-__init.patch
+drm-amd-display-stop-amdgpu_dm-initialize-when-link-nums-greater-than-max_links.patch
+landlock-add-the-errata-interface.patch
+revert-loongarch-bpf-fix-off-by-one-error-in-build_prologue.patch