diff mbox series

[SRU,F/J/M,2/2] UBUNTU: SAUCE: af_unix: fix lockdep positive in sk_diag_dump_icons()

Message ID 20240327001835.104772-3-yuxuan.luo@canonical.com
State New
Headers show
Series CVE-2024-26624 | expand

Commit Message

Yuxuan Luo March 27, 2024, 12:18 a.m. UTC
[ upstream commit 4d322dce82a1d44f8c83f0f54f95dd1b8dcf46c9 ]

The 4d322dce82a1 ("af_unix: fix lockdep positive in
sk_diag_dump_icons()") commit modifies unix_state_lock_nested() which is
copied to security/apparmor/af_unix.c. This commit synchronizes this
change.

CVE-2024-26624
Signed-off-by: Yuxuan Luo <yuxuan.luo@canonical.com>
---
 security/apparmor/af_unix.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/security/apparmor/af_unix.c b/security/apparmor/af_unix.c
index 06d6946990b91..d9344ee66af9d 100644
--- a/security/apparmor/af_unix.c
+++ b/security/apparmor/af_unix.c
@@ -578,13 +578,11 @@  static void unix_state_double_lock(struct sock *sk1, struct sock *sk2)
 		unix_state_lock(sk1);
 		return;
 	}
-	if (sk1 < sk2) {
-		unix_state_lock(sk1);
-		unix_state_lock_nested(sk2);
-	} else {
-		unix_state_lock(sk2);
-		unix_state_lock_nested(sk1);
-	}
+	if (sk1 > sk2)
+		swap(sk1, sk2);
+
+	unix_state_lock(sk1);
+	unix_state_lock_nested(sk2, U_LOCK_SECOND);
 }
 
 static void unix_state_double_unlock(struct sock *sk1, struct sock *sk2)