memfd: use PROC_SELF instead of getpid in __open_proc

This looks better for me, should be no functional change.

Another implication of this is nested pid namespaces, when we will
support them "__open_proc(getpid()...)" will try to open file of the
process which has the same pid but in NS_ROOT pidns, which is bad.

See also aa2d92082 ("files: use PROC_SELF when a process accesses its
/proc/PID") for a similar change.

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
This commit is contained in:
Pavel Tikhomirov 2020-11-06 13:40:25 +03:00 committed by Andrei Vagin
parent 34024dfdcb
commit 0bb3d85863

View file

@ -332,7 +332,7 @@ int memfd_open(struct file_desc *d, u32 *fdflags)
* O_LARGEFILE file flag with regular open(). It doesn't seem that
* important though.
*/
_fd = __open_proc(getpid(), 0, flags, "fd/%d", fd);
_fd = __open_proc(PROC_SELF, 0, flags, "fd/%d", fd);
if (_fd < 0) {
pr_perror("Can't reopen memfd id=%d", mfe->id);
goto err;