Re: [PATCH 4/4] audit: check if queue is full after prepare_to_wait_exclusive()

From: kernel test robot
Date: Mon May 08 2023 - 13:13:47 EST


Hi Eiichi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on pcmoore-audit/next]
[also build test WARNING on linus/master v6.4-rc1 next-20230508]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Eiichi-Tsukata/audit-refactor-queue-full-checks/20230508-160019
base: https://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit.git next
patch link: https://lore.kernel.org/r/20230508075812.76077-5-eiichi.tsukata%40nutanix.com
patch subject: [PATCH 4/4] audit: check if queue is full after prepare_to_wait_exclusive()
config: i386-randconfig-a001-20230508 (https://download.01.org/0day-ci/archive/20230509/202305090112.uJSc0NBw-lkp@xxxxxxxxx/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
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
# https://github.com/intel-lab-lkp/linux/commit/cbc69d0c34bdbc06ebca3e3020cfc24034fcf173
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Eiichi-Tsukata/audit-refactor-queue-full-checks/20230508-160019
git checkout cbc69d0c34bdbc06ebca3e3020cfc24034fcf173
# 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=i386 olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Link: https://lore.kernel.org/oe-kbuild-all/202305090112.uJSc0NBw-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

>> kernel/audit.c:651:6: warning: variable 'rtime' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
if (audit_queue_full(&audit_queue)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/audit.c:657:9: note: uninitialized use occurs here
return rtime;
^~~~~
kernel/audit.c:651:2: note: remove the 'if' if its condition is always true
if (audit_queue_full(&audit_queue)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/audit.c:642:12: note: initialize the variable 'rtime' to silence this warning
long rtime;
^
= 0
1 warning generated.


vim +651 kernel/audit.c

630
631 /**
632 * wait_for_kauditd - Wait for kauditd to drain the queue
633 * @stime: time to sleep
634 *
635 * Description:
636 * Waits for kauditd to drain the queue then adds duration of sleep time to
637 * audit_backlog_wait_time_actual as cumulative sum.
638 * Returns remaining time to sleep.
639 */
640 static long wait_for_kauditd(long stime)
641 {
642 long rtime;
643 DEFINE_WAIT(wait);
644
645 prepare_to_wait_exclusive(&audit_backlog_wait, &wait,
646 TASK_UNINTERRUPTIBLE);
647
648 /* need to check if the queue is full again because kauditd might have
649 * flushed the queue and went to sleep after prepare_to_wait_exclusive()
650 */
> 651 if (audit_queue_full(&audit_queue)) {
652 rtime = schedule_timeout(stime);
653 atomic_add(stime - rtime, &audit_backlog_wait_time_actual);
654 }
655 finish_wait(&audit_backlog_wait, &wait);
656
657 return rtime;
658 }
659

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