From 0bb3d85863e71b750511e5fa1123a1c5a135bf72 Mon Sep 17 00:00:00 2001 From: Pavel Tikhomirov Date: Fri, 6 Nov 2020 13:40:25 +0300 Subject: [PATCH] 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 --- criu/memfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/criu/memfd.c b/criu/memfd.c index 4419b4bf5..6c243a509 100644 --- a/criu/memfd.c +++ b/criu/memfd.c @@ -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;