llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [linux-stable-rc:queue/4.14 22/46] drivers/block/null_blk.c:1785:3: error: void function 'null_validate_conf' should not return a value
@ 2023-05-22 17:59 kernel test robot
  2023-05-22 18:37 ` Chaitanya Kulkarni
  0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2023-05-22 17:59 UTC (permalink / raw)
  To: Chaitanya Kulkarni
  Cc: llvm, oe-kbuild-all, Sasha Levin, Damien Le Moal, Ming Lei,
	Nitesh Shetty, Jens Axboe

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git queue/4.14
head:   840fe5c557003b7b70dd1c5e6bd6b057f8f671a2
commit: 1472d580894fe831ff4a2274ba77a3abe65aaf37 [22/46] null_blk: Always check queue mode setting from configfs
config: mips-randconfig-r036-20230522 (https://download.01.org/0day-ci/archive/20230523/202305230134.IWLqX1Hz-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project b0fb98227c90adf2536c9ad644a74d5e92961111)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install mips cross compiling tool for clang build
        # apt-get install binutils-mipsel-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/commit/?id=1472d580894fe831ff4a2274ba77a3abe65aaf37
        git remote add linux-stable-rc https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
        git fetch --no-tags linux-stable-rc queue/4.14
        git checkout 1472d580894fe831ff4a2274ba77a3abe65aaf37
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash drivers/block/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202305230134.IWLqX1Hz-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/block/null_blk.c:1785:3: error: void function 'null_validate_conf' should not return a value [-Wreturn-type]
                   return -EINVAL;
                   ^      ~~~~~~~
   1 error generated.


vim +/null_validate_conf +1785 drivers/block/null_blk.c

  1780	
  1781	static void null_validate_conf(struct nullb_device *dev)
  1782	{
  1783		if (dev->queue_mode == NULL_Q_RQ) {
  1784			pr_err("legacy IO path is no longer available\n");
> 1785			return -EINVAL;
  1786		}
  1787	
  1788		dev->blocksize = round_down(dev->blocksize, 512);
  1789		dev->blocksize = clamp_t(unsigned int, dev->blocksize, 512, 4096);
  1790		if (dev->use_lightnvm && dev->blocksize != 4096)
  1791			dev->blocksize = 4096;
  1792	
  1793		if (dev->use_lightnvm && dev->queue_mode != NULL_Q_MQ)
  1794			dev->queue_mode = NULL_Q_MQ;
  1795	
  1796		if (dev->queue_mode == NULL_Q_MQ && dev->use_per_node_hctx) {
  1797			if (dev->submit_queues != nr_online_nodes)
  1798				dev->submit_queues = nr_online_nodes;
  1799		} else if (dev->submit_queues > nr_cpu_ids)
  1800			dev->submit_queues = nr_cpu_ids;
  1801		else if (dev->submit_queues == 0)
  1802			dev->submit_queues = 1;
  1803	
  1804		dev->queue_mode = min_t(unsigned int, dev->queue_mode, NULL_Q_MQ);
  1805		dev->irqmode = min_t(unsigned int, dev->irqmode, NULL_IRQ_TIMER);
  1806	
  1807		/* Do memory allocation, so set blocking */
  1808		if (dev->memory_backed)
  1809			dev->blocking = true;
  1810		else /* cache is meaningless */
  1811			dev->cache_size = 0;
  1812		dev->cache_size = min_t(unsigned long, ULONG_MAX / 1024 / 1024,
  1813							dev->cache_size);
  1814		dev->mbps = min_t(unsigned int, 1024 * 40, dev->mbps);
  1815		/* can not stop a queue */
  1816		if (dev->queue_mode == NULL_Q_BIO)
  1817			dev->mbps = 0;
  1818	}
  1819	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [linux-stable-rc:queue/4.14 22/46] drivers/block/null_blk.c:1785:3: error: void function 'null_validate_conf' should not return a value
  2023-05-22 17:59 [linux-stable-rc:queue/4.14 22/46] drivers/block/null_blk.c:1785:3: error: void function 'null_validate_conf' should not return a value kernel test robot
@ 2023-05-22 18:37 ` Chaitanya Kulkarni
  0 siblings, 0 replies; 2+ messages in thread
From: Chaitanya Kulkarni @ 2023-05-22 18:37 UTC (permalink / raw)
  To: kernel test robot, oe-kbuild-all, Sasha Levin, llvm
  Cc: Damien Le Moal, Ming Lei, Nitesh Shetty, Jens Axboe, Chaitanya Kulkarni

On 5/22/23 10:59, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git queue/4.14
> head:   840fe5c557003b7b70dd1c5e6bd6b057f8f671a2
> commit: 1472d580894fe831ff4a2274ba77a3abe65aaf37 [22/46] null_blk: Always check queue mode setting from configfs
> config: mips-randconfig-r036-20230522 (https://download.01.org/0day-ci/archive/20230523/202305230134.IWLqX1Hz-lkp@intel.com/config)
> compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project b0fb98227c90adf2536c9ad644a74d5e92961111)
> reproduce (this is a W=1 build):
>          wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>          chmod +x ~/bin/make.cross
>          # install mips cross compiling tool for clang build
>          # apt-get install binutils-mipsel-linux-gnu
>          # https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/commit/?id=1472d580894fe831ff4a2274ba77a3abe65aaf37
>          git remote add linux-stable-rc https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
>          git fetch --no-tags linux-stable-rc queue/4.14
>          git checkout 1472d580894fe831ff4a2274ba77a3abe65aaf37
>          # save the config file
>          mkdir build_dir && cp config build_dir/.config
>          COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips olddefconfig
>          COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash drivers/block/
>
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202305230134.IWLqX1Hz-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
>>> drivers/block/null_blk.c:1785:3: error: void function 'null_validate_conf' should not return a value [-Wreturn-type]
>                     return -EINVAL;
>                     ^      ~~~~~~~
>     1 error generated.
>
>
> vim +/null_validate_conf +1785 drivers/block/null_blk.c
>
>    1780	
>    1781	static void null_validate_conf(struct nullb_device *dev)
>    1782	{
>    1783		if (dev->queue_mode == NULL_Q_RQ) {
>    1784			pr_err("legacy IO path is no longer available\n");
>> 1785			return -EINVAL;
>    1786		}
>   

in current linux-block/for-next tree I've this [1].
my patch that adds above check is [2].

I'm not sure how this patch got applied on null_validate_conf()
when it had void return value ...

if you have any idea please let me know, else will keep looking to
fix this ...

-ck


[1]
2000
2001 static int null_validate_conf(struct nullb_device *dev)
2002 {
2003         if (dev->queue_mode == NULL_Q_RQ) {
2004                 pr_err("legacy IO path is no longer available\n");
2005                 return -EINVAL;
2006         }
2007
2008         dev->blocksize = round_down(dev->blocksize, 512);
2009         dev->blocksize = clamp_t(unsigned int, dev->blocksize, 512, 
4096);
2010
2011         if (dev->queue_mode == NULL_Q_MQ && dev->use_per_node_hctx) {
2012                 if (dev->submit_queues != nr_online_nodes)
2013                         dev->submit_queues = nr_online_nodes;
2014         } else if (dev->submit_queues > nr_cpu_ids)
2015                 dev->submit_queues = nr_cpu_ids;
2016         else if (dev->submit_queues == 0)
2017                 dev->submit_queues = 1;
2018         dev->prev_submit_queues = dev->submit_queues;
2019
2020         if (dev->poll_queues > g_poll_queues)
2021                 dev->poll_queues = g_poll_queues;
2022         dev->prev_poll_queues = dev->poll_queues;
2023
2024         dev->queue_mode = min_t(unsigned int, dev->queue_mode, 
NULL_Q_MQ);
2025         dev->irqmode = min_t(unsigned int, dev->irqmode, 
NULL_IRQ_TIMER);
2026
2027         /* Do memory allocation, so set blocking */
2028         if (dev->memory_backed)
2029                 dev->blocking = true;
2030         else /* cache is meaningless */
2031                 dev->cache_size = 0;
2032         dev->cache_size = min_t(unsigned long, ULONG_MAX / 1024 / 1024,
2033 dev->cache_size);
2034         dev->mbps = min_t(unsigned int, 1024 * 40, dev->mbps);
2035         /* can not stop a queue */
2036         if (dev->queue_mode == NULL_Q_BIO)
2037                 dev->mbps = 0;
2038
2039         if (dev->zoned &&
2040             (!dev->zone_size || !is_power_of_2(dev->zone_size))) {
2041                 pr_err("zone_size must be power-of-two\n");
2042                 return -EINVAL;
2043         }
2044
2045         return 0;
2046 }



[2]
linux-block (for-next) # git format-patch 63f8793ee6051 -1
0001-null_blk-Always-check-queue-mode-setting-from-config.patch
linux-block (for-next) # cat 
0001-null_blk-Always-check-queue-mode-setting-from-config.patch
 From 63f8793ee60513a09f110ea460a6ff2c33811cdb Mon Sep 17 00:00:00 2001
From: Chaitanya Kulkarni <kch@nvidia.com>
Date: Sun, 16 Apr 2023 15:03:39 -0700
Subject: [PATCH] null_blk: Always check queue mode setting from configfs

Make sure to check device queue mode in the null_validate_conf() and
return error for NULL_Q_RQ as we don't allow legacy I/O path, without
this patch we get OOPs when queue mode is set to 1 from configfs,
following are repro steps :-

modprobe null_blk nr_devices=0
mkdir config/nullb/nullb0
echo 1 > config/nullb/nullb0/memory_backed
echo 4096 > config/nullb/nullb0/blocksize
echo 20480 > config/nullb/nullb0/size
echo 1 > config/nullb/nullb0/queue_mode
echo 1 > config/nullb/nullb0/power

Entering kdb (current=0xffff88810acdd080, pid 2372) on processor 42 
Oops: (null)
due to oops @ 0xffffffffc041c329
CPU: 42 PID: 2372 Comm: sh Tainted: G           O     N 6.3.0-rc5lblk+ #5
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
RIP: 0010:null_add_dev.part.0+0xd9/0x720 [null_blk]
Code: 01 00 00 85 d2 0f 85 a1 03 00 00 48 83 bb 08 01 00 00 00 0f 85 f7 
03 00 00 80 bb 62 01 00 00 00 48 8b 75 20 0f 85 6d 02 00 00 <48> 89 6e 
60 48 8b 75 20 bf 06 00 00 00 e8 f5 37 2c c1 48 8b 75 20
RSP: 0018:ffffc900052cbde0 EFLAGS: 00010246
RAX: 0000000000000001 RBX: ffff88811084d800 RCX: 0000000000000001
RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff888100042e00
RBP: ffff8881053d8200 R08: ffffc900052cbd68 R09: ffff888105db2000
R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000002
R13: ffff888104765200 R14: ffff88810eec1748 R15: ffff88810eec1740
FS:  00007fd445fd1740(0000) GS:ffff8897dfc80000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000060 CR3: 0000000166a00000 CR4: 0000000000350ee0
DR0: ffffffff8437a488 DR1: ffffffff8437a489 DR2: ffffffff8437a48a
DR3: ffffffff8437a48b DR6: 00000000ffff0ff0 DR7: 0000000000000400
Call Trace:
  <TASK>
  nullb_device_power_store+0xd1/0x120 [null_blk]
  configfs_write_iter+0xb4/0x120
  vfs_write+0x2ba/0x3c0
  ksys_write+0x5f/0xe0
  do_syscall_64+0x3b/0x90
  entry_SYSCALL_64_after_hwframe+0x72/0xdc
RIP: 0033:0x7fd4460c57a7
Code: 0d 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 f3 0f 1e 
fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 01 00 00 00 0f 05 <48> 3d 00 
f0 ff ff 77 51 c3 48 83 ec 28 48 89 54 24 18 48 89 74 24
RSP: 002b:00007ffd3792a4a8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007fd4460c57a7
RDX: 0000000000000002 RSI: 000055b43c02e4c0 RDI: 0000000000000001
RBP: 000055b43c02e4c0 R08: 000000000000000a R09: 00007fd44615b4e0
R10: 00007fd44615b3e0 R11: 0000000000000246 R12: 0000000000000002
R13: 00007fd446198520 R14: 0000000000000002 R15: 00007fd446198700
  </TASK>

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Nitesh Shetty <nj.shetty@samsung.com>
Link: https://lore.kernel.org/r/20230416220339.43845-1-kch@nvidia.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
  drivers/block/null_blk/main.c | 5 +++++
  1 file changed, 5 insertions(+)

diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 9a7e5699369e..fcb61f1d5437 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -2001,6 +2001,11 @@ static int null_init_tag_set(struct nullb *nullb, 
struct blk_mq_tag_set *set)

  static int null_validate_conf(struct nullb_device *dev)
  {
+    if (dev->queue_mode == NULL_Q_RQ) {
+        pr_err("legacy IO path is no longer available\n");
+        return -EINVAL;
+    }
+
      dev->blocksize = round_down(dev->blocksize, 512);
      dev->blocksize = clamp_t(unsigned int, dev->blocksize, 512, 4096);

-- 
2.40.0

linux-block (for-next) #


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-22 18:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-22 17:59 [linux-stable-rc:queue/4.14 22/46] drivers/block/null_blk.c:1785:3: error: void function 'null_validate_conf' should not return a value kernel test robot
2023-05-22 18:37 ` Chaitanya Kulkarni

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).