• Luis Henriques's avatar
    ceph: fix directories inode i_blkbits initialization · 75067034
    Luis Henriques authored
    When filling an inode with info from the MDS, i_blkbits is being
    initialized using fl_stripe_unit, which contains the stripe unit in
    bytes.  Unfortunately, this doesn't make sense for directories as they
    have fl_stripe_unit set to '0'.  This means that i_blkbits will be set
    to 0xff, causing an UBSAN undefined behaviour in i_blocksize():
    
      UBSAN: Undefined behaviour in ./include/linux/fs.h:731:12
      shift exponent 255 is too large for 32-bit type 'int'
    
    Fix this by initializing i_blkbits to CEPH_BLOCK_SHIFT if fl_stripe_unit
    is zero.
    Signed-off-by: default avatarLuis Henriques <lhenriques@suse.com>
    Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
    Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
    75067034
inode.c 65.1 KB