objtool: check: give big enough buffer for pv_ops
authorSergei Trofimovich <slyich@gmail.com>
Thu, 20 Jan 2022 23:37:48 +0000 (23:37 +0000)
committerSalvatore Bonaccorso <carnil@debian.org>
Wed, 9 Feb 2022 08:35:55 +0000 (08:35 +0000)
commit7fdd101d9024dcf6764fc273cfd16d554e707c33
tree697db347de0f26c1d762be6dbdb6f53a36cb3d1d
parentb1a7bd9ddcd03ee65f00967950437776c14493d4
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 <jpoimboe@redhat.com>
CC: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Sergei Trofimovich <slyich@gmail.com>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name objtool-check-give-big-enough-buffer-for-pv_ops.patch
tools/objtool/check.c