From: Jens Axboe <axboe@kernel.dk>
To: david.laight.linux@gmail.com, linux-kernel@vger.kernel.org,
io-uring@vger.kernel.org
Subject: Re: [PATCH 04/44] io_uring/net: Change some dubious min_t()
Date: Thu, 20 Nov 2025 07:48:58 -0700 [thread overview]
Message-ID: <3202c47d-532d-4c74-aff9-992ec1d9cbeb@kernel.dk> (raw)
In-Reply-To: <20251119224140.8616-5-david.laight.linux@gmail.com>
On 11/19/25 3:41 PM, david.laight.linux@gmail.com wrote:
> From: David Laight <david.laight.linux@gmail.com>
>
> Since iov_len is 'unsigned long' it is possible that the cast
> to 'int' will change the value of min_t(int, iov[nbufs].iov_len, ret).
> Use a plain min() and change the loop bottom to while (ret > 0) so that
> the compiler knows 'ret' is always positive.
>
> Also change min_t(int, sel->val, sr->mshot_total_len) to a simple min()
> since sel->val is also long and subject to possible trunctation.
>
> It might be that other checks stop these being problems, but they are
> picked up by some compile-time tests for min_t() truncating values.
Fails with clang-21:
io_uring/net.c:855:26: error: call to '__compiletime_assert_2006' declared with 'error' attribute: min(sel->val, sr->mshot_total_len) signedness error
855 | sr->mshot_total_len -= min(sel->val, sr->mshot_total_len);
| ^
./include/linux/minmax.h:105:19: note: expanded from macro 'min'
105 | #define min(x, y) __careful_cmp(min, x, y)
| ^
./include/linux/minmax.h:98:2: note: expanded from macro '__careful_cmp'
98 | __careful_cmp_once(op, x, y, __UNIQUE_ID(x_), __UNIQUE_ID(y_))
| ^
./include/linux/minmax.h:93:2: note: expanded from macro '__careful_cmp_once'
93 | BUILD_BUG_ON_MSG(!__types_ok(ux, uy), \
| ^
note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
././include/linux/compiler_types.h:590:2: note: expanded from macro '_compiletime_assert'
590 | __compiletime_assert(condition, msg, prefix, suffix)
| ^
././include/linux/compiler_types.h:583:4: note: expanded from macro '__compiletime_assert'
583 | prefix ## suffix(); \
| ^
<scratch space>:319:1: note: expanded from here
319 | __compiletime_assert_2006
| ^
--
Jens Axboe
next prev parent reply other threads:[~2025-11-20 14:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-19 22:40 [PATCH 00/44] Change a lot of min_t() that might mask high bits david.laight.linux
2025-11-19 22:41 ` [PATCH 04/44] io_uring/net: Change some dubious min_t() david.laight.linux
2025-11-20 14:48 ` Jens Axboe [this message]
2025-11-20 15:48 ` David Laight
2025-11-20 15:53 ` Jens Axboe
2025-11-22 11:31 ` David Laight
2025-11-20 1:47 ` [PATCH 00/44] Change a lot of min_t() that might mask high bits Jakub Kicinski
2025-11-20 9:38 ` Lorenzo Stoakes
2025-11-20 14:52 ` (subset) " Jens Axboe
2025-11-24 9:49 ` Herbert Xu
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=3202c47d-532d-4c74-aff9-992ec1d9cbeb@kernel.dk \
--to=axboe@kernel.dk \
--cc=david.laight.linux@gmail.com \
--cc=io-uring@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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