* Re: [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative()
2025-12-20 11:02 ` [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative() Vincent Mailhol
@ 2025-12-20 12:52 ` Nicolas Schier
2025-12-22 10:03 ` kernel test robot
` (5 subsequent siblings)
6 siblings, 0 replies; 21+ messages in thread
From: Nicolas Schier @ 2025-12-20 12:52 UTC (permalink / raw)
To: Vincent Mailhol
Cc: Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Chris Mason, David Sterba, Kees Cook,
Gustavo A. R. Silva, Linus Torvalds, linux-kbuild, linux-sparse,
linux-kernel, llvm, dri-devel, linux-btrfs, linux-hardening
On Sat, Dec 20, 2025 at 12:02:21PM +0100, Vincent Mailhol wrote:
> The is_non_negative() and is_negative() function-like macros just
> exist as a workaround to silence the -Wtype-limits warning. Now that
> this warning is disabled, those two macros have lost their raison
> d'être. Remove them.
>
> This reverts commit dc7fe518b049 ("overflow: Fix -Wtype-limits
> compilation warnings").
>
> Suggested-by: Nicolas Schier <nsc@kernel.org>
> Link: https://lore.kernel.org/all/aUT_yWin_xslnOFh@derry.ads.avm.de
> Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
> ---
> Changelog:
>
> v1 -> v2: new patch
> ---
> include/linux/overflow.h | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
>
Thanks!
Reviewed-by: Nicolas Schier <nsc@kernel.org>
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative()
2025-12-20 11:02 ` [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative() Vincent Mailhol
2025-12-20 12:52 ` Nicolas Schier
@ 2025-12-22 10:03 ` kernel test robot
2025-12-22 18:39 ` Vincent Mailhol
2025-12-22 19:55 ` kernel test robot
` (4 subsequent siblings)
6 siblings, 1 reply; 21+ messages in thread
From: kernel test robot @ 2025-12-22 10:03 UTC (permalink / raw)
To: Vincent Mailhol, Nathan Chancellor, Nicolas Schier,
Nick Desaulniers, Bill Wendling, Justin Stitt, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chris Mason, David Sterba, Kees Cook, Gustavo A. R. Silva
Cc: oe-kbuild-all, linux-kbuild, linux-sparse, linux-kernel, llvm,
dri-devel, linux-btrfs, linux-hardening, Vincent Mailhol
Hi Vincent,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 3e7f562e20ee87a25e104ef4fce557d39d62fa85]
url: https://github.com/intel-lab-lkp/linux/commits/Vincent-Mailhol/kbuild-remove-gcc-s-Wtype-limits/20251220-190509
base: 3e7f562e20ee87a25e104ef4fce557d39d62fa85
patch link: https://lore.kernel.org/r/20251220-remove_wtype-limits-v3-3-24b170af700e%40kernel.org
patch subject: [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative()
config: x86_64-randconfig-161-20251222 (https://download.01.org/0day-ci/archive/20251222/202512221735.mRV4BZqB-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
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/202512221735.mRV4BZqB-lkp@intel.com/
smatch warnings:
fs/libfs.c:1628 generic_check_addressable() warn: unsigned '*_d' is never less than zero.
fs/libfs.c:1628 generic_check_addressable() warn: unsigned '_a' is never less than zero.
mm/vmalloc.c:4708 remap_vmalloc_range_partial() warn: unsigned '*_d' is never less than zero.
mm/vmalloc.c:4708 remap_vmalloc_range_partial() warn: unsigned '_a' is never less than zero.
vim +1628 fs/libfs.c
1b061d9247f71c Christoph Hellwig 2010-05-26 1613
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1614 /**
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1615 * generic_check_addressable - Check addressability of file system
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1616 * @blocksize_bits: log of file system block size
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1617 * @num_blocks: number of blocks in file system
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1618 *
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1619 * Determine whether a file system with @num_blocks blocks (and a
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1620 * block size of 2**@blocksize_bits) is addressable by the sector_t
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1621 * and page cache of the system. Return 0 if so and -EFBIG otherwise.
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1622 */
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1623 int generic_check_addressable(unsigned blocksize_bits, u64 num_blocks)
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1624 {
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1625 u64 last_fs_block = num_blocks - 1;
25050181b61aa0 Pankaj Raghav 2025-06-30 1626 u64 last_fs_page, max_bytes;
25050181b61aa0 Pankaj Raghav 2025-06-30 1627
25050181b61aa0 Pankaj Raghav 2025-06-30 @1628 if (check_shl_overflow(num_blocks, blocksize_bits, &max_bytes))
25050181b61aa0 Pankaj Raghav 2025-06-30 1629 return -EFBIG;
25050181b61aa0 Pankaj Raghav 2025-06-30 1630
25050181b61aa0 Pankaj Raghav 2025-06-30 1631 last_fs_page = (max_bytes >> PAGE_SHIFT) - 1;
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1632
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1633 if (unlikely(num_blocks == 0))
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1634 return 0;
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1635
25050181b61aa0 Pankaj Raghav 2025-06-30 1636 if (blocksize_bits < 9)
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1637 return -EINVAL;
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1638
a33f13efe05192 Joel Becker 2010-08-16 1639 if ((last_fs_block > (sector_t)(~0ULL) >> (blocksize_bits - 9)) ||
a33f13efe05192 Joel Becker 2010-08-16 1640 (last_fs_page > (pgoff_t)(~0ULL))) {
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1641 return -EFBIG;
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1642 }
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1643 return 0;
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1644 }
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1645 EXPORT_SYMBOL(generic_check_addressable);
30ca22c70e3ef0 Patrick J. LoPresti 2010-07-22 1646
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative()
2025-12-22 10:03 ` kernel test robot
@ 2025-12-22 18:39 ` Vincent Mailhol
0 siblings, 0 replies; 21+ messages in thread
From: Vincent Mailhol @ 2025-12-22 18:39 UTC (permalink / raw)
To: kernel test robot, Nathan Chancellor, Nicolas Schier,
Nick Desaulniers, Bill Wendling, Justin Stitt, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chris Mason, David Sterba, Kees Cook, Gustavo A. R. Silva
Cc: oe-kbuild-all, linux-kbuild, linux-sparse, linux-kernel, llvm,
dri-devel, linux-btrfs, linux-hardening
On 22/12/2025 at 11:03, kernel test robot wrote:
> Hi Vincent,
>
> kernel test robot noticed the following build warnings:
>
> [auto build test WARNING on 3e7f562e20ee87a25e104ef4fce557d39d62fa85]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Vincent-Mailhol/kbuild-remove-gcc-s-Wtype-limits/20251220-190509
> base: 3e7f562e20ee87a25e104ef4fce557d39d62fa85
> patch link: https://lore.kernel.org/r/20251220-remove_wtype-limits-v3-3-24b170af700e%40kernel.org
> patch subject: [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative()
> config: x86_64-randconfig-161-20251222 (https://download.01.org/0day-ci/archive/20251222/202512221735.mRV4BZqB-lkp@intel.com/config)
> compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
>
> 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/202512221735.mRV4BZqB-lkp@intel.com/
>
> smatch warnings:
> fs/libfs.c:1628 generic_check_addressable() warn: unsigned '*_d' is never less than zero.
> fs/libfs.c:1628 generic_check_addressable() warn: unsigned '_a' is never less than zero.
> mm/vmalloc.c:4708 remap_vmalloc_range_partial() warn: unsigned '*_d' is never less than zero.
> mm/vmalloc.c:4708 remap_vmalloc_range_partial() warn: unsigned '_a' is never less than zero.
So smatch is not able to distinguish when the comparison comes from
a macro expansion.
Can this warning be ignored? Or should I remove this 3rd patch from
the series (and go back to v1)? My choice would be to ignore this
warning.
Yours sincerely,
Vincent Mailhol
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative()
2025-12-20 11:02 ` [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative() Vincent Mailhol
2025-12-20 12:52 ` Nicolas Schier
2025-12-22 10:03 ` kernel test robot
@ 2025-12-22 19:55 ` kernel test robot
2025-12-25 6:04 ` kernel test robot
` (3 subsequent siblings)
6 siblings, 0 replies; 21+ messages in thread
From: kernel test robot @ 2025-12-22 19:55 UTC (permalink / raw)
To: Vincent Mailhol, Nathan Chancellor, Nicolas Schier,
Nick Desaulniers, Bill Wendling, Justin Stitt, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chris Mason, David Sterba, Kees Cook, Gustavo A. R. Silva
Cc: oe-kbuild-all, linux-kbuild, linux-sparse, linux-kernel, llvm,
dri-devel, linux-btrfs, linux-hardening, Vincent Mailhol
Hi Vincent,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 3e7f562e20ee87a25e104ef4fce557d39d62fa85]
url: https://github.com/intel-lab-lkp/linux/commits/Vincent-Mailhol/kbuild-remove-gcc-s-Wtype-limits/20251220-190509
base: 3e7f562e20ee87a25e104ef4fce557d39d62fa85
patch link: https://lore.kernel.org/r/20251220-remove_wtype-limits-v3-3-24b170af700e%40kernel.org
patch subject: [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative()
config: i386-randconfig-141-20251222 (https://download.01.org/0day-ci/archive/20251223/202512230342.Lgha2HGH-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
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/202512230342.Lgha2HGH-lkp@intel.com/
New smatch warnings:
block/blk-settings.c:702 blk_stack_atomic_writes_chunk_sectors() warn: unsigned '*_d' is never less than zero.
block/blk-settings.c:702 blk_stack_atomic_writes_chunk_sectors() warn: unsigned '_a' is never less than zero.
drivers/nvme/host/core.c:3353 nvme_mps_to_sectors() warn: unsigned '*_d' is never less than zero.
drivers/nvme/host/core.c:3353 nvme_mps_to_sectors() warn: unsigned '_a' is never less than zero.
Old smatch warnings:
drivers/nvme/host/core.c:5032 nvme_free_cels() warn: iterator 'i' not incremented
vim +702 block/blk-settings.c
d7f36dc446e894 John Garry 2024-11-18 689
63d092d1c1b1f7 John Garry 2025-07-11 690 static void blk_stack_atomic_writes_chunk_sectors(struct queue_limits *t)
d7f36dc446e894 John Garry 2024-11-18 691 {
63d092d1c1b1f7 John Garry 2025-07-11 692 unsigned int chunk_bytes;
d7f36dc446e894 John Garry 2024-11-18 693
63d092d1c1b1f7 John Garry 2025-07-11 694 if (!t->chunk_sectors)
63d092d1c1b1f7 John Garry 2025-07-11 695 return;
63d092d1c1b1f7 John Garry 2025-07-11 696
63d092d1c1b1f7 John Garry 2025-07-11 697 /*
63d092d1c1b1f7 John Garry 2025-07-11 698 * If chunk sectors is so large that its value in bytes overflows
63d092d1c1b1f7 John Garry 2025-07-11 699 * UINT_MAX, then just shift it down so it definitely will fit.
63d092d1c1b1f7 John Garry 2025-07-11 700 * We don't support atomic writes of such a large size anyway.
63d092d1c1b1f7 John Garry 2025-07-11 701 */
63d092d1c1b1f7 John Garry 2025-07-11 @702 if (check_shl_overflow(t->chunk_sectors, SECTOR_SHIFT, &chunk_bytes))
63d092d1c1b1f7 John Garry 2025-07-11 703 chunk_bytes = t->chunk_sectors;
d7f36dc446e894 John Garry 2024-11-18 704
d7f36dc446e894 John Garry 2024-11-18 705 /*
d7f36dc446e894 John Garry 2024-11-18 706 * Find values for limits which work for chunk size.
d7f36dc446e894 John Garry 2024-11-18 707 * b->atomic_write_hw_unit_{min, max} may not be aligned with chunk
63d092d1c1b1f7 John Garry 2025-07-11 708 * size, as the chunk size is not restricted to a power-of-2.
d7f36dc446e894 John Garry 2024-11-18 709 * So we need to find highest power-of-2 which works for the chunk
d7f36dc446e894 John Garry 2024-11-18 710 * size.
63d092d1c1b1f7 John Garry 2025-07-11 711 * As an example scenario, we could have t->unit_max = 16K and
63d092d1c1b1f7 John Garry 2025-07-11 712 * t->chunk_sectors = 24KB. For this case, reduce t->unit_max to a
63d092d1c1b1f7 John Garry 2025-07-11 713 * value aligned with both limits, i.e. 8K in this example.
d7f36dc446e894 John Garry 2024-11-18 714 */
63d092d1c1b1f7 John Garry 2025-07-11 715 t->atomic_write_hw_unit_max = min(t->atomic_write_hw_unit_max,
63d092d1c1b1f7 John Garry 2025-07-11 716 max_pow_of_two_factor(chunk_bytes));
d7f36dc446e894 John Garry 2024-11-18 717
63d092d1c1b1f7 John Garry 2025-07-11 718 t->atomic_write_hw_unit_min = min(t->atomic_write_hw_unit_min,
d7f36dc446e894 John Garry 2024-11-18 719 t->atomic_write_hw_unit_max);
63d092d1c1b1f7 John Garry 2025-07-11 720 t->atomic_write_hw_max = min(t->atomic_write_hw_max, chunk_bytes);
63d092d1c1b1f7 John Garry 2025-07-11 721 }
d7f36dc446e894 John Garry 2024-11-18 722
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative()
2025-12-20 11:02 ` [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative() Vincent Mailhol
` (2 preceding siblings ...)
2025-12-22 19:55 ` kernel test robot
@ 2025-12-25 6:04 ` kernel test robot
2025-12-27 8:49 ` kernel test robot
` (2 subsequent siblings)
6 siblings, 0 replies; 21+ messages in thread
From: kernel test robot @ 2025-12-25 6:04 UTC (permalink / raw)
To: Vincent Mailhol, Nathan Chancellor, Nicolas Schier,
Nick Desaulniers, Bill Wendling, Justin Stitt, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chris Mason, David Sterba, Kees Cook, Gustavo A. R. Silva
Cc: oe-kbuild-all, linux-kbuild, linux-sparse, linux-kernel, llvm,
dri-devel, linux-btrfs, linux-hardening, Vincent Mailhol
Hi Vincent,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 3e7f562e20ee87a25e104ef4fce557d39d62fa85]
url: https://github.com/intel-lab-lkp/linux/commits/Vincent-Mailhol/kbuild-remove-gcc-s-Wtype-limits/20251220-190509
base: 3e7f562e20ee87a25e104ef4fce557d39d62fa85
patch link: https://lore.kernel.org/r/20251220-remove_wtype-limits-v3-3-24b170af700e%40kernel.org
patch subject: [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative()
config: i386-randconfig-141-20251225 (https://download.01.org/0day-ci/archive/20251225/202512251340.UApIFw9R-lkp@intel.com/config)
compiler: gcc-13 (Debian 13.3.0-16) 13.3.0
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/202512251340.UApIFw9R-lkp@intel.com/
smatch warnings:
drivers/md/dm-stripe.c:463 stripe_io_hints() warn: unsigned '*_d' is never less than zero.
drivers/md/dm-stripe.c:463 stripe_io_hints() warn: unsigned '_a' is never less than zero.
vim +463 drivers/md/dm-stripe.c
af4874e03ed82f Mike Snitzer 2009-06-22 454
40bea431274c24 Mike Snitzer 2009-09-04 455 static void stripe_io_hints(struct dm_target *ti,
40bea431274c24 Mike Snitzer 2009-09-04 456 struct queue_limits *limits)
40bea431274c24 Mike Snitzer 2009-09-04 457 {
40bea431274c24 Mike Snitzer 2009-09-04 458 struct stripe_c *sc = ti->private;
1071d560afb4c2 Mikulas Patocka 2025-08-11 459 unsigned int io_min, io_opt;
40bea431274c24 Mike Snitzer 2009-09-04 460
5fb9d4341b782a John Garry 2025-07-11 461 limits->chunk_sectors = sc->chunk_size;
1071d560afb4c2 Mikulas Patocka 2025-08-11 462
1071d560afb4c2 Mikulas Patocka 2025-08-11 @463 if (!check_shl_overflow(sc->chunk_size, SECTOR_SHIFT, &io_min) &&
1071d560afb4c2 Mikulas Patocka 2025-08-11 464 !check_mul_overflow(io_min, sc->stripes, &io_opt)) {
1071d560afb4c2 Mikulas Patocka 2025-08-11 465 limits->io_min = io_min;
1071d560afb4c2 Mikulas Patocka 2025-08-11 466 limits->io_opt = io_opt;
1071d560afb4c2 Mikulas Patocka 2025-08-11 467 }
40bea431274c24 Mike Snitzer 2009-09-04 468 }
40bea431274c24 Mike Snitzer 2009-09-04 469
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative()
2025-12-20 11:02 ` [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative() Vincent Mailhol
` (3 preceding siblings ...)
2025-12-25 6:04 ` kernel test robot
@ 2025-12-27 8:49 ` kernel test robot
2025-12-28 1:41 ` kernel test robot
2026-01-01 15:10 ` Vincent Mailhol
6 siblings, 0 replies; 21+ messages in thread
From: kernel test robot @ 2025-12-27 8:49 UTC (permalink / raw)
To: Vincent Mailhol, Nathan Chancellor, Nicolas Schier,
Nick Desaulniers, Bill Wendling, Justin Stitt, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chris Mason, David Sterba, Kees Cook, Gustavo A. R. Silva
Cc: oe-kbuild-all, linux-kbuild, linux-sparse, linux-kernel, llvm,
dri-devel, linux-btrfs, linux-hardening, Vincent Mailhol
Hi Vincent,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 3e7f562e20ee87a25e104ef4fce557d39d62fa85]
url: https://github.com/intel-lab-lkp/linux/commits/Vincent-Mailhol/kbuild-remove-gcc-s-Wtype-limits/20251220-190509
base: 3e7f562e20ee87a25e104ef4fce557d39d62fa85
patch link: https://lore.kernel.org/r/20251220-remove_wtype-limits-v3-3-24b170af700e%40kernel.org
patch subject: [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative()
config: sparc-randconfig-r072-20251227 (https://download.01.org/0day-ci/archive/20251227/202512271618.33YepxDC-lkp@intel.com/config)
compiler: sparc64-linux-gcc (GCC) 15.1.0
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/202512271618.33YepxDC-lkp@intel.com/
smatch warnings:
drivers/block/nbd.c:1612 __nbd_ioctl() warn: unsigned '_a' is never less than zero.
vim +/_a +1612 drivers/block/nbd.c
55313e92bd17a87 Mike Christie 2019-08-13 1591
9442b739207aab6 Josef Bacik 2017-02-07 1592 /* Must be called with config_lock held */
9442b739207aab6 Josef Bacik 2017-02-07 1593 static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
9442b739207aab6 Josef Bacik 2017-02-07 1594 unsigned int cmd, unsigned long arg)
9442b739207aab6 Josef Bacik 2017-02-07 1595 {
5ea8d10802ec4c1 Josef Bacik 2017-04-06 1596 struct nbd_config *config = nbd->config;
fad7cd3310db309 Baokun Li 2021-08-04 1597 loff_t bytesize;
5ea8d10802ec4c1 Josef Bacik 2017-04-06 1598
9442b739207aab6 Josef Bacik 2017-02-07 1599 switch (cmd) {
9442b739207aab6 Josef Bacik 2017-02-07 1600 case NBD_DISCONNECT:
29eaadc0364943b Josef Bacik 2017-04-06 1601 return nbd_disconnect(nbd);
9442b739207aab6 Josef Bacik 2017-02-07 1602 case NBD_CLEAR_SOCK:
0c1c9a27ce909e3 Christoph Hellwig 2023-08-11 1603 nbd_clear_sock_ioctl(nbd);
29eaadc0364943b Josef Bacik 2017-04-06 1604 return 0;
9442b739207aab6 Josef Bacik 2017-02-07 1605 case NBD_SET_SOCK:
e46c7287b1c2768 Josef Bacik 2017-04-06 1606 return nbd_add_socket(nbd, arg, false);
9442b739207aab6 Josef Bacik 2017-02-07 1607 case NBD_SET_BLKSIZE:
dcbddf541f18e36 Christoph Hellwig 2020-11-16 1608 return nbd_set_size(nbd, config->bytesize, arg);
9442b739207aab6 Josef Bacik 2017-02-07 1609 case NBD_SET_SIZE:
41e76c6a3c83c85 Nick Desaulniers 2021-09-20 1610 return nbd_set_size(nbd, arg, nbd_blksize(config));
9442b739207aab6 Josef Bacik 2017-02-07 1611 case NBD_SET_SIZE_BLOCKS:
41e76c6a3c83c85 Nick Desaulniers 2021-09-20 @1612 if (check_shl_overflow(arg, config->blksize_bits, &bytesize))
fad7cd3310db309 Baokun Li 2021-08-04 1613 return -EINVAL;
41e76c6a3c83c85 Nick Desaulniers 2021-09-20 1614 return nbd_set_size(nbd, bytesize, nbd_blksize(config));
9442b739207aab6 Josef Bacik 2017-02-07 1615 case NBD_SET_TIMEOUT:
55313e92bd17a87 Mike Christie 2019-08-13 1616 nbd_set_cmd_timeout(nbd, arg);
9442b739207aab6 Josef Bacik 2017-02-07 1617 return 0;
9442b739207aab6 Josef Bacik 2017-02-07 1618
9442b739207aab6 Josef Bacik 2017-02-07 1619 case NBD_SET_FLAGS:
5ea8d10802ec4c1 Josef Bacik 2017-04-06 1620 config->flags = arg;
9442b739207aab6 Josef Bacik 2017-02-07 1621 return 0;
9442b739207aab6 Josef Bacik 2017-02-07 1622 case NBD_DO_IT:
2a852a693f8839b Christoph Hellwig 2022-03-30 1623 return nbd_start_device_ioctl(nbd);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1624 case NBD_CLEAR_QUE:
4b2f0260c74324a Herbert Xu 2006-01-06 1625 /*
4b2f0260c74324a Herbert Xu 2006-01-06 1626 * This is for compatibility only. The queue is always cleared
4b2f0260c74324a Herbert Xu 2006-01-06 1627 * by NBD_DO_IT or NBD_CLEAR_SOCK.
4b2f0260c74324a Herbert Xu 2006-01-06 1628 */
^1da177e4c3f415 Linus Torvalds 2005-04-16 1629 return 0;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1630 case NBD_PRINT_DEBUG:
fd8383fd88a2fd8 Josef Bacik 2016-09-08 1631 /*
fd8383fd88a2fd8 Josef Bacik 2016-09-08 1632 * For compatibility only, we no longer keep a list of
fd8383fd88a2fd8 Josef Bacik 2016-09-08 1633 * outstanding requests.
fd8383fd88a2fd8 Josef Bacik 2016-09-08 1634 */
^1da177e4c3f415 Linus Torvalds 2005-04-16 1635 return 0;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1636 }
1a2ad21128bb4eb Pavel Machek 2009-04-02 1637 return -ENOTTY;
1a2ad21128bb4eb Pavel Machek 2009-04-02 1638 }
1a2ad21128bb4eb Pavel Machek 2009-04-02 1639
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative()
2025-12-20 11:02 ` [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative() Vincent Mailhol
` (4 preceding siblings ...)
2025-12-27 8:49 ` kernel test robot
@ 2025-12-28 1:41 ` kernel test robot
2026-01-01 15:10 ` Vincent Mailhol
6 siblings, 0 replies; 21+ messages in thread
From: kernel test robot @ 2025-12-28 1:41 UTC (permalink / raw)
To: Vincent Mailhol, Nathan Chancellor, Nicolas Schier,
Nick Desaulniers, Bill Wendling, Justin Stitt, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chris Mason, David Sterba, Kees Cook, Gustavo A. R. Silva
Cc: oe-kbuild-all, linux-kbuild, linux-sparse, linux-kernel, llvm,
dri-devel, linux-btrfs, linux-hardening, Vincent Mailhol
Hi Vincent,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 3e7f562e20ee87a25e104ef4fce557d39d62fa85]
url: https://github.com/intel-lab-lkp/linux/commits/Vincent-Mailhol/kbuild-remove-gcc-s-Wtype-limits/20251220-190509
base: 3e7f562e20ee87a25e104ef4fce557d39d62fa85
patch link: https://lore.kernel.org/r/20251220-remove_wtype-limits-v3-3-24b170af700e%40kernel.org
patch subject: [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative()
config: arm-randconfig-r071-20251224 (https://download.01.org/0day-ci/archive/20251228/202512280906.wt7UNpya-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 8.5.0
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/202512280906.wt7UNpya-lkp@intel.com/
smatch warnings:
fs/xfs/xfs_mount.c:144 xfs_sb_validate_fsb_count() warn: unsigned '*_d' is never less than zero.
fs/xfs/xfs_mount.c:144 xfs_sb_validate_fsb_count() warn: unsigned '_a' is never less than zero.
vim +144 fs/xfs/xfs_mount.c
27174203f570b9 Christoph Hellwig 2009-03-30 130
4cc929ee305c69 Nathan Scott 2007-05-14 131 /*
4cc929ee305c69 Nathan Scott 2007-05-14 132 * Check size of device based on the (data/realtime) block count.
4cc929ee305c69 Nathan Scott 2007-05-14 133 * Note: this check is used by the growfs code as well as mount.
4cc929ee305c69 Nathan Scott 2007-05-14 134 */
4cc929ee305c69 Nathan Scott 2007-05-14 135 int
4cc929ee305c69 Nathan Scott 2007-05-14 136 xfs_sb_validate_fsb_count(
4cc929ee305c69 Nathan Scott 2007-05-14 137 xfs_sb_t *sbp,
c8ce540db5f67d Darrick J. Wong 2017-06-16 138 uint64_t nblocks)
4cc929ee305c69 Nathan Scott 2007-05-14 139 {
cebf9dacd5c3ce Pankaj Raghav 2024-08-22 140 uint64_t max_bytes;
cebf9dacd5c3ce Pankaj Raghav 2024-08-22 141
4cc929ee305c69 Nathan Scott 2007-05-14 142 ASSERT(sbp->sb_blocklog >= BBSHIFT);
4cc929ee305c69 Nathan Scott 2007-05-14 143
cebf9dacd5c3ce Pankaj Raghav 2024-08-22 @144 if (check_shl_overflow(nblocks, sbp->sb_blocklog, &max_bytes))
cebf9dacd5c3ce Pankaj Raghav 2024-08-22 145 return -EFBIG;
cebf9dacd5c3ce Pankaj Raghav 2024-08-22 146
d5cf09baced0ef Christoph Hellwig 2014-07-30 147 /* Limited by ULONG_MAX of page cache index */
cebf9dacd5c3ce Pankaj Raghav 2024-08-22 148 if (max_bytes >> PAGE_SHIFT > ULONG_MAX)
2451337dd04390 Dave Chinner 2014-06-25 149 return -EFBIG;
4cc929ee305c69 Nathan Scott 2007-05-14 150 return 0;
4cc929ee305c69 Nathan Scott 2007-05-14 151 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 152
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative()
2025-12-20 11:02 ` [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative() Vincent Mailhol
` (5 preceding siblings ...)
2025-12-28 1:41 ` kernel test robot
@ 2026-01-01 15:10 ` Vincent Mailhol
2026-01-01 19:39 ` Nicolas Schier
6 siblings, 1 reply; 21+ messages in thread
From: Vincent Mailhol @ 2026-01-01 15:10 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Nick Desaulniers,
Bill Wendling, Justin Stitt, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Chris Mason,
David Sterba, Kees Cook, Gustavo A. R. Silva
Cc: Linus Torvalds, linux-kbuild, linux-sparse, linux-kernel, llvm,
dri-devel, linux-btrfs, linux-hardening, kernel test robot
On 20/12/2025 at 12:02, Vincent Mailhol wrote:
> The is_non_negative() and is_negative() function-like macros just
> exist as a workaround to silence the -Wtype-limits warning. Now that
> this warning is disabled, those two macros have lost their raison
> d'être. Remove them.
>
> This reverts commit dc7fe518b049 ("overflow: Fix -Wtype-limits
> compilation warnings").
>
> Suggested-by: Nicolas Schier <nsc@kernel.org>
> Link: https://lore.kernel.org/all/aUT_yWin_xslnOFh@derry.ads.avm.de
> Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
So at the end, this patch got five kernel test robot reports:
https://lore.kernel.org/all/202512221735.mRV4BZqB-lkp@intel.com/
https://lore.kernel.org/all/202512230342.Lgha2HGH-lkp@intel.com/
https://lore.kernel.org/all/202512251340.UApIFw9R-lkp@intel.com/
https://lore.kernel.org/all/202512271618.33YepxDC-lkp@intel.com/
https://lore.kernel.org/all/202512280906.wt7UNpya-lkp@intel.com/
All these are the same smatch warning just triggered from a different
place. I think it is still too early to undo that workaround in
include/linux/overflow.h, otherwise developers would be getting that
smatch report too often.
I will send a v4 in which I will drop this patch. This basically means
that the v4 is a revert to v1...
> ---
> Changelog:
>
> v1 -> v2: new patch
> ---
> include/linux/overflow.h | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux/overflow.h b/include/linux/overflow.h
> index 736f633b2d5f..ab142d60c6b5 100644
> --- a/include/linux/overflow.h
> +++ b/include/linux/overflow.h
> @@ -36,12 +36,6 @@
> #define __type_min(T) ((T)((T)-type_max(T)-(T)1))
> #define type_min(t) __type_min(typeof(t))
>
> -/*
> - * Avoids triggering -Wtype-limits compilation warning,
> - * while using unsigned data types to check a < 0.
> - */
> -#define is_non_negative(a) ((a) > 0 || (a) == 0)
> -#define is_negative(a) (!(is_non_negative(a)))
>
> /*
> * Allows for effectively applying __must_check to a macro so we can have
> @@ -201,9 +195,9 @@ static inline bool __must_check __must_check_overflow(bool overflow)
> typeof(d) _d = d; \
> unsigned long long _a_full = _a; \
> unsigned int _to_shift = \
> - is_non_negative(_s) && _s < 8 * sizeof(*d) ? _s : 0; \
> + _s >= 0 && _s < 8 * sizeof(*d) ? _s : 0; \
> *_d = (_a_full << _to_shift); \
> - (_to_shift != _s || is_negative(*_d) || is_negative(_a) || \
> + (_to_shift != _s || *_d < 0 || _a < 0 || \
> (*_d >> _to_shift) != _a); \
> }))
>
>
Yours sincerely,
Vincent Mailhol
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative()
2026-01-01 15:10 ` Vincent Mailhol
@ 2026-01-01 19:39 ` Nicolas Schier
2026-01-02 11:04 ` Miguel Ojeda
0 siblings, 1 reply; 21+ messages in thread
From: Nicolas Schier @ 2026-01-01 19:39 UTC (permalink / raw)
To: Vincent Mailhol
Cc: Nathan Chancellor, Nicolas Schier, Nick Desaulniers,
Bill Wendling, Justin Stitt, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Chris Mason,
David Sterba, Kees Cook, Gustavo A. R. Silva, Linus Torvalds,
linux-kbuild, linux-sparse, linux-kernel, llvm, dri-devel,
linux-btrfs, linux-hardening, kernel test robot
[-- Attachment #1: Type: text/plain, Size: 1596 bytes --]
On Thu, Jan 01, 2026 at 04:10:36PM +0100, Vincent Mailhol wrote:
> On 20/12/2025 at 12:02, Vincent Mailhol wrote:
> > The is_non_negative() and is_negative() function-like macros just
> > exist as a workaround to silence the -Wtype-limits warning. Now that
> > this warning is disabled, those two macros have lost their raison
> > d'être. Remove them.
> >
> > This reverts commit dc7fe518b049 ("overflow: Fix -Wtype-limits
> > compilation warnings").
> >
> > Suggested-by: Nicolas Schier <nsc@kernel.org>
> > Link: https://lore.kernel.org/all/aUT_yWin_xslnOFh@derry.ads.avm.de
> > Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
>
> So at the end, this patch got five kernel test robot reports:
>
> https://lore.kernel.org/all/202512221735.mRV4BZqB-lkp@intel.com/
> https://lore.kernel.org/all/202512230342.Lgha2HGH-lkp@intel.com/
> https://lore.kernel.org/all/202512251340.UApIFw9R-lkp@intel.com/
> https://lore.kernel.org/all/202512271618.33YepxDC-lkp@intel.com/
> https://lore.kernel.org/all/202512280906.wt7UNpya-lkp@intel.com/
>
> All these are the same smatch warning just triggered from a different
> place. I think it is still too early to undo that workaround in
> include/linux/overflow.h, otherwise developers would be getting that
> smatch report too often.
>
> I will send a v4 in which I will drop this patch. This basically means
> that the v4 is a revert to v1...
thanks! I think it's a bit sad to keep code only to make some checker
tooling happy, but for now it seems to be the right thing to do.
Kind Regards,
Nicolas
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative()
2026-01-01 19:39 ` Nicolas Schier
@ 2026-01-02 11:04 ` Miguel Ojeda
2026-01-02 22:26 ` Vincent Mailhol
0 siblings, 1 reply; 21+ messages in thread
From: Miguel Ojeda @ 2026-01-02 11:04 UTC (permalink / raw)
To: Nicolas Schier
Cc: Vincent Mailhol, Nathan Chancellor, Nicolas Schier,
Nick Desaulniers, Bill Wendling, Justin Stitt, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chris Mason, David Sterba, Kees Cook, Gustavo A. R. Silva,
Linus Torvalds, linux-kbuild, linux-sparse, linux-kernel, llvm,
dri-devel, linux-btrfs, linux-hardening, kernel test robot
On Thu, Jan 1, 2026 at 9:13 PM Nicolas Schier <nicolas@fjasle.eu> wrote:
>
> thanks! I think it's a bit sad to keep code only to make some checker
> tooling happy, but for now it seems to be the right thing to do.
Perhaps a patch to add a comment explaining Vincent's findings would
be a good outcome, i.e. explaining the reason it needs to remain in
place for the moment (even a link to lore.kernel.org to this thread
would help).
Cheers,
Miguel
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 3/3] overflow: Remove is_non_negative() and is_negative()
2026-01-02 11:04 ` Miguel Ojeda
@ 2026-01-02 22:26 ` Vincent Mailhol
2026-01-02 22:29 ` [PATCH] overflow: Update is_non_negative() and is_negative() comment Vincent Mailhol
0 siblings, 1 reply; 21+ messages in thread
From: Vincent Mailhol @ 2026-01-02 22:26 UTC (permalink / raw)
To: Miguel Ojeda, Nicolas Schier
Cc: Nathan Chancellor, Nicolas Schier, Nick Desaulniers,
Bill Wendling, Justin Stitt, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Chris Mason,
David Sterba, Kees Cook, Gustavo A. R. Silva, Linus Torvalds,
linux-kbuild, linux-sparse, linux-kernel, llvm, dri-devel,
linux-btrfs, linux-hardening, kernel test robot
On 02/01/2026 at 12:04, Miguel Ojeda wrote:
> On Thu, Jan 1, 2026 at 9:13 PM Nicolas Schier <nicolas@fjasle.eu> wrote:
>>
>> thanks! I think it's a bit sad to keep code only to make some checker
>> tooling happy, but for now it seems to be the right thing to do.
>
> Perhaps a patch to add a comment explaining Vincent's findings would
> be a good outcome, i.e. explaining the reason it needs to remain in
> place for the moment
OK. But I will send this as a separate patch as a reply to this thread
so that this can be discussed separately without having to respin the
main series again and again. I will add it back to the main series only
if it get a decent level of Acked-by tags.
> (even a link to lore.kernel.org to this thread would help).
It is rather uncommon to add lore.kernel.org links in the code comment.
But I am not against. I will do as you suggested so and see what people
think of it.
Yours sincerely,
Vincent Mailhol
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH] overflow: Update is_non_negative() and is_negative() comment
2026-01-02 22:26 ` Vincent Mailhol
@ 2026-01-02 22:29 ` Vincent Mailhol
2026-01-03 10:02 ` Dan Carpenter
0 siblings, 1 reply; 21+ messages in thread
From: Vincent Mailhol @ 2026-01-02 22:29 UTC (permalink / raw)
To: Miguel Ojeda, Nicolas Schier
Cc: Nathan Chancellor, Nicolas Schier, Nick Desaulniers,
Bill Wendling, Justin Stitt, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Chris Mason,
David Sterba, Kees Cook, Gustavo A. R. Silva, Linus Torvalds,
linux-kbuild, linux-sparse, linux-kernel, llvm, dri-devel,
linux-btrfs, linux-hardening, kernel test robot
The is_non_negative() and is_negative() function-like macros initially
exist as a workaround to silence the -Wtype-limits warning. Now that
this warning is disabled, those two macros have lost their raison
d'être. Or so we thought.
In reality, smatch still produces a similar warning and so, it is
unfortunately still too early to undo this workaround.
Update the comment to point to smatch instead of GCC's -Wtype-limits.
Add a link to the thread in which this was discovered.
Suggested-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Link: https://lore.kernel.org/all/CANiq72=jRT+6+2PBgshsK-TpxPiRK70H-+3D6sYaN-fdfC83qw@mail.gmail.com/
Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
---
include/linux/overflow.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/overflow.h b/include/linux/overflow.h
index 736f633b2d5f..d84194fc783b 100644
--- a/include/linux/overflow.h
+++ b/include/linux/overflow.h
@@ -37,8 +37,8 @@
#define type_min(t) __type_min(typeof(t))
/*
- * Avoids triggering -Wtype-limits compilation warning,
- * while using unsigned data types to check a < 0.
+ * Avoids triggering "unsigned 'a' is never less than zero" smatch warning,
+ * Link: https://lore.kernel.org/all/acdd84b2-e893-419c-8a46-da55d695dda2@kernel.org
*/
#define is_non_negative(a) ((a) > 0 || (a) == 0)
#define is_negative(a) (!(is_non_negative(a)))
--
2.52.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH] overflow: Update is_non_negative() and is_negative() comment
2026-01-02 22:29 ` [PATCH] overflow: Update is_non_negative() and is_negative() comment Vincent Mailhol
@ 2026-01-03 10:02 ` Dan Carpenter
2026-01-03 11:10 ` Vincent Mailhol
0 siblings, 1 reply; 21+ messages in thread
From: Dan Carpenter @ 2026-01-03 10:02 UTC (permalink / raw)
To: Randy Dunlap
Cc: Vincent Mailhol, Miguel Ojeda, Nicolas Schier, Nathan Chancellor,
Nicolas Schier, Nick Desaulniers, Bill Wendling, Justin Stitt,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Chris Mason, David Sterba, Kees Cook,
Gustavo A. R. Silva, Linus Torvalds, linux-kbuild, linux-sparse,
linux-kernel, llvm, dri-devel, linux-btrfs, linux-hardening,
kernel test robot
Thanks Randy, for sending this to me. I'm on the sparse list, but
I've been on vacation and haven't caught up with my email. I can
easily silence this in Smatch.
regards,
dan carpenter
diff --git a/check_unsigned_lt_zero.c b/check_unsigned_lt_zero.c
index bfeb3261f91d..ac3e650704ce 100644
--- a/check_unsigned_lt_zero.c
+++ b/check_unsigned_lt_zero.c
@@ -105,7 +105,8 @@ static bool is_allowed_zero(struct expression *expr)
strcmp(macro, "STRTO_H") == 0 ||
strcmp(macro, "SUB_EXTEND_USTAT") == 0 ||
strcmp(macro, "TEST_CASTABLE_TO_TYPE_VAR") == 0 ||
- strcmp(macro, "TEST_ONE_SHIFT") == 0)
+ strcmp(macro, "TEST_ONE_SHIFT") == 0 ||
+ strcmp(macro, "check_shl_overflow") == 0)
return true;
return false;
}
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH] overflow: Update is_non_negative() and is_negative() comment
2026-01-03 10:02 ` Dan Carpenter
@ 2026-01-03 11:10 ` Vincent Mailhol
2026-01-03 16:56 ` Dan Carpenter
0 siblings, 1 reply; 21+ messages in thread
From: Vincent Mailhol @ 2026-01-03 11:10 UTC (permalink / raw)
To: Dan Carpenter, Randy Dunlap
Cc: Miguel Ojeda, Nicolas Schier, Nathan Chancellor, Nicolas Schier,
Nick Desaulniers, Bill Wendling, Justin Stitt, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Chris Mason, David Sterba, Kees Cook, Gustavo A. R. Silva,
Linus Torvalds, linux-kbuild, linux-sparse, linux-kernel, llvm,
dri-devel, linux-btrfs, linux-hardening, kernel test robot
On 03/01/2026 at 11:02, Dan Carpenter wrote:
> Thanks Randy, for sending this to me. I'm on the sparse list, but
> I've been on vacation and haven't caught up with my email.
Welcome back, hope you enjoyed your holidays!
>I can easily silence this in Smatch.
Thanks. I ran this locally, I can confirm that this silences the
warning. So:
Tested-by: Vincent Mailhol <mailhol@kernel.org>
> diff --git a/check_unsigned_lt_zero.c b/check_unsigned_lt_zero.c
> index bfeb3261f91d..ac3e650704ce 100644
> --- a/check_unsigned_lt_zero.c
> +++ b/check_unsigned_lt_zero.c
> @@ -105,7 +105,8 @@ static bool is_allowed_zero(struct expression *expr)
> strcmp(macro, "STRTO_H") == 0 ||
> strcmp(macro, "SUB_EXTEND_USTAT") == 0 ||
> strcmp(macro, "TEST_CASTABLE_TO_TYPE_VAR") == 0 ||
> - strcmp(macro, "TEST_ONE_SHIFT") == 0)
> + strcmp(macro, "TEST_ONE_SHIFT") == 0 ||
> + strcmp(macro, "check_shl_overflow") == 0)
But, for the long term, wouldn't it better to just ignore all the code
coming from macro extensions instead of maintaining this allow-list?
> return true;
> return false;
> }
Yours sincerely,
Vincent Mailhol
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] overflow: Update is_non_negative() and is_negative() comment
2026-01-03 11:10 ` Vincent Mailhol
@ 2026-01-03 16:56 ` Dan Carpenter
2026-01-03 19:40 ` Vincent Mailhol
0 siblings, 1 reply; 21+ messages in thread
From: Dan Carpenter @ 2026-01-03 16:56 UTC (permalink / raw)
To: Vincent Mailhol
Cc: Randy Dunlap, Miguel Ojeda, Nicolas Schier, Nathan Chancellor,
Nicolas Schier, Nick Desaulniers, Bill Wendling, Justin Stitt,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Chris Mason, David Sterba, Kees Cook,
Gustavo A. R. Silva, Linus Torvalds, linux-kbuild, linux-sparse,
linux-kernel, llvm, dri-devel, linux-btrfs, linux-hardening,
kernel test robot
On Sat, Jan 03, 2026 at 12:10:45PM +0100, Vincent Mailhol wrote:
> On 03/01/2026 at 11:02, Dan Carpenter wrote:
> > Thanks Randy, for sending this to me. I'm on the sparse list, but
> > I've been on vacation and haven't caught up with my email.
>
> Welcome back, hope you enjoyed your holidays!
>
> >I can easily silence this in Smatch.
>
> Thanks. I ran this locally, I can confirm that this silences the
> warning. So:
>
> Tested-by: Vincent Mailhol <mailhol@kernel.org>
>
> > diff --git a/check_unsigned_lt_zero.c b/check_unsigned_lt_zero.c
> > index bfeb3261f91d..ac3e650704ce 100644
> > --- a/check_unsigned_lt_zero.c
> > +++ b/check_unsigned_lt_zero.c
> > @@ -105,7 +105,8 @@ static bool is_allowed_zero(struct expression *expr)
> > strcmp(macro, "STRTO_H") == 0 ||
> > strcmp(macro, "SUB_EXTEND_USTAT") == 0 ||
> > strcmp(macro, "TEST_CASTABLE_TO_TYPE_VAR") == 0 ||
> > - strcmp(macro, "TEST_ONE_SHIFT") == 0)
> > + strcmp(macro, "TEST_ONE_SHIFT") == 0 ||
> > + strcmp(macro, "check_shl_overflow") == 0)
>
> But, for the long term, wouldn't it better to just ignore all the code
> coming from macro extensions instead of maintaining this allow-list?
>
Of course, that idea occured to me, but so far the allow list is not
very burdensome to maintain. I maybe should disable it for all
macros unless the --spammy option is used...
regards,
dan carpenter
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] overflow: Update is_non_negative() and is_negative() comment
2026-01-03 16:56 ` Dan Carpenter
@ 2026-01-03 19:40 ` Vincent Mailhol
0 siblings, 0 replies; 21+ messages in thread
From: Vincent Mailhol @ 2026-01-03 19:40 UTC (permalink / raw)
To: Dan Carpenter
Cc: Randy Dunlap, Miguel Ojeda, Nicolas Schier, Nathan Chancellor,
Nicolas Schier, Nick Desaulniers, Bill Wendling, Justin Stitt,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Chris Mason, David Sterba, Kees Cook,
Gustavo A. R. Silva, Linus Torvalds, linux-kbuild, linux-sparse,
linux-kernel, llvm, dri-devel, linux-btrfs, linux-hardening,
kernel test robot
On 03/01/2026 at 17:56, Dan Carpenter wrote:
> On Sat, Jan 03, 2026 at 12:10:45PM +0100, Vincent Mailhol wrote:
>> On 03/01/2026 at 11:02, Dan Carpenter wrote:
>>> Thanks Randy, for sending this to me. I'm on the sparse list, but
>>> I've been on vacation and haven't caught up with my email.
>>
>> Welcome back, hope you enjoyed your holidays!
>>
>>> I can easily silence this in Smatch.
>>
>> Thanks. I ran this locally, I can confirm that this silences the
>> warning. So:
>>
>> Tested-by: Vincent Mailhol <mailhol@kernel.org>
>>
>>> diff --git a/check_unsigned_lt_zero.c b/check_unsigned_lt_zero.c
>>> index bfeb3261f91d..ac3e650704ce 100644
>>> --- a/check_unsigned_lt_zero.c
>>> +++ b/check_unsigned_lt_zero.c
>>> @@ -105,7 +105,8 @@ static bool is_allowed_zero(struct expression *expr)
>>> strcmp(macro, "STRTO_H") == 0 ||
>>> strcmp(macro, "SUB_EXTEND_USTAT") == 0 ||
>>> strcmp(macro, "TEST_CASTABLE_TO_TYPE_VAR") == 0 ||
>>> - strcmp(macro, "TEST_ONE_SHIFT") == 0)
>>> + strcmp(macro, "TEST_ONE_SHIFT") == 0 ||
>>> + strcmp(macro, "check_shl_overflow") == 0)
>>
>> But, for the long term, wouldn't it better to just ignore all the code
>> coming from macro extensions instead of maintaining this allow-list?
>>
>
> Of course, that idea occured to me, but so far the allow list is not
> very burdensome to maintain.
Indeed, but my concern was more on how people would treat such smatch
warnings coming from the kernel test robot. It is very uncommon to have
an allow-list hard coded into the static analyzer. Actually, this is the
first time I see this. My fear here is that people will just uglify the
code rather than sending a patch to extend the allow list in smatch.
> I maybe should disable it for all macros unless the --spammy option is used...
IMHO, that would be an even better approach. That said, I am happy
enough with your previous patch which resolves my issue and which is way
better than updating the is_non_negative() and is_negative() comments as
I did in my patch!
Yours sincerely,
Vincent Mailhol
^ permalink raw reply [flat|nested] 21+ messages in thread