1. 31 Jul, 2023 1 commit
    • Gustavo A. R. Silva's avatar
      fs: omfs: Use flexible-array member in struct omfs_extent · 4d8cbf6d
      Gustavo A. R. Silva authored
      Memory for 'struct omfs_extent' and a 'e_extent_count' number of extent
      entries is indirectly allocated through 'bh->b_data', which is a pointer
      to data within the page. This implies that the member 'e_entry'
      (which is the start of extent entries) functions more like an array than
      a single object of type 'struct omfs_extent_entry'.
      
      So we better turn this object into a proper array, in this case a
      flexible-array member, and with that, fix the following
      -Wstringop-overflow warning seen after building s390 architecture with
      allyesconfig (GCC 13):
      
      fs/omfs/file.c: In function 'omfs_grow_extent':
      include/linux/fortify-string.h:57:33: warning: writing 16 bytes into a region of size 0 [-Wstringop-overflow=]
         57 | #define __underlying_memcpy     __builtin_memcpy
            |                                 ^
      include/linux/fortify-string.h:648:9: note: in expansion of macro '__underlying_memcpy'
        648 |         __underlying_##op(p, q, __fortify_size);                        \
            |         ^~~~~~~~~~~~~
      include/linux/fortify-string.h:693:26: note: in expansion of macro '__fortify_memcpy_chk'
        693 | #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
            |                          ^~~~~~~~~~~~~~~~~~~~
      fs/omfs/file.c:170:9: note: in expansion of macro 'memcpy'
        170 |         memcpy(terminator, entry, sizeof(struct omfs_extent_entry));
            |         ^~~~~~
      In file included from fs/omfs/omfs.h:8,
                       from fs/omfs/file.c:11:
      fs/omfs/omfs_fs.h:80:34: note: at offset 16 into destination object 'e_entry' of size 16
         80 |         struct omfs_extent_entry e_entry;       /* start of extent entries */
            |                                  ^~~~~~~
      
      There are some binary differences before and after changes, but this are
      expected due to the change in the size of 'struct omfs_extent' and the
      necessary adjusments.
      
      This helps with the ongoing efforts to globally enable
      -Wstringop-overflow.
      
      Link: https://github.com/KSPP/linux/issues/330Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      4d8cbf6d
  2. 12 Jul, 2023 2 commits
    • Gustavo A. R. Silva's avatar
      sparc: openpromio: Address -Warray-bounds warning · 221a4b56
      Gustavo A. R. Silva authored
      One-element arrays are deprecated, and we are replacing them with flexible
      array members instead. So, replace one-element array with flexible-array
      member in struct openpromio.
      
      Address the following warning found after building (with GCC-13) sparc
      with sparc64_defconfig:
      In function 'opromgetprop',
          inlined from 'openprom_sunos_ioctl.isra' at drivers/sbus/char/openprom.c:312:11:
      drivers/sbus/char/openprom.c:141:24: warning: array subscript 1 is above array bounds of 'char[1]' [-Warray-bounds=]
        141 |         op->oprom_array[len] = '\0';
            |         ~~~~~~~~~~~~~~~^~~~~
      In file included from drivers/sbus/char/openprom.c:31:
      arch/sparc/include/uapi/asm/openpromio.h: In function 'openprom_sunos_ioctl.isra':
      arch/sparc/include/uapi/asm/openpromio.h:16:17: note: while referencing 'oprom_array'
         16 |         char    oprom_array[1];         /* Holds property names and values. */
            |                 ^~~~~~~~~~~
      
      This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
      routines on memcpy() and help us make progress towards globally
      enabling -Warray-bounds.
      
      This results in no differences in binary output.
      
      Link: https://github.com/KSPP/linux/issues/79
      Link: https://github.com/KSPP/linux/issues/322Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      221a4b56
    • Gustavo A. R. Silva's avatar
      reiserfs: Replace one-element array with flexible-array member · 76d2ceda
      Gustavo A. R. Silva authored
      One-element arrays are deprecated, and we are replacing them with flexible
      array members instead. So, replace one-element array with flexible-array
      member in direntry_uarea structure, and refactor the rest of the code,
      accordingly.
      
      Worth mentioning is that before these changes, the original implementation
      was returning two-too many bytes in function direntry_create_vi():
      
      fs/reiserfs/item_ops.c:464:     int size = sizeof(struct direntry_uarea);
      ...
      fs/reiserfs/item_ops.c-490-     size += (dir_u->entry_count * sizeof(short));
      ...
      fs/reiserfs/item_ops.c-517-     return size;
      
      Link: https://github.com/KSPP/linux/issues/79
      Link: https://github.com/KSPP/linux/issues/290Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      76d2ceda
  3. 09 Jul, 2023 10 commits
  4. 08 Jul, 2023 27 commits