2022-07-13 11:09:20

by Liu Xinpeng

[permalink] [raw]
Subject: [PATCH] iov_iter: Fix repeated minus operation

After executing command 'cat /proc/cpuinfo', got a message:

[ 6.909745] ------------[ cut here ]------------
[ 6.910267] WARNING: CPU: 0 PID: 76 at lib/iov_iter.c:1026
iov_iter_pipe+0x34/0x40
[ 6.910951] Modules linked in:
[ 6.911584] CPU: 0 PID: 76 Comm: cat Not tainted 5.19.0-rc6-next-20220711 #9
[ 6.911916] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014
[ 6.912668] RIP: 0010:iov_iter_pipe+0x34/0x40
[ 6.913062] Code: 72 54 39 72 5c 76 23 48 c7 07 00 00 00 00 48 c7 47 08 00 00
00 00 c6 07 03 48 89 4f 10 48 89 57 18 89 47 20 89 47 24 c3 0f 0b <0f> 7
[ 6.914341] RSP: 0018:ffffc900001c7d48 EFLAGS: 00000246
[ 6.914647] RAX: 0000000000000010 RBX: ffff888004988700 RCX: 0000000000000000
[ 6.914893] RDX: ffff88800490bc00 RSI: 0000000000000010 RDI: ffffc900001c7d58
[ 6.915302] RBP: ffffc900001c7e00 R08: 0000000000000000 R09: ffff888004cafad8
[ 6.915609] R10: 0000000000020000 R11: 0000000000001000 R12: ffff88800490bc00
[ 6.915856] R13: ffffc900001c7e48 R14: 00000000000002d5 R15: ffff88800490bc00
[ 6.916352] FS: 00000000016df8c0(0000) GS:ffff88800f600000(0000)

Checking the code, need to delete the duplicate minus in a loop.

Signed-off-by: Liu Xinpeng <[email protected]>
---
lib/iov_iter.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 4a3451e..642841ce 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -472,7 +472,6 @@ static size_t copy_pipe_to_iter(const void *addr, size_t bytes,
break;
memcpy_to_page(page, off, addr, chunk);
addr += chunk;
- n -= chunk;
}
return bytes;
}
--
1.8.3.1


2022-07-14 11:58:07

by Michael Walle

[permalink] [raw]
Subject: Re: [PATCH] iov_iter: Fix repeated minus operation

> After executing command 'cat /proc/cpuinfo', got a message:
>
> [ 6.909745] ------------[ cut here ]------------
> [ 6.910267] WARNING: CPU: 0 PID: 76 at lib/iov_iter.c:1026
> iov_iter_pipe+0x34/0x40
> [ 6.910951] Modules linked in:
> [ 6.911584] CPU: 0 PID: 76 Comm: cat Not tainted 5.19.0-rc6-next-20220711 #9
> [ 6.911916] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
> rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014
> [ 6.912668] RIP: 0010:iov_iter_pipe+0x34/0x40
> [ 6.913062] Code: 72 54 39 72 5c 76 23 48 c7 07 00 00 00 00 48 c7 47 08 00 00
> 00 00 c6 07 03 48 89 4f 10 48 89 57 18 89 47 20 89 47 24 c3 0f 0b <0f> 7
> [ 6.914341] RSP: 0018:ffffc900001c7d48 EFLAGS: 00000246
> [ 6.914647] RAX: 0000000000000010 RBX: ffff888004988700 RCX: 0000000000000000
> [ 6.914893] RDX: ffff88800490bc00 RSI: 0000000000000010 RDI: ffffc900001c7d58
> [ 6.915302] RBP: ffffc900001c7e00 R08: 0000000000000000 R09: ffff888004cafad8
> [ 6.915609] R10: 0000000000020000 R11: 0000000000001000 R12: ffff88800490bc00
> [ 6.915856] R13: ffffc900001c7e48 R14: 00000000000002d5 R15: ffff88800490bc00
> [ 6.916352] FS: 00000000016df8c0(0000) GS:ffff88800f600000(0000)

Thanks, I'm getting the same warning and also if you do a cat on any sysfs
file.

> Checking the code, need to delete the duplicate minus in a loop.
>
> Signed-off-by: Liu Xinpeng <[email protected]>

Fixes: 3d246b875f31 ("ITER_PIPE: allocate buffers as we go in copy-to-pipe primitives")
Tested-by: Michael Walle <[email protected]>

-michael

2022-07-15 01:19:42

by Al Viro

[permalink] [raw]
Subject: Re: [PATCH] iov_iter: Fix repeated minus operation

On Wed, Jul 13, 2022 at 06:23:40PM +0800, Liu Xinpeng wrote:
> After executing command 'cat /proc/cpuinfo', got a message:
>
> [ 6.909745] ------------[ cut here ]------------
> [ 6.910267] WARNING: CPU: 0 PID: 76 at lib/iov_iter.c:1026
> iov_iter_pipe+0x34/0x40
> [ 6.910951] Modules linked in:
> [ 6.911584] CPU: 0 PID: 76 Comm: cat Not tainted 5.19.0-rc6-next-20220711 #9
> [ 6.911916] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
> rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014
> [ 6.912668] RIP: 0010:iov_iter_pipe+0x34/0x40
> [ 6.913062] Code: 72 54 39 72 5c 76 23 48 c7 07 00 00 00 00 48 c7 47 08 00 00
> 00 00 c6 07 03 48 89 4f 10 48 89 57 18 89 47 20 89 47 24 c3 0f 0b <0f> 7
> [ 6.914341] RSP: 0018:ffffc900001c7d48 EFLAGS: 00000246
> [ 6.914647] RAX: 0000000000000010 RBX: ffff888004988700 RCX: 0000000000000000
> [ 6.914893] RDX: ffff88800490bc00 RSI: 0000000000000010 RDI: ffffc900001c7d58
> [ 6.915302] RBP: ffffc900001c7e00 R08: 0000000000000000 R09: ffff888004cafad8
> [ 6.915609] R10: 0000000000020000 R11: 0000000000001000 R12: ffff88800490bc00
> [ 6.915856] R13: ffffc900001c7e48 R14: 00000000000002d5 R15: ffff88800490bc00
> [ 6.916352] FS: 00000000016df8c0(0000) GS:ffff88800f600000(0000)
>
> Checking the code, need to delete the duplicate minus in a loop.

Nice catch. Fix folded in...