]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
UBUNTU: SAUCE: shiftfs: prevent ESTALE for LOOKUP_JUMP lookups
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 23 Jun 2020 17:46:16 +0000 (19:46 +0200)
committerPaolo Pisati <paolo.pisati@canonical.com>
Tue, 2 Nov 2021 07:24:49 +0000 (08:24 +0100)
commit72c529c6c93f58ef7e21d86efd339f1426b3e905
tree0d9f347579f0e31b11e4ed4c60e408462d59374a
parent7b94853790be893912667a43bf684eeb761acb89
UBUNTU: SAUCE: shiftfs: prevent ESTALE for LOOKUP_JUMP lookups

BugLink: https://bugs.launchpad.net/bugs/1872757
Users reported that creating temporary files shiftfs reports ESTALE.
This can be reproduced via:

import tempfile
import os

def test():
    with tempfile.TemporaryFile() as fd:
        fd.write("data".encode('utf-8'))
        # re-open the file to get a read-only file descriptor
        return open(f"/proc/self/fd/{fd.fileno()}", "r")

def main():
   fd = test()
   fd.close()

if __name__ == "__main__":
    main()

a similar issue was reported here:
https://github.com/systemd/systemd/issues/14861

Our revalidate methods were very opinionated about whether or not a
lower dentry was valid especially when it became unlinked we simply
invalidated the lower dentry which caused above bug to surface. This has
led to bugs where a ESTALE was returned for e.g.  temporary files that
were created and directly re-opened afterwards through
/proc/<pid>/fd/<nr-of-deleted-file>. When a file is re-opened through
/proc/<pid>/fd/<nr> LOOKUP_JUMP is set and the vfs will revalidate via
d_weak_revalidate(). Since the file has been unhashed or even already
gone negative we'd fail the open when we should've succeeded.

Reported-by: Christian Kellner <ckellner@redhat.com>
Reported-by: Evgeny Vereshchagin <evvers@ya.ru>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Seth Forshee <seth.forshee@canonical.com>
Link: https://github.com/systemd/systemd/issues/14861
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
fs/shiftfs.c