Skip to content

Commit 76a299f

Browse files
[AUTO-CHERRYPICK] Patched CVE-2024-22365 in pam. (CP: #8320) - branch 3.0-dev (#10896)
Co-authored-by: Pawel Winogrodzki <pawelwi@microsoft.com>
1 parent bef8a9c commit 76a299f

4 files changed

Lines changed: 70 additions & 10 deletions

File tree

SPECS/pam/CVE-2024-22365.patch

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
From 031bb5a5d0d950253b68138b498dc93be69a64cb Mon Sep 17 00:00:00 2001
2+
From: Matthias Gerstner <matthias.gerstner@suse.de>
3+
Date: Wed, 27 Dec 2023 14:01:59 +0100
4+
Subject: [PATCH] pam_namespace: protect_dir(): use O_DIRECTORY to prevent
5+
local DoS situations
6+
7+
Without O_DIRECTORY the path crawling logic is subject to e.g. FIFOs
8+
being placed in user controlled directories, causing the PAM module to
9+
block indefinitely during `openat()`.
10+
11+
Pass O_DIRECTORY to cause the `openat()` to fail if the path does not
12+
refer to a directory.
13+
14+
With this the check whether the final path element is a directory
15+
becomes unnecessary, drop it.
16+
---
17+
modules/pam_namespace/pam_namespace.c | 18 +-----------------
18+
1 file changed, 1 insertion(+), 17 deletions(-)
19+
20+
diff --git a/modules/pam_namespace/pam_namespace.c b/modules/pam_namespace/pam_namespace.c
21+
index 2528cff86..f72d67189 100644
22+
--- a/modules/pam_namespace/pam_namespace.c
23+
+++ b/modules/pam_namespace/pam_namespace.c
24+
@@ -1201,7 +1201,7 @@ static int protect_dir(const char *path, mode_t mode, int do_mkdir,
25+
int dfd = AT_FDCWD;
26+
int dfd_next;
27+
int save_errno;
28+
- int flags = O_RDONLY;
29+
+ int flags = O_RDONLY | O_DIRECTORY;
30+
int rv = -1;
31+
struct stat st;
32+
33+
@@ -1255,22 +1255,6 @@ static int protect_dir(const char *path, mode_t mode, int do_mkdir,
34+
rv = openat(dfd, dir, flags);
35+
}
36+
37+
- if (rv != -1) {
38+
- if (fstat(rv, &st) != 0) {
39+
- save_errno = errno;
40+
- close(rv);
41+
- rv = -1;
42+
- errno = save_errno;
43+
- goto error;
44+
- }
45+
- if (!S_ISDIR(st.st_mode)) {
46+
- close(rv);
47+
- errno = ENOTDIR;
48+
- rv = -1;
49+
- goto error;
50+
- }
51+
- }
52+
-
53+
if (flags & O_NOFOLLOW) {
54+
/* we are inside user-owned dir - protect */
55+
if (protect_mount(rv, p, idata) == -1) {

SPECS/pam/pam.spec

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Summary: Linux Pluggable Authentication Modules
22
Name: pam
33
Version: 1.5.3
4-
Release: 1%{?dist}
4+
Release: 2%{?dist}
55
License: BSD and GPLv2+
66
URL: https://github.com/linux-pam/linux-pam
77
Source0: https://github.com/linux-pam/linux-pam/releases/download/v%{version}/Linux-PAM-%{version}.tar.xz
@@ -15,6 +15,8 @@ BuildRequires: audit-devel
1515
Requires: audit-libs
1616
Recommends: cracklib-dicts
1717

18+
Patch0: CVE-2024-22365.patch
19+
1820
%description
1921
The Linux PAM package contains Pluggable Authentication Modules used to
2022
enable the local system administrator to choose how applications authenticate users.
@@ -37,7 +39,7 @@ This package contains libraries, header files and documentation
3739
for developing applications that use pam.
3840

3941
%prep
40-
%autosetup -n Linux-PAM-%{version}
42+
%autosetup -n Linux-PAM-%{version} -p1
4143

4244
%build
4345
./configure \
@@ -102,6 +104,9 @@ EOF
102104
%{_libdir}/pkgconfig/pamc.pc
103105

104106
%changelog
107+
* Wed Oct 30 2024 Pawel Winogrodzki <pawelwi@microsoft.com> - 1.5.3-2
108+
- Patching CVE-2024-22365.
109+
105110
* Tue Nov 21 2023 CBL-Mariner Servicing Account <cblmargh@microsoft.com> - 1.5.3-1
106111
- Auto-upgrade to 1.5.3 - Azure Linux 3.0 - package upgrades
107112

toolkit/resources/manifests/package/toolchain_aarch64.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,10 @@ p11-kit-debuginfo-0.25.0-1.azl3.aarch64.rpm
296296
p11-kit-devel-0.25.0-1.azl3.aarch64.rpm
297297
p11-kit-server-0.25.0-1.azl3.aarch64.rpm
298298
p11-kit-trust-0.25.0-1.azl3.aarch64.rpm
299-
pam-1.5.3-1.azl3.aarch64.rpm
300-
pam-debuginfo-1.5.3-1.azl3.aarch64.rpm
301-
pam-devel-1.5.3-1.azl3.aarch64.rpm
302-
pam-lang-1.5.3-1.azl3.aarch64.rpm
299+
pam-1.5.3-2.azl3.aarch64.rpm
300+
pam-debuginfo-1.5.3-2.azl3.aarch64.rpm
301+
pam-devel-1.5.3-2.azl3.aarch64.rpm
302+
pam-lang-1.5.3-2.azl3.aarch64.rpm
303303
patch-2.7.6-9.azl3.aarch64.rpm
304304
patch-debuginfo-2.7.6-9.azl3.aarch64.rpm
305305
pcre2-10.42-3.azl3.aarch64.rpm

toolkit/resources/manifests/package/toolchain_x86_64.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,10 @@ p11-kit-debuginfo-0.25.0-1.azl3.x86_64.rpm
302302
p11-kit-devel-0.25.0-1.azl3.x86_64.rpm
303303
p11-kit-server-0.25.0-1.azl3.x86_64.rpm
304304
p11-kit-trust-0.25.0-1.azl3.x86_64.rpm
305-
pam-1.5.3-1.azl3.x86_64.rpm
306-
pam-debuginfo-1.5.3-1.azl3.x86_64.rpm
307-
pam-devel-1.5.3-1.azl3.x86_64.rpm
308-
pam-lang-1.5.3-1.azl3.x86_64.rpm
305+
pam-1.5.3-2.azl3.x86_64.rpm
306+
pam-debuginfo-1.5.3-2.azl3.x86_64.rpm
307+
pam-devel-1.5.3-2.azl3.x86_64.rpm
308+
pam-lang-1.5.3-2.azl3.x86_64.rpm
309309
patch-2.7.6-9.azl3.x86_64.rpm
310310
patch-debuginfo-2.7.6-9.azl3.x86_64.rpm
311311
pcre2-10.42-3.azl3.x86_64.rpm

0 commit comments

Comments
 (0)