lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 26 Oct 2016 11:17:13 +0200
From:   Miklos Szeredi <miklos@...redi.hu>
To:     Tomasz Majchrzak <tomasz.majchrzak@...el.com>
Cc:     LKML <linux-kernel@...r.kernel.org>, dan.j.williams@...el.com,
        Al Viro <viro@...iv.linux.org.uk>,
        aleksey.obitotskiy@...el.com, pawel.baldysiak@...el.com,
        artur.paszkiewicz@...el.com, maksymilian.kunt@...el.com
Subject: Re: [PATCH v2][RESEND] seq_file: don't set read position for invalid iterator

On Wed, Oct 12, 2016 at 2:07 PM, Tomasz Majchrzak
<tomasz.majchrzak@...el.com> wrote:
> If kernfs file is empty on a first read, successive read operations
> using the same file descriptor will return no data, even when data is
> available. Default kernfs 'seq_next' implementation advances iterator
> position even when next object is not there. Kernfs 'seq_start' for
> following requests will not return iterator as position is already on
> the second object.
>
> This bug doesn't allow to monitor badblocks sysfs files from MD raid.
> They are initially empty but if data appears at some stage, userspace is
> not able to read it. It doesn't affect any released applications but it
> is necessary for upcoming bad block support for external metadata in MD
> raid.

What is the expectation from the userspace application?  Should
seq_file support "tail -f" as more data is added to the file?  AFAICS
this patch doesn't address that generally, just the empty->nonempty
transition (with the single record case).

Why does userspace app not do open+read+close each time it polls the
badblocks file?

Thanks,
Miklos







>
> Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@...el.com>
> Reviewed-by: Dan Williams <dan.j.williams@...el.com>
> ---
>  fs/seq_file.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> diff --git a/fs/seq_file.c b/fs/seq_file.c
> index 6dc4296..74197f4 100644
> --- a/fs/seq_file.c
> +++ b/fs/seq_file.c
> @@ -235,7 +235,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
>         p = m->op->start(m, &pos);
>         while (1) {
>                 err = PTR_ERR(p);
> -               if (!p || IS_ERR(p))
> +               if (IS_ERR_OR_NULL(p))
>                         break;
>                 err = m->op->show(m, p);
>                 if (err < 0)
> @@ -244,7 +244,8 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
>                         m->count = 0;
>                 if (unlikely(!m->count)) {
>                         p = m->op->next(m, p, &pos);
> -                       m->index = pos;
> +                       if (!IS_ERR_OR_NULL(p))
> +                               m->index = pos;
>                         continue;
>                 }
>                 if (m->count < m->size)
> --
> 1.8.3.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ