All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergei Trofimovich <slyich@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org,
	Sergei Trofimovich <slyich@gmail.com>,
	Josh Poimboeuf <jpoimboe@redhat.com>
Subject: [PATCH] objtool: check: give big enough buffer for pv_ops
Date: Fri, 14 Jan 2022 07:57:56 +0000	[thread overview]
Message-ID: <20220114075756.838243-1-slyich@gmail.com> (raw)

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>
---
 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 8c1931eab5f1..0fae132ea59f 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2852,7 +2852,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


             reply	other threads:[~2022-01-14  7:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-14  7:57 Sergei Trofimovich [this message]
2022-01-14  8:53 ` [PATCH] objtool: check: give big enough buffer for pv_ops Peter Zijlstra
2022-01-20 22:58   ` Josh Poimboeuf
2022-01-20 23:09     ` Josh Poimboeuf
2022-01-20 23:37       ` [PATCH v2] " Sergei Trofimovich
2022-01-31 12:04         ` [tip: objtool/urgent] objtool: Fix truncated string warning tip-bot2 for Sergei Trofimovich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220114075756.838243-1-slyich@gmail.com \
    --to=slyich@gmail.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.