Project

General

Profile

Actions

Bug #14395

open

zfs: array subscript is partly outside array bounds

Added by Toomas Soome 9 days ago. Updated 9 days ago.

Status:
In Progress
Priority:
Normal
Assignee:
Category:
zfs - Zettabyte File System
Start date:
Due date:
% Done:

90%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

Build errors with gcc 11:

    In file included from ../../common/fs/zfs/sys/zfs_context.h:58,
                     from ../../common/fs/zfs/sys/dmu.h:48,
                     from ../../common/fs/zfs/sys/zio_crypt.h:23,
                     from ../../common/fs/zfs/zio_crypt.c:20:
    ../../common/fs/zfs/zio_crypt.c: In function 'zio_crypt_do_dnode_hmac_updates':
    ../../common/fs/zfs/zio_crypt.c:1073:54: error: array subscript 'dnode_phys_t {aka struct dnode_phys}[0]' is partly outside array bounds of 'uint8_t[64]' {aka 'unsigned char[64]'} [-Werror=array-bounds]
     1073 |                 adnp->dn_datablkszsec = BSWAP_16(adnp->dn_datablkszsec);
          |                                                      ^~
    ../../common/sys/byteorder.h:115:31: note: in definition of macro 'BSWAP_16'
      115 | #define BSWAP_16(x)     htons(x)
          |                               ^
    ../../common/fs/zfs/zio_crypt.c:1064:17: note: while referencing 'tmp_dncore'
     1064 |         uint8_t tmp_dncore[offsetof(dnode_phys_t, dn_blkptr)];
          |                 ^~~~~~~~~~
    ../../common/fs/zfs/zio_crypt.c:1073:21: error: array subscript 'dnode_phys_t {aka struct dnode_phys}[0]' is partly outside array bounds of 'uint8_t[64]' {aka 'unsigned char[64]'} [-Werror=array-bounds]
     1073 |                 adnp->dn_datablkszsec = BSWAP_16(adnp->dn_datablkszsec);
          |                     ^~
    ../../common/fs/zfs/zio_crypt.c:1064:17: note: while referencing 'tmp_dncore'
     1064 |         uint8_t tmp_dncore[offsetof(dnode_phys_t, dn_blkptr)];
          |                 ^~~~~~~~~~
    In file included from ../../common/fs/zfs/sys/zfs_context.h:58,
                     from ../../common/fs/zfs/sys/dmu.h:48,
                     from ../../common/fs/zfs/sys/zio_crypt.h:23,
                     from ../../common/fs/zfs/zio_crypt.c:20:
    ../../common/fs/zfs/zio_crypt.c:1074:50: error: array subscript 'dnode_phys_t {aka struct dnode_phys}[0]' is partly outside array bounds of 'uint8_t[64]' {aka 'unsigned char[64]'} [-Werror=array-bounds]
     1074 |                 adnp->dn_bonuslen = BSWAP_16(adnp->dn_bonuslen);
          |                                                  ^~
    ../../common/sys/byteorder.h:115:31: note: in definition of macro 'BSWAP_16'
      115 | #define BSWAP_16(x)     htons(x)
          |                               ^
    ../../common/fs/zfs/zio_crypt.c:1064:17: note: while referencing 'tmp_dncore'
     1064 |         uint8_t tmp_dncore[offsetof(dnode_phys_t, dn_blkptr)];
          |                 ^~~~~~~~~~
    ../../common/fs/zfs/zio_crypt.c:1074:21: error: array subscript 'dnode_phys_t {aka struct dnode_phys}[0]' is partly outside array bounds of 'uint8_t[64]' {aka 'unsigned char[64]'} [-Werror=array-bounds]
     1074 |                 adnp->dn_bonuslen = BSWAP_16(adnp->dn_bonuslen);
          |                     ^~
    ../../common/fs/zfs/zio_crypt.c:1064:17: note: while referencing 'tmp_dncore'
     1064 |         uint8_t tmp_dncore[offsetof(dnode_phys_t, dn_blkptr)];
          |                 ^~~~~~~~~~
    In file included from ../../common/fs/zfs/sys/zfs_context.h:58,
                     from ../../common/fs/zfs/sys/dmu.h:48,
                     from ../../common/fs/zfs/sys/zio_crypt.h:23,
                     from ../../common/fs/zfs/zio_crypt.c:20:
    ../../common/fs/zfs/zio_crypt.c:1075:50: error: array subscript 'dnode_phys_t {aka struct dnode_phys}[0]' is partly outside array bounds of 'uint8_t[64]' {aka 'unsigned char[64]'} [-Werror=array-bounds]
     1075 |                 adnp->dn_maxblkid = BSWAP_64(adnp->dn_maxblkid);
          |                                                  ^~
    ../../common/sys/byteorder.h:130:32: note: in definition of macro 'BSWAP_64'
      130 | #define BSWAP_64(x)     htonll(x)
          |                                ^
    ../../common/fs/zfs/zio_crypt.c:1064:17: note: while referencing 'tmp_dncore'
     1064 |         uint8_t tmp_dncore[offsetof(dnode_phys_t, dn_blkptr)];
          |                 ^~~~~~~~~~
    ../../common/fs/zfs/zio_crypt.c:1075:21: error: array subscript 'dnode_phys_t {aka struct dnode_phys}[0]' is partly outside array bounds of 'uint8_t[64]' {aka 'unsigned char[64]'} [-Werror=array-bounds]
     1075 |                 adnp->dn_maxblkid = BSWAP_64(adnp->dn_maxblkid);
          |                     ^~
    ../../common/fs/zfs/zio_crypt.c:1064:17: note: while referencing 'tmp_dncore'
     1064 |         uint8_t tmp_dncore[offsetof(dnode_phys_t, dn_blkptr)];
          |                 ^~~~~~~~~~
    In file included from ../../common/fs/zfs/sys/zfs_context.h:58,
                     from ../../common/fs/zfs/sys/dmu.h:48,
                     from ../../common/fs/zfs/sys/zio_crypt.h:23,
                     from ../../common/fs/zfs/zio_crypt.c:20:
    ../../common/fs/zfs/zio_crypt.c:1076:46: error: array subscript 'dnode_phys_t {aka struct dnode_phys}[0]' is partly outside array bounds of 'uint8_t[64]' {aka 'unsigned char[64]'} [-Werror=array-bounds]
     1076 |                 adnp->dn_used = BSWAP_64(adnp->dn_used);
          |                                              ^~
    ../../common/sys/byteorder.h:130:32: note: in definition of macro 'BSWAP_64'
      130 | #define BSWAP_64(x)     htonll(x)
          |                                ^
    ../../common/fs/zfs/zio_crypt.c:1064:17: note: while referencing 'tmp_dncore'
     1064 |         uint8_t tmp_dncore[offsetof(dnode_phys_t, dn_blkptr)];
          |                 ^~~~~~~~~~
    ../../common/fs/zfs/zio_crypt.c:1078:24: error: array subscript 'dnode_phys_t {aka struct dnode_phys}[0]' is partly outside array bounds of 'uint8_t[64]' {aka 'unsigned char[64]'} [-Werror=array-bounds]
     1078 |         adnp->dn_flags &= DNODE_CRYPT_PORTABLE_FLAGS_MASK;
          |                        ^~
    ../../common/fs/zfs/zio_crypt.c:1064:17: note: while referencing 'tmp_dncore'
     1064 |         uint8_t tmp_dncore[offsetof(dnode_phys_t, dn_blkptr)];
          |                 ^~~~~~~~~~
    ../../common/fs/zfs/zio_crypt.c:1078:24: error: array subscript 'dnode_phys_t {aka struct dnode_phys}[0]' is partly outside array bounds of 'uint8_t[64]' {aka 'unsigned char[64]'} [-Werror=array-bounds]
     1078 |         adnp->dn_flags &= DNODE_CRYPT_PORTABLE_FLAGS_MASK;
    ../../common/fs/zfs/zio_crypt.c:1064:17: note: while referencing 'tmp_dncore'
     1064 |         uint8_t tmp_dncore[offsetof(dnode_phys_t, dn_blkptr)];
          |                 ^~~~~~~~~~
    ../../common/fs/zfs/zio_crypt.c:1079:13: error: array subscript 'dnode_phys_t {aka struct dnode_phys}[0]' is partly outside array bounds of 'uint8_t[64]' {aka 'unsigned char[64]'} [-Werror=array-bounds]
     1079 |         adnp->dn_used = 0;
          |             ^~
    ../../common/fs/zfs/zio_crypt.c:1064:17: note: while referencing 'tmp_dncore'
     1064 |         uint8_t tmp_dncore[offsetof(dnode_phys_t, dn_blkptr)];
          |                 ^~~~~~~~~~
    cc1: all warnings being treated as errors

The problem is similar as with few previous issues: we do have large structure, but need only part of its content, so the code does use smaller memory area for this struct. Compiler does not like it.

I really do not want to silence this one, but the problem is, the solution to use full 'struct dnode_phys' may hurt linux, which is known to have problems with large stack allocations.

Actions #1

Updated by Electric Monk 9 days ago

  • Gerrit CR set to 1943
Actions

Also available in: Atom PDF