Patch "objtool: Fix truncated string warning" has been added to the 5.16-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    objtool: Fix truncated string warning

to the 5.16-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     objtool-fix-truncated-string-warning.patch
and it can be found in the queue-5.16 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit e35cef4d73ba2656dd8850a49ab0c3b3e05262d5
Author: Sergei Trofimovich <slyich@xxxxxxxxx>
Date:   Thu Jan 20 23:37:48 2022 +0000

    objtool: Fix truncated string warning
    
    [ Upstream commit 82880283d7fcd0a1d20964a56d6d1a5cc0df0713 ]
    
    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@xxxxxxxxxx>
    Reported-by: Martin Liška <mliska@xxxxxxx>
    Signed-off-by: Sergei Trofimovich <slyich@xxxxxxxxx>
    Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20220120233748.2062559-1-slyich@xxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 21735829b860c..750ef1c446c8a 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[19];
 	struct reloc *rel;
 	int idx;
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux