Re: [PATCH] /dev/kmem : Debug preadv() progress.

From: kbuild test robot
Date: Mon Aug 12 2019 - 18:24:48 EST


Hi Tetsuo,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[cannot apply to v5.3-rc4]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Tetsuo-Handa/dev-kmem-Debug-preadv-progress/20190813-044328
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=sh

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

drivers/char/mem.c: In function 'read_mem':
>> drivers/char/mem.c:145:27: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'ssize_t {aka int}' [-Wformat=]
printk("read_mem: sz=%ld count=%ld\n", sz, count);
~~^
%d
>> drivers/char/mem.c:145:37: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'size_t {aka unsigned int}' [-Wformat=]
printk("read_mem: sz=%ld count=%ld\n", sz, count);
~~^
%d
drivers/char/mem.c:187:28: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'ssize_t {aka int}' [-Wformat=]
printk("read_mem: read=%ld *ppos=%lld\n", read, *ppos);
~~^
%d

vim +145 drivers/char/mem.c

133
134 bounce = kmalloc(PAGE_SIZE, GFP_KERNEL);
135 if (!bounce)
136 return -ENOMEM;
137
138 while (count > 0) {
139 unsigned long remaining;
140 int allowed, probe;
141
142 sz = size_inside_page(p, count);
143 if (IS_ENABLED(CONFIG_DEBUG_AID_FOR_SYZBOT) &&
144 fatal_signal_pending(current))
> 145 printk("read_mem: sz=%ld count=%ld\n", sz, count);
146
147 err = -EPERM;
148 allowed = page_is_allowed(p >> PAGE_SHIFT);
149 if (!allowed)
150 goto failed;
151
152 err = -EFAULT;
153 if (allowed == 2) {
154 /* Show zeros for restricted memory. */
155 remaining = clear_user(buf, sz);
156 } else {
157 /*
158 * On ia64 if a page has been mapped somewhere as
159 * uncached, then it must also be accessed uncached
160 * by the kernel or data corruption may occur.
161 */
162 ptr = xlate_dev_mem_ptr(p);
163 if (!ptr)
164 goto failed;
165
166 probe = probe_kernel_read(bounce, ptr, sz);
167 unxlate_dev_mem_ptr(p, ptr);
168 if (probe)
169 goto failed;
170
171 remaining = copy_to_user(buf, bounce, sz);
172 }
173
174 if (remaining)
175 goto failed;
176
177 buf += sz;
178 p += sz;
179 count -= sz;
180 read += sz;
181 }
182 kfree(bounce);
183
184 *ppos += read;
185 if (IS_ENABLED(CONFIG_DEBUG_AID_FOR_SYZBOT) &&
186 fatal_signal_pending(current))
187 printk("read_mem: read=%ld *ppos=%lld\n", read, *ppos);
188 return read;
189
190 failed:
191 if (IS_ENABLED(CONFIG_DEBUG_AID_FOR_SYZBOT) &&
192 fatal_signal_pending(current))
193 printk("read_mem: err=%d\n", err);
194 kfree(bounce);
195 return err;
196 }
197

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

Attachment: .config.gz
Description: application/gzip