All of lore.kernel.org
 help / color / mirror / Atom feed
* [qais-yousef:sched-setscheduler-hide 12/12] kernel/kthread.c:1570 param_get_namefmt() warn: variable dereferenced before check 'param' (see line 1567)
@ 2023-09-08 11:24 kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2023-09-08 11:24 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: Qais Yousef <qyousef@layalina.io>

tree:   https://github.com/qais-yousef/linux sched-setscheduler-hide
head:   557fb1e21399de5f674beb93fa6793adce124cc2
commit: 557fb1e21399de5f674beb93fa6793adce124cc2 [12/12] kthread: Implement parameter handling logic
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago
config: x86_64-randconfig-161-20230907 (https://download.01.org/0day-ci/archive/20230908/202309081907.lbs9VWMn-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230908/202309081907.lbs9VWMn-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>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202309081907.lbs9VWMn-lkp@intel.com/

smatch warnings:
kernel/kthread.c:1570 param_get_namefmt() warn: variable dereferenced before check 'param' (see line 1567)
kernel/kthread.c:1794 param_set_sched_util_min() warn: ignoring unreachable code.

vim +/param +1570 kernel/kthread.c

4328f6314232c50e Qais Yousef 2023-08-26  1558  
4328f6314232c50e Qais Yousef 2023-08-26  1559  /*
4328f6314232c50e Qais Yousef 2023-08-26  1560   * Kthread sysfs params handling
4328f6314232c50e Qais Yousef 2023-08-26  1561   */
557fb1e21399de5f Qais Yousef 2023-08-27  1562  static int param_get_namefmt(char *buffer, int len,
557fb1e21399de5f Qais Yousef 2023-08-27  1563  			     const char *name, const char *param)
557fb1e21399de5f Qais Yousef 2023-08-27  1564  {
557fb1e21399de5f Qais Yousef 2023-08-27  1565  	int namelen = strlen(name);
557fb1e21399de5f Qais Yousef 2023-08-27  1566  	int kthreadlen = strlen("kthread.");
557fb1e21399de5f Qais Yousef 2023-08-27 @1567  	int paramlen = strlen(param);
557fb1e21399de5f Qais Yousef 2023-08-27  1568  	int size = namelen - kthreadlen - paramlen;
557fb1e21399de5f Qais Yousef 2023-08-27  1569  
557fb1e21399de5f Qais Yousef 2023-08-27 @1570  	if (!namelen || !param || size > len)
557fb1e21399de5f Qais Yousef 2023-08-27  1571  		return -EINVAL;
557fb1e21399de5f Qais Yousef 2023-08-27  1572  
557fb1e21399de5f Qais Yousef 2023-08-27  1573  	strlcpy(buffer, name + kthreadlen, size);
557fb1e21399de5f Qais Yousef 2023-08-27  1574  
557fb1e21399de5f Qais Yousef 2023-08-27  1575  	return 0;
557fb1e21399de5f Qais Yousef 2023-08-27  1576  }
557fb1e21399de5f Qais Yousef 2023-08-27  1577  

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

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

* [qais-yousef:sched-setscheduler-hide 12/12] kernel/kthread.c:1570 param_get_namefmt() warn: variable dereferenced before check 'param' (see line 1567)
@ 2023-09-08 16:19 Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2023-09-08 16:19 UTC (permalink / raw)
  To: oe-kbuild, Qais Yousef; +Cc: lkp, oe-kbuild-all

tree:   https://github.com/qais-yousef/linux sched-setscheduler-hide
head:   557fb1e21399de5f674beb93fa6793adce124cc2
commit: 557fb1e21399de5f674beb93fa6793adce124cc2 [12/12] kthread: Implement parameter handling logic
config: x86_64-randconfig-161-20230907 (https://download.01.org/0day-ci/archive/20230908/202309081907.lbs9VWMn-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230908/202309081907.lbs9VWMn-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>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202309081907.lbs9VWMn-lkp@intel.com/

smatch warnings:
kernel/kthread.c:1570 param_get_namefmt() warn: variable dereferenced before check 'param' (see line 1567)
kernel/kthread.c:1794 param_set_sched_util_min() warn: ignoring unreachable code.

vim +/param +1570 kernel/kthread.c

557fb1e21399de5f Qais Yousef 2023-08-27  1562  static int param_get_namefmt(char *buffer, int len,
557fb1e21399de5f Qais Yousef 2023-08-27  1563  			     const char *name, const char *param)
557fb1e21399de5f Qais Yousef 2023-08-27  1564  {
557fb1e21399de5f Qais Yousef 2023-08-27  1565  	int namelen = strlen(name);
557fb1e21399de5f Qais Yousef 2023-08-27  1566  	int kthreadlen = strlen("kthread.");
557fb1e21399de5f Qais Yousef 2023-08-27 @1567  	int paramlen = strlen(param);
                                                                      ^^^^^
Dereferenced

557fb1e21399de5f Qais Yousef 2023-08-27  1568  	int size = namelen - kthreadlen - paramlen;
557fb1e21399de5f Qais Yousef 2023-08-27  1569  
557fb1e21399de5f Qais Yousef 2023-08-27 @1570  	if (!namelen || !param || size > len)
                                                                 ^^^^^
Checked too late.

557fb1e21399de5f Qais Yousef 2023-08-27  1571  		return -EINVAL;
557fb1e21399de5f Qais Yousef 2023-08-27  1572  
557fb1e21399de5f Qais Yousef 2023-08-27  1573  	strlcpy(buffer, name + kthreadlen, size);
557fb1e21399de5f Qais Yousef 2023-08-27  1574  
557fb1e21399de5f Qais Yousef 2023-08-27  1575  	return 0;
557fb1e21399de5f Qais Yousef 2023-08-27  1576  }

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


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

end of thread, other threads:[~2023-09-08 16:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-08 11:24 [qais-yousef:sched-setscheduler-hide 12/12] kernel/kthread.c:1570 param_get_namefmt() warn: variable dereferenced before check 'param' (see line 1567) kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2023-09-08 16:19 Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.