From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Kuan-Wei Chiu <visitorckw@gmail.com>,
Petr Mladek <pmladek@suse.com>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 6.13 12/34] printk: Fix signed integer overflow when defining LOG_BUF_LEN_MAX
Date: Sun, 26 Jan 2025 09:52:48 -0500 [thread overview]
Message-ID: <20250126145310.926311-12-sashal@kernel.org> (raw)
In-Reply-To: <20250126145310.926311-1-sashal@kernel.org>
From: Kuan-Wei Chiu <visitorckw@gmail.com>
[ Upstream commit 3d6f83df8ff2d5de84b50377e4f0d45e25311c7a ]
Shifting 1 << 31 on a 32-bit int causes signed integer overflow, which
leads to undefined behavior. To prevent this, cast 1 to u32 before
performing the shift, ensuring well-defined behavior.
This change explicitly avoids any potential overflow by ensuring that
the shift occurs on an unsigned 32-bit integer.
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Acked-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20240928113608.1438087-1-visitorckw@gmail.com
Signed-off-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/printk/printk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 80910bc3470c2..d8d82dd39dee8 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -523,7 +523,7 @@ static struct latched_seq clear_seq = {
/* record buffer */
#define LOG_ALIGN __alignof__(unsigned long)
#define __LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT)
-#define LOG_BUF_LEN_MAX (u32)(1 << 31)
+#define LOG_BUF_LEN_MAX ((u32)1 << 31)
static char __log_buf[__LOG_BUF_LEN] __aligned(LOG_ALIGN);
static char *log_buf = __log_buf;
static u32 log_buf_len = __LOG_BUF_LEN;
--
2.39.5
next prev parent reply other threads:[~2025-01-26 14:53 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-26 14:52 [PATCH AUTOSEL 6.13 01/34] drm/virtio: New fence for every plane update Sasha Levin
2025-01-26 14:52 ` [PATCH AUTOSEL 6.13 02/34] drm: Add panel backlight quirks Sasha Levin
2025-01-26 14:52 ` [PATCH AUTOSEL 6.13 03/34] drm/amd/display: Add support for minimum backlight quirk Sasha Levin
2025-01-26 14:52 ` [PATCH AUTOSEL 6.13 04/34] drm: panel-backlight-quirks: Add Framework 13 matte panel Sasha Levin
2025-01-26 14:52 ` [PATCH AUTOSEL 6.13 05/34] drm: panel-backlight-quirks: Add Framework 13 glossy and 2.8k panels Sasha Levin
2025-01-26 14:52 ` [PATCH AUTOSEL 6.13 06/34] nvkm/gsp: correctly advance the read pointer of GSP message queue Sasha Levin
2025-01-26 14:52 ` [PATCH AUTOSEL 6.13 07/34] nvkm: correctly calculate the available space of the GSP cmdq buffer Sasha Levin
2025-01-26 14:52 ` [PATCH AUTOSEL 6.13 08/34] drm/tests: hdmi: handle empty modes in find_preferred_mode() Sasha Levin
2025-01-26 14:52 ` [PATCH AUTOSEL 6.13 09/34] drm/tests: hdmi: return meaningful value from set_connector_edid() Sasha Levin
2025-01-26 14:52 ` [PATCH AUTOSEL 6.13 10/34] drm/amd/display: Populate chroma prefetch parameters, DET buffer fix Sasha Levin
2025-01-26 14:52 ` [PATCH AUTOSEL 6.13 11/34] drm/amd/display: Overwriting dualDPP UBF values before usage Sasha Levin
2025-01-26 14:52 ` Sasha Levin [this message]
2025-01-26 14:52 ` [PATCH AUTOSEL 6.13 13/34] drm/msm/dpu: filter out too wide modes if no 3dmux is present Sasha Levin
2025-01-26 14:52 ` [PATCH AUTOSEL 6.13 14/34] drm/connector: add mutex to protect ELD from concurrent access Sasha Levin
2025-01-26 14:52 ` [PATCH AUTOSEL 6.13 15/34] drm/bridge: anx7625: use eld_mutex to protect access to connector->eld Sasha Levin
2025-01-26 14:52 ` [PATCH AUTOSEL 6.13 16/34] drm/bridge: ite-it66121: " Sasha Levin
2025-01-26 14:52 ` [PATCH AUTOSEL 6.13 17/34] drm/amd/display: " Sasha Levin
2025-01-26 14:52 ` [PATCH AUTOSEL 6.13 18/34] drm/exynos: hdmi: " Sasha Levin
2025-01-26 14:52 ` [PATCH AUTOSEL 6.13 19/34] drm/msm/dp: " Sasha Levin
2025-01-26 14:52 ` [PATCH AUTOSEL 6.13 20/34] drm/radeon: " Sasha Levin
2025-01-26 14:52 ` [PATCH AUTOSEL 6.13 21/34] drm/sti: hdmi: " Sasha Levin
2025-01-26 14:52 ` [PATCH AUTOSEL 6.13 22/34] drm/vc4: " Sasha Levin
2025-01-26 14:52 ` [PATCH AUTOSEL 6.13 23/34] drm/amd/display: Fix Mode Cutoff in DSC Passthrough to DP2.1 Monitor Sasha Levin
2025-01-26 14:53 ` [PATCH AUTOSEL 6.13 24/34] drm/amdgpu: Don't enable sdma 4.4.5 CTXEMPTY interrupt Sasha Levin
2025-01-26 14:53 ` [PATCH AUTOSEL 6.13 25/34] drm/amdkfd: Queue interrupt work to different CPU Sasha Levin
2025-01-26 14:53 ` [PATCH AUTOSEL 6.13 26/34] drm/bridge: it6505: Change definition MAX_HDCP_DOWN_STREAM_COUNT Sasha Levin
2025-01-26 14:53 ` [PATCH AUTOSEL 6.13 27/34] drm/bridge: it6505: fix HDCP Bstatus check Sasha Levin
2025-01-26 14:53 ` [PATCH AUTOSEL 6.13 28/34] drm/bridge: it6505: fix HDCP encryption when R0 ready Sasha Levin
2025-01-26 14:53 ` [PATCH AUTOSEL 6.13 29/34] drm/bridge: it6505: fix HDCP CTS compare V matching Sasha Levin
2025-01-26 14:53 ` [PATCH AUTOSEL 6.13 30/34] drm/bridge: it6505: fix HDCP CTS KSV list wait timer Sasha Levin
2025-01-26 14:53 ` [PATCH AUTOSEL 6.13 31/34] safesetid: check size of policy writes Sasha Levin
2025-01-26 14:53 ` [PATCH AUTOSEL 6.13 32/34] drm/amd/display: Increase sanitizer frame larger than limit when compile testing with clang Sasha Levin
2025-01-26 14:53 ` [PATCH AUTOSEL 6.13 33/34] drm/amd/display: Limit Scaling Ratio on DCN3.01 Sasha Levin
2025-01-26 14:53 ` [PATCH AUTOSEL 6.13 34/34] ring-buffer: Make reading page consistent with the code logic Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250126145310.926311-12-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=stable@vger.kernel.org \
--cc=visitorckw@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox