mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-07-08 18:13:59 +02:00
lib/vsprintf: Check pointer before dereferencing in time_and_date()
[ Upstream commit372a12bd5d] The pointer may be invalid when gets to the printf(). In particular the time_and_date() dereferencing it in some cases without checking. Move the check from rtc_str() to time_and_date() to cover all cases. Fixes:7daac5b2fd("lib/vsprintf: Print time64_t in human readable format") Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Petr Mladek <pmladek@suse.com> Link: https://patch.msgid.link/20251110132118.4113976-1-andriy.shevchenko@linux.intel.com Signed-off-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
80ff15286f
commit
a9af8ca089
+3
-3
@@ -1829,9 +1829,6 @@ char *rtc_str(char *buf, char *end, const struct rtc_time *tm,
|
||||
bool raw = false;
|
||||
int count = 2;
|
||||
|
||||
if (check_pointer(&buf, end, tm, spec))
|
||||
return buf;
|
||||
|
||||
switch (fmt[count]) {
|
||||
case 'd':
|
||||
have_t = false;
|
||||
@@ -1886,6 +1883,9 @@ static noinline_for_stack
|
||||
char *time_and_date(char *buf, char *end, void *ptr, struct printf_spec spec,
|
||||
const char *fmt)
|
||||
{
|
||||
if (check_pointer(&buf, end, ptr, spec))
|
||||
return buf;
|
||||
|
||||
switch (fmt[1]) {
|
||||
case 'R':
|
||||
return rtc_str(buf, end, (const struct rtc_time *)ptr, spec, fmt);
|
||||
|
||||
Reference in New Issue
Block a user