Re: [PATCH v2 1/1] binfmt_elf, coredump: Log the reason of the failed core dumps

From: kernel test robot
Date: Sat Jul 13 2024 - 01:30:22 EST


Hi Roman,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 831bcbcead6668ebf20b64fdb27518f1362ace3a]

url: https://github.com/intel-lab-lkp/linux/commits/Roman-Kisel/binfmt_elf-coredump-Log-the-reason-of-the-failed-core-dumps/20240713-055749
base: 831bcbcead6668ebf20b64fdb27518f1362ace3a
patch link: https://lore.kernel.org/r/20240712215223.605363-2-romank%40linux.microsoft.com
patch subject: [PATCH v2 1/1] binfmt_elf, coredump: Log the reason of the failed core dumps
config: arm-allnoconfig (https://download.01.org/0day-ci/archive/20240713/202407131345.6cPoXZGa-lkp@xxxxxxxxx/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project a0c6b8aef853eedaa0980f07c0a502a5a8a9740e)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240713/202407131345.6cPoXZGa-lkp@xxxxxxxxx/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@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202407131345.6cPoXZGa-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

In file included from fs/coredump.c:6:
In file included from include/linux/mm.h:2253:
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
514 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
>> fs/coredump.c:875:34: warning: format specifies type 'long' but the argument has type 'ssize_t' (aka 'int') [-Wformat]
874 | pr_err_ratelimited("Core dump of %s(PID %d) failed when writing out, error %ld\n",
| ~~~
| %zd
875 | current->comm, current->pid, n);
| ^
include/linux/printk.h:672:45: note: expanded from macro 'pr_err_ratelimited'
672 | printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
| ~~~ ^~~~~~~~~~~
include/linux/printk.h:658:17: note: expanded from macro 'printk_ratelimited'
658 | printk(fmt, ##__VA_ARGS__); \
| ~~~ ^~~~~~~~~~~
include/linux/printk.h:464:60: note: expanded from macro 'printk'
464 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
| ~~~ ^~~~~~~~~~~
include/linux/printk.h:436:19: note: expanded from macro 'printk_index_wrap'
436 | _p_func(_fmt, ##__VA_ARGS__); \
| ~~~~ ^~~~~~~~~~~
fs/coredump.c:878:34: warning: format specifies type 'long' but the argument has type 'ssize_t' (aka 'int') [-Wformat]
877 | pr_err_ratelimited("Core dump of %s(PID %d) partially written out, only %ld(of %d) bytes written\n",
| ~~~
| %zd
878 | current->comm, current->pid, n, nr);
| ^
include/linux/printk.h:672:45: note: expanded from macro 'pr_err_ratelimited'
672 | printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
| ~~~ ^~~~~~~~~~~
include/linux/printk.h:658:17: note: expanded from macro 'printk_ratelimited'
658 | printk(fmt, ##__VA_ARGS__); \
| ~~~ ^~~~~~~~~~~
include/linux/printk.h:464:60: note: expanded from macro 'printk'
464 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
| ~~~ ^~~~~~~~~~~
include/linux/printk.h:436:19: note: expanded from macro 'printk_index_wrap'
436 | _p_func(_fmt, ##__VA_ARGS__); \
| ~~~~ ^~~~~~~~~~~
3 warnings generated.


vim +875 fs/coredump.c

854
855 /*
856 * Core dumping helper functions. These are the only things you should
857 * do on a core-file: use only these functions to write out all the
858 * necessary info.
859 */
860 static int __dump_emit(struct coredump_params *cprm, const void *addr, int nr)
861 {
862 struct file *file = cprm->file;
863 loff_t pos = file->f_pos;
864 ssize_t n;
865 if (cprm->written + nr > cprm->limit)
866 return 0;
867
868
869 if (dump_interrupted())
870 return 0;
871 n = __kernel_write(file, addr, nr, &pos);
872 if (n != nr) {
873 if (n < 0)
874 pr_err_ratelimited("Core dump of %s(PID %d) failed when writing out, error %ld\n",
> 875 current->comm, current->pid, n);
876 else
877 pr_err_ratelimited("Core dump of %s(PID %d) partially written out, only %ld(of %d) bytes written\n",
878 current->comm, current->pid, n, nr);
879
880 return 0;
881 }
882 file->f_pos = pos;
883 cprm->written += n;
884 cprm->pos += n;
885
886 return 1;
887 }
888

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