lkml.org 
[lkml]   [2022]   [Jan]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2] objtool: check: give big enough buffer for pv_ops
Date
On gcc-12 build fails flagging possible buffer overflow:

check.c: In function 'validate_call':
check.c:2865:58: error: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size 9 [-Werror=format-truncation=]
2865 | snprintf(pvname, sizeof(pvname), "pv_ops[%d]", idx);
| ^~

I think it's a valid warning:

static char pvname[16];
int idx;
...
idx = (rel->addend / sizeof(void *));
snprintf(pvname, sizeof(pvname), "pv_ops[%d]", idx);

we have only 7 chars for %d while it could take up to 9.

CC: Josh Poimboeuf <jpoimboe@redhat.com>
CC: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Sergei Trofimovich <slyich@gmail.com>
---
Change since v1: added missing S-O-B.
tools/objtool/check.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index c2d2ab9a2861..f5bed94e4558 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2854,7 +2854,7 @@ static inline bool func_uaccess_safe(struct symbol *func)

static inline const char *call_dest_name(struct instruction *insn)
{
- static char pvname[16];
+ static char pvname[32];
struct reloc *rel;
int idx;

--
2.34.1
\
 
 \ /
  Last update: 2022-01-21 00:38    [W:0.082 / U:0.800 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site