diff --git a/CVE-2024-22365.patch b/CVE-2024-22365.patch new file mode 100644 index 0000000000000000000000000000000000000000..7811013728a68a7f2158bcdc8a0e9cf7ac6b3818 --- /dev/null +++ b/CVE-2024-22365.patch @@ -0,0 +1,55 @@ +From 031bb5a5d0d950253b68138b498dc93be69a64cb Mon Sep 17 00:00:00 2001 +From: Matthias Gerstner +Date: Wed, 27 Dec 2023 14:01:59 +0100 +Subject: [PATCH] pam_namespace: protect_dir(): use O_DIRECTORY to prevent + local DoS situations + +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. +--- + 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 2528cff86..f72d67189 100644 +--- a/modules/pam_namespace/pam_namespace.c ++++ b/modules/pam_namespace/pam_namespace.c +@@ -1201,7 +1201,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; + +@@ -1255,22 +1255,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) { diff --git a/pam.spec b/pam.spec index e8ec49d1acac1dd105e4204b52473a0f1cb68220..9adc8f70c698731d8dbdd812a40e7fcdb6dbccf2 100644 --- a/pam.spec +++ b/pam.spec @@ -1,4 +1,4 @@ -%define anolis_release 6 +%define anolis_release 7 %global soname_version 0 Name: pam @@ -8,11 +8,9 @@ Summary: A Security Interface for Applications in Authentication activiti License: GPL-2.0-or-later OR BSD-3-Clause Group: System/Libraries -URL: http://www.linux-pam.org/ -Source0: Linux-PAM-%{version}.tar.xz -Source1: Linux-PAM-%{version}.tar.xz.asc -Source2: Linux-PAM-%{version}-docs.tar.xz -Source3: Linux-PAM-%{version}-docs.tar.xz.asc +URL: https://github.com/linux-pam/linux-pam +Source0: https://github.com/linux-pam/linux-pam/releases/download/v%{version}/Linux-PAM-%{version}.tar.xz +Source1: https://github.com/linux-pam/linux-pam/releases/download/v%{version}/Linux-PAM-%{version}-docs.tar.xz Source4: gpl-2.0.txt Source5: macros.%{name} #config files @@ -25,7 +23,8 @@ Source100: system-auth.5 Source101: config-util.5 Source102: postlogin.5 -Patch1: 0001-use-gdbm-instead-of-libdb.patch +Patch0001: 0001-use-gdbm-instead-of-libdb.patch +Patch0002: CVE-2024-22365.patch BuildRequires: audit-libs-devel BuildRequires: autoconf @@ -111,14 +110,15 @@ having to recompile programs that handle authentication. The pam-libs contains the shared libraries for PAM. %prep -%setup -q -n Linux-PAM-%{version} -a 2 +%setup -q -n Linux-PAM-%{version} -a 1 perl -pi -e "s/ppc64-\*/ppc64-\* \| ppc64p7-\*/" build-aux/config.sub perl -pi -e "s/\/lib \/usr\/lib/\/lib \/usr\/lib \/lib64 \/usr\/lib64/" m4/libtool.m4 #Add GPL license cp %{SOURCE4} . -%patch1 -p1 +%patch -P0001 -p1 +%patch -P0002 -p1 %build autoreconf -i @@ -345,6 +345,8 @@ done %{abidir}/libpam*.dump %changelog +* Thu Jan 18 2024 Funda Wang - 1.5.2-7 +- fix CVE-2024-22365 * Mon Dec 5 2022 Kun(llfl) - 1.5.2-6 - optimise spec file and remove unnecessary list file