All of lore.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot2 for Sergei Trofimovich" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Adam Borowski <kilobyte@angband.pl>,
	mliska@suse.cz, Sergei Trofimovich <slyich@gmail.com>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: objtool/urgent] objtool: Fix truncated string warning
Date: Mon, 31 Jan 2022 12:04:55 -0000	[thread overview]
Message-ID: <164363069582.16921.3459888464931150219.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20220120233748.2062559-1-slyich@gmail.com>

The following commit has been merged into the objtool/urgent branch of tip:

Commit-ID:     82880283d7fcd0a1d20964a56d6d1a5cc0df0713
Gitweb:        https://git.kernel.org/tip/82880283d7fcd0a1d20964a56d6d1a5cc0df0713
Author:        Sergei Trofimovich <slyich@gmail.com>
AuthorDate:    Thu, 20 Jan 2022 23:37:48 
Committer:     Josh Poimboeuf <jpoimboe@redhat.com>
CommitterDate: Mon, 24 Jan 2022 10:09:06 -08:00

objtool: Fix truncated string warning

On GCC 12, the build fails due to a possible truncated string:

    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);
          |                                                          ^~

In theory it's a valid bug:

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

There are only 7 chars for %d while it could take up to 9, so the
printed "pv_ops[%d]" string could get truncated.

In reality the bug should never happen, because pv_ops only has ~80
entries, so 7 chars for the integer is more than enough.  Still, it's
worth fixing.  Bump the buffer size by 2 bytes to silence the warning.

[ jpoimboe: changed size to 19; massaged changelog ]

Fixes: db2b0c5d7b6f ("objtool: Support pv_opsindirect calls for noinstr")
Reported-by: Adam Borowski <kilobyte@angband.pl>
Reported-by: Martin Liška <mliska@suse.cz>
Signed-off-by: Sergei Trofimovich <slyich@gmail.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20220120233748.2062559-1-slyich@gmail.com
---
 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 c2d2ab9..7c33ec6 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[19];
 	struct reloc *rel;
 	int idx;
 

      reply	other threads:[~2022-01-31 12:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-14  7:57 [PATCH] objtool: check: give big enough buffer for pv_ops Sergei Trofimovich
2022-01-14  8:53 ` 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-bot2 for Sergei Trofimovich [this message]

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=164363069582.16921.3459888464931150219.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=jpoimboe@redhat.com \
    --cc=kilobyte@angband.pl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mliska@suse.cz \
    --cc=slyich@gmail.com \
    --cc=x86@kernel.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.