lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <171995639138.2215.10418408006509074215.tip-bot2@tip-bot2>
Date: Tue, 02 Jul 2024 21:39:51 -0000
From: "tip-bot2 for Yosry Ahmed" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Yosry Ahmed <yosryahmed@...gle.com>,
 Dave Hansen <dave.hansen@...ux.intel.com>,
 "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>, x86@...nel.org,
 linux-kernel@...r.kernel.org
Subject: [tip: x86/mm] x86/mm: Cleanup prctl_enable_tagged_addr() nr_bits
 error checking

The following commit has been merged into the x86/mm branch of tip:

Commit-ID:     b7c35279e0da414e7d90eba76f58a16223a734cb
Gitweb:        https://git.kernel.org/tip/b7c35279e0da414e7d90eba76f58a16223a734cb
Author:        Yosry Ahmed <yosryahmed@...gle.com>
AuthorDate:    Tue, 02 Jul 2024 13:21:39 
Committer:     Dave Hansen <dave.hansen@...ux.intel.com>
CommitterDate: Tue, 02 Jul 2024 11:33:44 -07:00

x86/mm: Cleanup prctl_enable_tagged_addr() nr_bits error checking

There are two separate checks in prctl_enable_tagged_addr() that nr_bits
is in the correct range. The checks are arranged such the correct case
is sandwiched between both error cases, which do exactly the same thing.

Simplify the if condition and pull the correct case outside with the
rest of the success code path.

Signed-off-by: Yosry Ahmed <yosryahmed@...gle.com>
Signed-off-by: Dave Hansen <dave.hansen@...ux.intel.com>
Reviewed-by: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
Link: https://lore.kernel.org/all/20240702132139.3332013-4-yosryahmed%40google.com
---
 arch/x86/kernel/process_64.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index e9f7cfd..2264723 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -812,6 +812,9 @@ static void enable_lam_func(void *__mm)
 
 static void mm_enable_lam(struct mm_struct *mm)
 {
+	mm->context.lam_cr3_mask = X86_CR3_LAM_U57;
+	mm->context.untag_mask =  ~GENMASK(62, 57);
+
 	/*
 	 * Even though the process must still be single-threaded at this
 	 * point, kernel threads may be using the mm.  IPI those kernel
@@ -846,13 +849,7 @@ static int prctl_enable_tagged_addr(struct mm_struct *mm, unsigned long nr_bits)
 		return -EBUSY;
 	}
 
-	if (!nr_bits) {
-		mmap_write_unlock(mm);
-		return -EINVAL;
-	} else if (nr_bits <= LAM_U57_BITS) {
-		mm->context.lam_cr3_mask = X86_CR3_LAM_U57;
-		mm->context.untag_mask =  ~GENMASK(62, 57);
-	} else {
+	if (!nr_bits || nr_bits > LAM_U57_BITS) {
 		mmap_write_unlock(mm);
 		return -EINVAL;
 	}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ