bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#35137: [df] incorrect parsing of /proc/self/mountinfo with \r in mou


From: Bernhard Voelker
Subject: bug#35137: [df] incorrect parsing of /proc/self/mountinfo with \r in mount path
Date: Fri, 5 Apr 2019 09:01:00 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

On 4/4/19 9:52 AM, Zbigniew Jędrzejewski-Szmek wrote:
> See https://github.com/systemd/systemd/issues/12018 and
> https://github.com/karelzak/util-linux/issues/780 for additional context.
> 
> $ mkdir "$(echo -e foo\\rbar)"
> $ sudo mount -t tmpfs tmpfs foo^Mbar/
> $ cat -v /proc/self/mountinfo|grep foo
> 865 39 0:59 / /tmp/foo^Mbar rw,relatime shared:462 - tmpfs tmpfs rw,seclabel
> $ df -h | grep foo
> $ df -h /tmp/foo$'\r'bar
> Filesystem      Size  Used Avail Use% Mounted on
> -               3.9G     0  3.9G   0% /tmp/foo?bar
> 
> When asked to show all filesystems, the mount point is not shown at all.
> When asked to show just that one, df parses the mount point correctly,
> but it gets the filesystem type wrong.

Thanks for the report.

I see the issue is not yet solved in util-linux as well.
For coreutils, the fix is in gnulib.  Parsing the line is starting
to get ugly ... dirty patch attached.

This also caters for the issue that df(1) totally skips a file system
if the source is an empty string which is allowed for e.g. tmpfs:

  $ mount -t tmpfs '' /mnt
  $ df -h | grep mnt

At least util-linux' findmnt has already worked around that case, see
https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/commit/?id=18a52a5094f8

Finally, other users of gnulib/lib/mountlist.c are also affected.

Have a nice day,
Berny

Attachment: mountlist.diff
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]