Re: [PATCH -next -v2 6/8] lockdown: bound the status string with scnprintf

From
sashiko-bot@kernel.org
Date
2026-11-10 13:12:54
Reply to
Cai Xinchen, 2026-11-10
Use scnprintf() instead of sprintf() when composing the lockdown status
string in lockdown_read().  The current set of levels fits well within the
80 byte buffer, but sprintf() provides no protection if more or longer
labels are added later.  scnprintf() makes the buffer bounds explicit.

Store the level label strings in named arrays and point the matching
lockdown_reasons[] entries at them.  Their sizes are compile-time
constants, so a BUILD_BUG_ON() can verify that the status buffer is large
enough for all level labels, their trailing spaces, and the brackets
around the active one.

Signed-off-by: Cai Xinchen <redacted>
Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261110132818.2231593-1-caixinchen1@huawei.com?part=6
Thread (18 messages) 18 messages, 3 authors, last reply 6d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help