Skip to content

Commit

Permalink
images: Add protobuf definition for pidfd
Browse files Browse the repository at this point in the history
We only use the last pid from the list in NSpid entry (from
/proc/<pid>/fdinfo/<pidfd>) while restoring pidfds.
The last pid refers to the pid of the process in the most deeply nested
pid namespace. Since CRIU does not currently support nested pid
namespaces, this entry is the one we want.

After Linux 6.9, inode numbers can be used to compare pidfds. pidfds
referring to the same process will have the same inode numbers. We use
inode numbers to restore pidfds that point to dead processes.

Signed-off-by: Bhavik Sachdev <[email protected]>
  • Loading branch information
bsach64 committed Aug 11, 2024
1 parent b7f6b72 commit 371ccab
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions images/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ proto-obj-y += bpfmap-file.o
proto-obj-y += bpfmap-data.o
proto-obj-y += apparmor.o
proto-obj-y += rseq.o
proto-obj-y += pidfd.o

CFLAGS += -iquote $(obj)/

Expand Down
3 changes: 3 additions & 0 deletions images/fdinfo.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import "ext-file.proto";
import "sk-unix.proto";
import "fifo.proto";
import "pipe.proto";
import "pidfd.proto";
import "tty.proto";
import "memfd.proto";
import "bpfmap-file.proto";
Expand All @@ -42,6 +43,7 @@ enum fd_types {
TIMERFD = 17;
MEMFD = 18;
BPFMAP = 19;
PIDFD = 20;

/* Any number above the real used. Not stored to image */
CTL_TTY = 65534;
Expand Down Expand Up @@ -78,4 +80,5 @@ message file_entry {
optional tty_file_entry tty = 19;
optional memfd_file_entry memfd = 20;
optional bpfmap_file_entry bpf = 21;
optional pidfd_entry pidfd = 22;
}
13 changes: 13 additions & 0 deletions images/pidfd.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: MIT

syntax = "proto2";

import "fown.proto";

message pidfd_entry {
required uint32 id = 1;
required uint32 ino = 2;
required uint32 flags = 3;
required int32 nspid = 4;
required fown_entry fown = 5;
}

0 comments on commit 371ccab

Please sign in to comment.