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

Al Viro
2020-11-16T03:30:11Z

On Sun, Nov 15, 2020 at 05:34:16PM -0700, Nathan Chancellor wrote:

> Still good.
>
> Tested-by: Nathan Chancellor <natechancellor@gmail.com>

Pushed into #fixes

> > BTW, is that call of readv() really coming from init? And if it
> > is, what version of init are you using?
>
> I believe that it is but since this is WSL2, I believe that /init is a
> proprietary Microsoft implementation, rather than systemd or another
> init system:
>
> https://wiki.ubuntu.com/WSL#Keeping_Ubuntu_Updated_in_WSL
>
> So I am not sure how possible it is to see exactly what is going on or
> getting it improved.

Oh, well... Anyway, as a regression test it's interesting:

#include <sys/uio.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
main()
{
static char s[1024];
static struct iovec v[2] = {{NULL, 0}, {s, 1024}};

for(;;) {
ssize_t n = readv(0, v, 2), m, w;

if (n < 0) {
perror("readv");
return -1;
}
if (!n)
return 0;
for (m = 0; m < n; m += w) {
w = write(1, s + m, n - m);
if (w < 0)
perror("write");
}
}
}

which ought to copy stdin to stdout; with this bug it would (on sufficiently
large seq_file-based files) fail with "readv: Bad address" (-EFAULT, that is).