fs: use acquire ordering in __fget_light()
authorJann Horn <jannh@google.com>
Mon, 31 Oct 2022 17:52:56 +0000 (18:52 +0100)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 31 Oct 2022 19:30:11 +0000 (15:30 -0400)
commit7ee47dcfff1835ff75a794d1075b6b5f5462cfed
tree42d8767ff75c33525b7bc0ba0a05e112b7958200
parent9abf2313adc1ca1b6180c508c25f22f9395cc780
fs: use acquire ordering in __fget_light()

We must prevent the CPU from reordering the files->count read with the
FD table access like this, on architectures where read-read reordering is
possible:

    files_lookup_fd_raw()
                                  close_fd()
                                  put_files_struct()
    atomic_read(&files->count)

I would like to mark this for stable, but the stable rules explicitly say
"no theoretical races", and given that the FD table pointer and
files->count are explicitly stored in the same cacheline, this sort of
reordering seems quite unlikely in practice...

Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/file.c