Re: [PATCH RFC 0/4] fs: port files to rcuref_long_t

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

 



On Sat, 5 Oct 2024 at 15:01, Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
>
> I wouldn't bet on that.  You *can* get over 2G references on 64bit box
> with arseloads of memory, and we have no way to make fget() et.al.
> fail when refcount gets that high - no valid error to return and
> a serious DoS potential if we start doing that.

Why do you think we can't make fget() fail?

That's what we did for the page count, and it worked just fine. Two
billion file references is not a valid thing - it's an attack.

We don't have to fix every file ref increment - the same way we didn't
fix all the get_page() cases. We only need to fix the ones that are
directly triggerable from user accesses (ie temporary kernel refs are
fine).

And the main case that is user-accessible is exactly the fget()
variatiosn that result in get_file_rcu(). It's perfectly fine to say
"nope, I'm not getting you this file, you're clearly a bad person".

There are probably other cases that just do "get_file()" on an
existing 'struct file *" directly, but it's usually fairly hard to get
users to refer to file pointers without giving an actual file
descriptor number. But things like "split a vma" will do it (on the
file that is mapped), and probably a few other cases, but I bet it
really is just a few cases.

That said, the simple "atomic_inc_return()" suggestion of mine was
broken for other reasons anyway.

So I do think it needs some of the rcuref code complexity with the
rcuref_put_slowpath() turning the last ref into RCUREF_DEAD).

                 Linus




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux