Commit 5e342e81 authored by Rasmus Villemoes's avatar Rasmus Villemoes Committed by Yang Yingliang
Browse files

efi: cper: fix snprintf() use in cper_dimm_err_location()



stable inclusion
from linux-4.19.194
commit dd47a33e11fdd6c9d31570500e6ecc369ba1f08e

--------------------------------

[ Upstream commit 942859d9 ]

snprintf() should be given the full buffer size, not one less. And it
guarantees nul-termination, so doing it manually afterwards is
pointless.

It's even potentially harmful (though probably not in practice because
CPER_REC_LEN is 256), due to the "return how much would have been
written had the buffer been big enough" semantics. I.e., if the bank
and/or device strings are long enough that the "DIMM location ..."
output gets truncated, writing to msg[n] is a buffer overflow.

Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
Fixes: 3760cd20 ("CPER: Adjust code flow of some functions")
Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parent 3f680876
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment