Re: [PATCH 1/6] seq_file: add seq_read_iter

Nathan Chancellor
2020-11-14T03:01:51Z

On Sat, Nov 14, 2020 at 01:17:54AM +0000, Al Viro wrote:
> On Fri, Nov 13, 2020 at 04:54:53PM -0700, Nathan Chancellor wrote:
>
> > This patch in -next (6a9f696d1627bacc91d1cebcfb177f474484e8ba) breaks
> > WSL2's interoperability feature, where Windows paths automatically get
> > added to PATH on start up so that Windows binaries can be accessed from
> > within Linux (such as clip.exe to pipe output to the clipboard). Before,
> > I would see a bunch of Linux + Windows folders in $PATH but after, I
> > only see the Linux folders (I can give you the actual PATH value if you
> > care but it is really long).
> >
> > I am not at all familiar with the semantics of this patch or how
> > Microsoft would be using it to inject folders into PATH (they have some
> > documentation on it here:
> > https://docs.microsoft.com/en-us/windows/wsl/interop) and I am not sure
> > how to go about figuring that out to see why this patch breaks something
> > (unless you have an idea). I have added the Hyper-V maintainers and list
> > to CC in case they know someone who could help.
>
> Out of curiosity: could you slap WARN_ON(!iov_iter_count(iter)); right in
> the beginning of seq_read_iter() and see if that triggers?

Sure thing, it does trigger.

[ 0.235058] ------------[ cut here ]------------
[ 0.235062] WARNING: CPU: 15 PID: 237 at fs/seq_file.c:176 seq_read_iter+0x3b3/0x3f0
[ 0.235064] CPU: 15 PID: 237 Comm: localhost Not tainted 5.10.0-rc2-microsoft-cbl-00002-g6a9f696d1627-dirty #15
[ 0.235065] RIP: 0010:seq_read_iter+0x3b3/0x3f0
[ 0.235066] Code: ba 01 00 00 00 e8 6d d2 fc ff 4c 89 e7 48 89 ee 48 8b 54 24 10 e8 ad 8b 45 00 49 01 c5 48 29 43 18 48 89 43 10 e9 61 fe ff ff <0f> 0b e9 6f fc ff ff 0f 0b 45 31 ed e9 0d fd ff ff 48 c7 43 18 00
[ 0.235067] RSP: 0018:ffff9c774063bd08 EFLAGS: 00010246
[ 0.235068] RAX: ffff91a77ac01f00 RBX: ffff91a50133c348 RCX: 0000000000000001
[ 0.235069] RDX: ffff9c774063bdb8 RSI: ffff9c774063bd60 RDI: ffff9c774063bd88
[ 0.235069] RBP: 0000000000000000 R08: 0000000000000000 R09: ffff91a50058b768
[ 0.235070] R10: ffff91a7f79f0000 R11: ffffffffbc2c2030 R12: ffff9c774063bd88
[ 0.235070] R13: ffff9c774063bd60 R14: ffff9c774063be48 R15: ffff91a77af58900
[ 0.235072] FS: 000000000029c800(0000) GS:ffff91a7f7bc0000(0000) knlGS:0000000000000000
[ 0.235073] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 0.235073] CR2: 00007ab6c1fabad0 CR3: 000000037a004000 CR4: 0000000000350ea0
[ 0.235074] Call Trace:
[ 0.235077] seq_read+0x127/0x150
[ 0.235078] proc_reg_read+0x42/0xa0
[ 0.235080] do_iter_read+0x14c/0x1e0
[ 0.235081] do_readv+0x18d/0x240
[ 0.235083] do_syscall_64+0x33/0x70
[ 0.235085] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[ 0.235086] RIP: 0033:0x22c483
[ 0.235086] Code: 4e 66 48 0f 7e c8 48 83 f8 01 48 89 d0 48 83 d0 ff 48 89 46 08 66 0f 7f 46 10 48 63 7f 78 b8 13 00 00 00 ba 02 00 00 00 0f 05 <48> 89 c7 e8 15 bb ff ff 48 85 c0 7e 34 48 89 c1 48 2b 4c 24 08 76
[ 0.235087] RSP: 002b:00007ffca2245ca0 EFLAGS: 00000257 ORIG_RAX: 0000000000000013
[ 0.235088] RAX: ffffffffffffffda RBX: 0000000000a58120 RCX: 000000000022c483
[ 0.235088] RDX: 0000000000000002 RSI: 00007ffca2245ca0 RDI: 0000000000000005
[ 0.235089] RBP: 00000000ffffffff R08: fefefefefefefeff R09: 8080808080808080
[ 0.235089] R10: 00007ab6c1fabb20 R11: 0000000000000257 R12: 0000000000a58120
[ 0.235089] R13: 00007ffca2245d90 R14: 0000000000000001 R15: 00007ffca2245ce7
[ 0.235091] CPU: 15 PID: 237 Comm: localhost Not tainted 5.10.0-rc2-microsoft-cbl-00002-g6a9f696d1627-dirty #15
[ 0.235091] Call Trace:
[ 0.235092] dump_stack+0xa1/0xfb
[ 0.235094] __warn+0x7f/0x120
[ 0.235095] ? seq_read_iter+0x3b3/0x3f0
[ 0.235096] report_bug+0xb1/0x110
[ 0.235097] handle_bug+0x3d/0x70
[ 0.235098] exc_invalid_op+0x18/0xb0
[ 0.235098] asm_exc_invalid_op+0x12/0x20
[ 0.235100] RIP: 0010:seq_read_iter+0x3b3/0x3f0
[ 0.235100] Code: ba 01 00 00 00 e8 6d d2 fc ff 4c 89 e7 48 89 ee 48 8b 54 24 10 e8 ad 8b 45 00 49 01 c5 48 29 43 18 48 89 43 10 e9 61 fe ff ff <0f> 0b e9 6f fc ff ff 0f 0b 45 31 ed e9 0d fd ff ff 48 c7 43 18 00
[ 0.235101] RSP: 0018:ffff9c774063bd08 EFLAGS: 00010246
[ 0.235101] RAX: ffff91a77ac01f00 RBX: ffff91a50133c348 RCX: 0000000000000001
[ 0.235102] RDX: ffff9c774063bdb8 RSI: ffff9c774063bd60 RDI: ffff9c774063bd88
[ 0.235102] RBP: 0000000000000000 R08: 0000000000000000 R09: ffff91a50058b768
[ 0.235103] R10: ffff91a7f79f0000 R11: ffffffffbc2c2030 R12: ffff9c774063bd88
[ 0.235103] R13: ffff9c774063bd60 R14: ffff9c774063be48 R15: ffff91a77af58900
[ 0.235104] ? seq_open+0x70/0x70
[ 0.235105] ? path_openat+0xbc0/0xc40
[ 0.235106] seq_read+0x127/0x150
[ 0.235107] proc_reg_read+0x42/0xa0
[ 0.235108] do_iter_read+0x14c/0x1e0
[ 0.235109] do_readv+0x18d/0x240
[ 0.235109] do_syscall_64+0x33/0x70
[ 0.235110] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[ 0.235111] RIP: 0033:0x22c483
[ 0.235111] Code: 4e 66 48 0f 7e c8 48 83 f8 01 48 89 d0 48 83 d0 ff 48 89 46 08 66 0f 7f 46 10 48 63 7f 78 b8 13 00 00 00 ba 02 00 00 00 0f 05 <48> 89 c7 e8 15 bb ff ff 48 85 c0 7e 34 48 89 c1 48 2b 4c 24 08 76
[ 0.235112] RSP: 002b:00007ffca2245ca0 EFLAGS: 00000257 ORIG_RAX: 0000000000000013
[ 0.235113] RAX: ffffffffffffffda RBX: 0000000000a58120 RCX: 000000000022c483
[ 0.235113] RDX: 0000000000000002 RSI: 00007ffca2245ca0 RDI: 0000000000000005
[ 0.235113] RBP: 00000000ffffffff R08: fefefefefefefeff R09: 8080808080808080
[ 0.235114] R10: 00007ab6c1fabb20 R11: 0000000000000257 R12: 0000000000a58120
[ 0.235114] R13: 00007ffca2245d90 R14: 0000000000000001 R15: 00007ffca2245ce7
[ 0.235115] ---[ end trace 92966dbcf1e9cae5 ]---

Cheers,
Nathan