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:   Fri, 11 Dec 2020 14:14:42 +0200
From:   Amir Goldstein <amir73il@...il.com>
To:     Jan Kara <jack@...e.cz>
Cc:     Hugh Dickins <hughd@...gle.com>,
        linux-fsdevel <linux-fsdevel@...r.kernel.org>,
        linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: linux-next fsnotify mod breaks tail -f

On Fri, Dec 11, 2020 at 12:47 PM Jan Kara <jack@...e.cz> wrote:
>
> On Fri 11-12-20 10:42:16, Amir Goldstein wrote:
> > On Fri, Dec 11, 2020 at 1:45 AM Hugh Dickins <hughd@...gle.com> wrote:
> > >
> > > Hi Jan, Amir,
> > >
> > > There's something wrong with linux-next commit ca7fbf0d29ab
> > > ("fsnotify: fix events reported to watching parent and child").
> > >
> > > If I revert that commit, no problem;
> > > but here's a one-line script "tailed":
> > >
> > > for i in 1 2 3 4 5; do date; sleep 1; done &
> > >
> > > Then if I run that (same result doing ./tailed after chmod a+x):
> > >
> > > sh tailed >log; tail -f log
> > >
> > > the "tail -f log" behaves in one of three ways:
> > >
> > > 1) On a console, before graphical screen, no problem,
> > >    it shows the five lines coming from "date" as you would expect.
> > > 2) From xterm or another tty, shows just the first line from date,
> > >    but after I wait and Ctrl-C out, "cat log" shows all five lines.
> > > 3) From xterm or another tty, doesn't even show that first line.
> > >
> > > The before/after graphical screen thing seems particularly weird:
> > > I expect you'll end up with a simpler explanation for what's
> > > causing that difference.
> > >
> > > tailed and log are on ext4, if that's relevant;
> > > ah, I just tried on tmpfs, and saw no problem there.
> >
> > Nice riddle Hugh :)
> > Thanks for this early testing!
> >
> > I was able to reproduce this.
> > The outcome does not depend on the type of terminal or filesystem
> > it depends on the existence of a watch on the parent dir of the log file.
> > Running ' inotifywait -m . &' will stop tail from getting notifications:
> >
> > echo > log
> > tail -f log &
> > sleep 1
> > echo "can you see this?" >> log
> > inotifywait -m . &
> > sleep 1
> > echo "how about this?" >> log
> > kill $(jobs -p)
> >
> > I suppose with a graphical screen you have systemd or other services
> > in the system watching the logs/home dir in your test env.
> >
> > Attached fix patch. I suppose Jan will want to sqhash it.
> >
> > We missed a subtle logic change in the switch from inode/child marks
> > to parent/inode marks terminology.
> >
> > Before the change (!inode_mark && child_mark) meant that name
> > was not NULL and should be discarded (which the old code did).
> > After the change (!parent_mark && inode_mark) is not enough to
> > determine if name should be discarded (it should be discarded only
> > for "events on child"), so another check is needed.
>
> Thanks for testing Hugh and for a quick fix Amir! I've folded it into the
> original buggy commit.
>

Test for original commit [1] extended to cover this bug as well:
Test #1: Group with child watches and other group with parent watch

Cheers,
Amir.

[1] https://github.com/amir73il/ltp/commits/fsnotify-fixes

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ