fscrypt fix for v6.18-rc5

Fix an UBSAN warning that started occurring when the block layer started
 supporting logical_block_size > PAGE_SIZE.
 -----BEGIN PGP SIGNATURE-----
 
 iIoEABYIADIWIQSacvsUNc7UX4ntmEPzXCl4vpKOKwUCaQ0DUxQcZWJpZ2dlcnNA
 a2VybmVsLm9yZwAKCRDzXCl4vpKOK0E/AQDUd4N4YJ1D/vUcQXjtHnH6lkSMSRgo
 ZDJmoZcwSI+28QEA31Lvjs3G1heMSpKCTcz/+C7FLwM35+9e/ZUA5z+0fQg=
 =fPMw
 -----END PGP SIGNATURE-----

Merge tag 'fscrypt-for-linus' of git://git.kernel.org/pub/scm/fs/fscrypt/linux

Pull fscrypt fix from Eric Biggers:
 "Fix an UBSAN warning that started occurring when the block layer
  started supporting logical_block_size > PAGE_SIZE"

* tag 'fscrypt-for-linus' of git://git.kernel.org/pub/scm/fs/fscrypt/linux:
  fscrypt: fix left shift underflow when inode->i_blkbits > PAGE_SHIFT
This commit is contained in:
Linus Torvalds 2025-11-06 12:45:15 -08:00
commit c668da99b9
1 changed files with 1 additions and 2 deletions

View File

@ -333,8 +333,7 @@ static bool bh_get_inode_and_lblk_num(const struct buffer_head *bh,
inode = mapping->host;
*inode_ret = inode;
*lblk_num_ret = ((u64)folio->index << (PAGE_SHIFT - inode->i_blkbits)) +
(bh_offset(bh) >> inode->i_blkbits);
*lblk_num_ret = (folio_pos(folio) + bh_offset(bh)) >> inode->i_blkbits;
return true;
}