* [scarthgap][PATCH] pam: Fix for CVE-2024-22365
@ 2024-07-24 10:11 Guðni Már Gilbert
2024-07-24 10:13 ` Guðni Már Gilbert
0 siblings, 1 reply; 2+ messages in thread
From: Guðni Már Gilbert @ 2024-07-24 10:11 UTC (permalink / raw)
To: openembedded-core; +Cc: Guðni Már Gilbert
Upstream-Status: Backport from https://github.com/linux-pam/linux-pam/commit/031bb5a5d0d950253b68138b498dc93be69a64cb
Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
---
.../pam/libpam/CVE-2024-22365.patch | 65 +++++++++++++++++++
meta/recipes-extended/pam/libpam_1.5.3.bb | 1 +
2 files changed, 66 insertions(+)
create mode 100644 meta/recipes-extended/pam/libpam/CVE-2024-22365.patch
diff --git a/meta/recipes-extended/pam/libpam/CVE-2024-22365.patch b/meta/recipes-extended/pam/libpam/CVE-2024-22365.patch
new file mode 100644
index 0000000000..e4ec862dc5
--- /dev/null
+++ b/meta/recipes-extended/pam/libpam/CVE-2024-22365.patch
@@ -0,0 +1,65 @@
+From 84f378d3b8573828e7ccc54b54b5e128aa993748 Mon Sep 17 00:00:00 2001
+From: Matthias Gerstner <matthias.gerstner@suse.de>
+Date: Wed, 27 Dec 2023 14:01:59 +0100
+Subject: [PATCH] pam_namespace: protect_dir(): use O_DIRECTORY to prevent
+ local DoS situations
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Without O_DIRECTORY the path crawling logic is subject to e.g. FIFOs
+being placed in user controlled directories, causing the PAM module to
+block indefinitely during `openat()`.
+
+Pass O_DIRECTORY to cause the `openat()` to fail if the path does not
+refer to a directory.
+
+With this the check whether the final path element is a directory
+becomes unnecessary, drop it.
+
+Upstream-Status: Backport [https://github.com/linux-pam/linux-pam/commit/031bb5a5d0d950253b68138b498dc93be69a64cb]
+CVE: CVE-2024-22365
+Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
+---
+ modules/pam_namespace/pam_namespace.c | 18 +-----------------
+ 1 file changed, 1 insertion(+), 17 deletions(-)
+
+diff --git a/modules/pam_namespace/pam_namespace.c b/modules/pam_namespace/pam_namespace.c
+index f34ce934..ef856443 100644
+--- a/modules/pam_namespace/pam_namespace.c
++++ b/modules/pam_namespace/pam_namespace.c
+@@ -1194,7 +1194,7 @@ static int protect_dir(const char *path, mode_t mode, int do_mkdir,
+ int dfd = AT_FDCWD;
+ int dfd_next;
+ int save_errno;
+- int flags = O_RDONLY;
++ int flags = O_RDONLY | O_DIRECTORY;
+ int rv = -1;
+ struct stat st;
+
+@@ -1248,22 +1248,6 @@ static int protect_dir(const char *path, mode_t mode, int do_mkdir,
+ rv = openat(dfd, dir, flags);
+ }
+
+- if (rv != -1) {
+- if (fstat(rv, &st) != 0) {
+- save_errno = errno;
+- close(rv);
+- rv = -1;
+- errno = save_errno;
+- goto error;
+- }
+- if (!S_ISDIR(st.st_mode)) {
+- close(rv);
+- errno = ENOTDIR;
+- rv = -1;
+- goto error;
+- }
+- }
+-
+ if (flags & O_NOFOLLOW) {
+ /* we are inside user-owned dir - protect */
+ if (protect_mount(rv, p, idata) == -1) {
+--
+2.43.0
+
diff --git a/meta/recipes-extended/pam/libpam_1.5.3.bb b/meta/recipes-extended/pam/libpam_1.5.3.bb
index ef32d19f3d..bcaa84c9a5 100644
--- a/meta/recipes-extended/pam/libpam_1.5.3.bb
+++ b/meta/recipes-extended/pam/libpam_1.5.3.bb
@@ -26,6 +26,7 @@ SRC_URI = "${GITHUB_BASE_URI}/download/v${PV}/Linux-PAM-${PV}.tar.xz \
file://pam-volatiles.conf \
file://0001-pam_namespace-include-stdint-h.patch \
file://0001-pam_pwhistory-fix-passing-NULL-filename-argument-to-.patch \
+ file://CVE-2024-22365.patch \
"
SRC_URI[sha256sum] = "7ac4b50feee004a9fa88f1dfd2d2fa738a82896763050cd773b3c54b0a818283"
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [scarthgap][PATCH] pam: Fix for CVE-2024-22365
2024-07-24 10:11 [scarthgap][PATCH] pam: Fix for CVE-2024-22365 Guðni Már Gilbert
@ 2024-07-24 10:13 ` Guðni Már Gilbert
0 siblings, 0 replies; 2+ messages in thread
From: Guðni Már Gilbert @ 2024-07-24 10:13 UTC (permalink / raw)
To: openembedded-core
[-- Attachment #1: Type: text/plain, Size: 211 bytes --]
Note: this backport is already in kirkstone and dunfell. See for example: https://git.openembedded.org/openembedded-core/commit/meta/recipes-extended/pam?h=kirkstone&id=9af2e012ee4483541559788dfb9510e0223daefe
[-- Attachment #2: Type: text/html, Size: 226 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-24 10:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-24 10:11 [scarthgap][PATCH] pam: Fix for CVE-2024-22365 Guðni Már Gilbert
2024-07-24 10:13 ` Guðni Már Gilbert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox