• Kees Cook's avatar
    jfs: Use unsigned variable for length calculations · 820eb59d
    Kees Cook authored
    To avoid confusing the compiler about possible negative sizes, switch
    "ssize" which can never be negative from int to u32.  Seen with GCC 13:
    
    ../fs/jfs/namei.c: In function 'jfs_symlink': ../include/linux/fortify-string.h:57:33: warning: '__builtin_memcpy' pointer overflow between offset 0 and size [-2147483648, -1]
    [-Warray-bounds=]
       57 | #define __underlying_memcpy     __builtin_memcpy
          |                                 ^
    ...
    ../fs/jfs/namei.c:950:17: note: in expansion of macro 'memcpy'
      950 |                 memcpy(ip->i_link, name, ssize);
          |                 ^~~~~~
    
    Cc: Dave Kleikamp <shaggy@kernel.org>
    Cc: Christian Brauner <brauner@kernel.org>
    Cc: Dave Chinner <dchinner@redhat.com>
    Cc: jfs-discussion@lists.sourceforge.net
    Signed-off-by: default avatarKees Cook <keescook@chromium.org>
    Acked-by: default avatarJeff Xu <jeffxu@chromium.org>
    Message-Id: <20230204183355.never.877-kees@kernel.org>
    Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
    820eb59d
namei.c 36.7 KB