From: Sergei Trofimovich Date: Thu, 20 Jan 2022 23:37:48 +0000 (+0000) Subject: objtool: check: give big enough buffer for pv_ops X-Git-Tag: archive/raspbian/5.16.7-2+rpi1^2~26 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=7fdd101d9024dcf6764fc273cfd16d554e707c33;p=linux.git objtool: check: give big enough buffer for pv_ops Origin: https://lore.kernel.org/lkml/20220120233748.2062559-1-slyich@gmail.com/ Bug-Debian: https://bugs.debian.org/1004495 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 CC: Peter Zijlstra Signed-off-by: Sergei Trofimovich Gbp-Pq: Topic bugfix/all Gbp-Pq: Name objtool-check-give-big-enough-buffer-for-pv_ops.patch --- diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 21735829b86..a4883a5e4eb 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -2823,7 +2823,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;