From: Christoph Hellwig <hch@infradead.org>
To: Yongpeng Yang <yangyongpeng.storage@gmail.com>
Cc: Christoph Hellwig <hch@infradead.org>,
Eric Biggers <ebiggers@kernel.org>,
Jaegeuk Kim <jaegeuk@kernel.org>, Theodore Ts'o <tytso@mit.edu>,
linux-fscrypt@vger.kernel.org,
Yongpeng Yang <yangyongpeng@xiaomi.com>,
linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org,
Luis Chamberlain <mcgrof@kernel.org>
Subject: Re: [PATCH v2] fscrypt: fix left shift underflow when inode->i_blkbits > PAGE_SHIFT
Date: Wed, 5 Nov 2025 05:38:18 -0800 [thread overview]
Message-ID: <aQtTSsthjYzsv66t@infradead.org> (raw)
In-Reply-To: <b8f06e62-27dc-462e-83ad-33b179daf8a2@gmail.com>
On Tue, Nov 04, 2025 at 11:05:49PM +0800, Yongpeng Yang wrote:
> On 11/4/2025 7:12 PM, Christoph Hellwig wrote:
> > On Mon, Nov 03, 2025 at 08:48:29AM -0800, Eric Biggers wrote:
> > > > *inode_ret = inode;
> > > > - *lblk_num_ret = ((u64)folio->index << (PAGE_SHIFT - inode->i_blkbits)) +
> > > > + *lblk_num_ret = (((u64)folio->index << PAGE_SHIFT) >> inode->i_blkbits) +
> >
> > This should be using folio_pos() instead of open coding the arithmetics.
> >
>
> How about this modification: using "<< PAGE_SHIFT" instead of "* PAGE_SIZE"
> for page_offset and folio_pos?
Any decent compiler turns a multiplication by a compіle time fixed
power of two constant in shifts, so why bother?
(and yes, I just double checked this happens here)
next prev parent reply other threads:[~2025-11-05 13:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-30 7:29 [PATCH v2] fscrypt: fix left shift underflow when inode->i_blkbits > PAGE_SHIFT Yongpeng Yang
2025-11-03 16:48 ` Eric Biggers
2025-11-04 11:12 ` Christoph Hellwig
2025-11-04 15:05 ` Yongpeng Yang
2025-11-05 13:38 ` Christoph Hellwig [this message]
2025-11-04 18:10 ` Eric Biggers
2025-11-05 13:40 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aQtTSsthjYzsv66t@infradead.org \
--to=hch@infradead.org \
--cc=ebiggers@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=tytso@mit.edu \
--cc=yangyongpeng.storage@gmail.com \
--cc=yangyongpeng@xiaomi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).