Hi There! Because this is a global variable, it appears to be exploitable. Either we generate a sufficient number of processes to achieve this counter, or you increase the open file limit with ulimit or sysctl. Unless the kernel has a hard restriction on the number of potential file descriptors that I'm not aware of. In any case, it's probably a good idea to patch this to make it explicitly secure. If you discover a hard-limit in the kernel for open file descriptors, please let me know. I'm genuinely interested :D! Best Regards, Jordy > On 08/20/2021 12:05 PM Kees Cook <keescook@xxxxxxxxxxxx> wrote: > > > On Fri, Aug 20, 2021 at 07:57:25AM -0700, James Bottomley wrote: > > On Fri, 2021-08-20 at 06:33 +0200, Jordy Zomer wrote: > > > As you can see there's an `atomic_inc` for each `memfd` that is > > > opened in the `memfd_secret` syscall. If a local attacker succeeds to > > > open 2^32 memfd's, the counter will wrap around to 0. This implies > > > that you may hibernate again, even though there are still regions of > > > this secret memory, thereby bypassing the security check. > > > > This isn't a possible attack, is it? secret memory is per process and > > each process usually has an open fd limit of 1024. That's not to say > > we shouldn't have overflow protection just in case, but I think today > > we don't have a problem. > > But it's a _global_ setting, so it's still possible, though likely > impractical today. But refcount_t mitigates it and is a trivial change. > :) > > -- > Kees Cook