From: David Laight <david.laight.linux@gmail.com>
To: kernel test robot <lkp@intel.com>
Cc: oe-kbuild-all@lists.linux.dev,
Christian Brauner <brauner@kernel.org>,
linux-fsdevel@vger.kernel.org, miklos@szeredi.hu
Subject: Re: [linux-next:master 1617/1848] include/linux/compiler_types.h:630:45: error: call to '__compiletime_assert_612' declared with attribute error: min(((pos + len - 1) >> 12) - (pos >> 12) + 1, max_pages) signedness error
Date: Tue, 16 Dec 2025 11:02:59 +0000 [thread overview]
Message-ID: <20251216110259.60c84f61@pumpkin> (raw)
In-Reply-To: <202512160948.O7QqxHj2-lkp@intel.com>
On Tue, 16 Dec 2025 09:05:42 +0100
kernel test robot <lkp@intel.com> wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> head: 563c8dd425b59e44470e28519107b1efc99f4c7b
> commit: 0f5bb0cfb0b40a31d2fe146ecbef5727690fa547 [1617/1848] fs: use min() or umin() instead of min_t()
> config: i386-randconfig-2006-20250825 (https://download.01.org/0day-ci/archive/20251216/202512160948.O7QqxHj2-lkp@intel.com/config)
> compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251216/202512160948.O7QqxHj2-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202512160948.O7QqxHj2-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
> In file included from <command-line>:
> In function 'fuse_wr_pages',
> inlined from 'fuse_perform_write' at fs/fuse/file.c:1347:27:
> >> include/linux/compiler_types.h:630:45: error: call to '__compiletime_assert_612' declared with attribute error: min(((pos + len - 1) >> 12) - (pos >> 12) + 1, max_pages) signedness error
...
The definitions are:
loff_t pos - 64bit signed.
size_t len - unsigned long, 32bit for this i386 build.
unsigned int max_pages - 32 bit unsigned.
On a 64bit build 'len' is 64bits unsigned which promotes the LHS to
unsigned and min() is happy.
On a 32bit build this doesn't happen, the LHS remains signed and
min() is unhappy.
I'm not sure why file offsets are signed (apart from relative lseek()),
causes signedness issues in a few places.
In any case there are a few ways to fix this.
Clearly a cast could be used somewhere, the most subtle would be changing
the prototype to 'u64 len'.
Perhaps better is rewriting the conditional as:
min(((len + (pos & (PAGE_SIZE - 1)) - 1) >> PAGE_SHIFT) + 1,
max_pages);
Although the LHS is still signed 64bit, the compiler knows it can't
be negative.
This still contains a lot of 64bit maths, adding a cast:
min(((len + (size_t)(pos & (PAGE_SIZE - 1)) - 1) >> PAGE_SHIFT) + 1,
makes it 32bit and the generated code much, much better.
In theory the expression can overflow (fixable by masking off the high bit
of 'len' (eg (len << 1 >> 1)), but normal IO are limited to MAX_RW_COUNT
(INT_MAX & PAGE_MASK) even on 64bit.
I'm not sure io_uring enforces that limit (it should, a lot of drivers are
broken if the requested size exceeds 4G).
David
parent reply other threads:[~2025-12-16 12:51 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <202512160948.O7QqxHj2-lkp@intel.com>]
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=20251216110259.60c84f61@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=miklos@szeredi.hu \
--cc=oe-kbuild-all@lists.linux.dev \
/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).