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: <tencent_54C2A2746A83BA29EE92248CE9683F0C6509@qq.com>
Date:   Sun,  9 Jul 2023 14:49:12 +0800
From:   Linke Li <lilinke99@...mail.com>
To:     linux-mips@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org, tsbogend@...ha.franken.de,
        Linke Li <lilinke99@...il.com>
Subject: [PATCH] MIPS: Fix undefined behavior in PAGE_MASK calculation

From: Linke Li <lilinke99@...il.com>

Make PAGE_MASK an unsigned long, like it is on x86, to avoid:

../arch/mips/include/asm/ginvt.h:44:20: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        addr &= PAGE_MASK << 1;

In the MIPS architecture, the PAGE_MASK definition in arch/mips/include/asm/page.h leads to
shifting a negative signed value, which is undefined according to the language specification.
To address this issue, the PAGE_MASK definition is modified to be unsigned long and ensure
well-defined behavior.

Signed-off-by: Linke Li <lilinke99@...il.com>
---
 arch/mips/include/asm/page.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
index 5978a8dfb917..3061a5586954 100644
--- a/arch/mips/include/asm/page.h
+++ b/arch/mips/include/asm/page.h
@@ -33,7 +33,7 @@
 #define PAGE_SHIFT	16
 #endif
 #define PAGE_SIZE	(_AC(1,UL) << PAGE_SHIFT)
-#define PAGE_MASK	(~((1 << PAGE_SHIFT) - 1))
+#define PAGE_MASK	(~(PAGE_SIZE - 1))
 
 /*
  * This is used for calculating the real page sizes
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ