* [PATCH v2 0/2] EDAC/ i5000, i5400: fix snprintf limit
@ 2025-12-09 14:36 Dan Carpenter
2025-12-09 14:36 ` [PATCH v2 1/2] EDAC/i5000: Fix snprintf() size calculation in calculate_dimm_size() Dan Carpenter
2025-12-09 14:37 ` [PATCH v2 2/2] EDAC/i5400: Fix snprintf() limit " Dan Carpenter
0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2025-12-09 14:36 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Aristeu Rozanski, Borislav Petkov, linux-edac, linux-kernel,
Tony Luck
These fixes don't affect runtime since the buffer is large enough but
the size limits used for snprintf() limits aren't caculated correct.
Changes since v1:
* Fix i5000 as well.
* Fix the subject
* Delete some related dead code
Dan Carpenter (2):
EDAC/i5000: Fix snprintf() size calculation in calculate_dimm_size()
EDAC/i5400: Fix snprintf() limit calculation in calculate_dimm_size()
drivers/edac/i5000_edac.c | 1 +
drivers/edac/i5400_edac.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
--
2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/2] EDAC/i5000: Fix snprintf() size calculation in calculate_dimm_size()
2025-12-09 14:36 [PATCH v2 0/2] EDAC/ i5000, i5400: fix snprintf limit Dan Carpenter
@ 2025-12-09 14:36 ` Dan Carpenter
2025-12-10 1:26 ` Zhuo, Qiuxu
2025-12-09 14:37 ` [PATCH v2 2/2] EDAC/i5400: Fix snprintf() limit " Dan Carpenter
1 sibling, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2025-12-09 14:36 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Borislav Petkov, Tony Luck, Aristeu Rozanski, linux-edac,
linux-kernel
The snprintf() can't really overflow because we're writing a max of 42
bytes to a PAGE_SIZE buffer. But the limit calculation doesn't take
the first 11 bytes that we wrote into consideration so the limit is
not correct. Just fix it for correctness even though it doesn't
affect runtime.
Fixes: 64e1fdaf55d6 ("i5000_edac: Fix the logic that retrieves memory information")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
v2: new patch
drivers/edac/i5000_edac.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/edac/i5000_edac.c b/drivers/edac/i5000_edac.c
index 4a1bebc1ff14..471b8540d18b 100644
--- a/drivers/edac/i5000_edac.c
+++ b/drivers/edac/i5000_edac.c
@@ -1111,6 +1111,7 @@ static void calculate_dimm_size(struct i5000_pvt *pvt)
n = snprintf(p, space, " ");
p += n;
+ space -= n;
for (branch = 0; branch < MAX_BRANCHES; branch++) {
n = snprintf(p, space, " branch %d | ", branch);
p += n;
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] EDAC/i5400: Fix snprintf() limit calculation in calculate_dimm_size()
2025-12-09 14:36 [PATCH v2 0/2] EDAC/ i5000, i5400: fix snprintf limit Dan Carpenter
2025-12-09 14:36 ` [PATCH v2 1/2] EDAC/i5000: Fix snprintf() size calculation in calculate_dimm_size() Dan Carpenter
@ 2025-12-09 14:37 ` Dan Carpenter
1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2025-12-09 14:37 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Borislav Petkov, Tony Luck, Aristeu Rozanski, linux-edac,
linux-kernel
The snprintf() can't really overflow because we're writing a max of 42
bytes to a PAGE_SIZE buffer. But my static checker complains because
the limit calculation doesn't take the first 11 space characters that
we wrote into the buffer into consideration. Fix this for the sake of
correctness even though it doesn't affect runtime.
Also delete an earlier "space -= n;" which was not used.
Fixes: 68d086f89b80 ("i5400_edac: improve debug messages to better represent the filled memory")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
---
v2: Delete the earlier "space -= n" which is not used.
Fix the subject
drivers/edac/i5400_edac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/edac/i5400_edac.c b/drivers/edac/i5400_edac.c
index b5cf25905b05..fb49a1d1df11 100644
--- a/drivers/edac/i5400_edac.c
+++ b/drivers/edac/i5400_edac.c
@@ -1026,13 +1026,13 @@ static void calculate_dimm_size(struct i5400_pvt *pvt)
space -= n;
}
- space -= n;
edac_dbg(2, "%s\n", mem_buffer);
p = mem_buffer;
space = PAGE_SIZE;
n = snprintf(p, space, " ");
p += n;
+ space -= n;
for (branch = 0; branch < MAX_BRANCHES; branch++) {
n = snprintf(p, space, " branch %d | ", branch);
p += n;
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH v2 1/2] EDAC/i5000: Fix snprintf() size calculation in calculate_dimm_size()
2025-12-09 14:36 ` [PATCH v2 1/2] EDAC/i5000: Fix snprintf() size calculation in calculate_dimm_size() Dan Carpenter
@ 2025-12-10 1:26 ` Zhuo, Qiuxu
0 siblings, 0 replies; 4+ messages in thread
From: Zhuo, Qiuxu @ 2025-12-10 1:26 UTC (permalink / raw)
To: Dan Carpenter, Mauro Carvalho Chehab
Cc: Borislav Petkov, Luck, Tony, Aristeu Rozanski,
linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org
> From: Dan Carpenter <dan.carpenter@linaro.org>
> Sent: Tuesday, December 9, 2025 10:37 PM
> To: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: Borislav Petkov <bp@alien8.de>; Luck, Tony <tony.luck@intel.com>;
> Aristeu Rozanski <arozansk@redhat.com>; linux-edac@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Subject: [PATCH v2 1/2] EDAC/i5000: Fix snprintf() size calculation in
> calculate_dimm_size()
>
> The snprintf() can't really overflow because we're writing a max of 42 bytes to
> a PAGE_SIZE buffer. But the limit calculation doesn't take the first 11 bytes
> that we wrote into consideration so the limit is not correct. Just fix it for
> correctness even though it doesn't affect runtime.
>
> Fixes: 64e1fdaf55d6 ("i5000_edac: Fix the logic that retrieves memory
> information")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
LGTM. Thanks.
Reviewed-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-12-10 1:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-09 14:36 [PATCH v2 0/2] EDAC/ i5000, i5400: fix snprintf limit Dan Carpenter
2025-12-09 14:36 ` [PATCH v2 1/2] EDAC/i5000: Fix snprintf() size calculation in calculate_dimm_size() Dan Carpenter
2025-12-10 1:26 ` Zhuo, Qiuxu
2025-12-09 14:37 ` [PATCH v2 2/2] EDAC/i5400: Fix snprintf() limit " Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).