]> git.feebdaed.xyz Git - 0xmirror/crun.git/commit
utils: handle NULL container passed to libcrun_open_proc_file()
authorDominique Martinet <dominique.martinet@atmark-techno.com>
Mon, 22 Dec 2025 05:14:37 +0000 (14:14 +0900)
committerDominique Martinet <dominique.martinet@atmark-techno.com>
Mon, 22 Dec 2025 09:13:46 +0000 (18:13 +0900)
commit5bee6a06b5b58c27451f65ae9b5930a005a117f5
tree8190a76e56422e8c2a7aedfa63f3dec89106a594
parentc0011b8db90a71b9d273aaea89d8c3b1d7a78019
utils: handle NULL container passed to libcrun_open_proc_file()

It's possible for this function to be called with a NULL container when
called from run_process_child() -> mark_or_close_fds_ge_than() after
close_range() failed (old kernel or restricted syscall)

Handle this by opening a temporary /proc fd, which can be closed
immediately in libcrun_open_proc_file()

There are no other callers of libcrun_get_cached_proc_fd() at this
point, but such users would not need to worry about this fd potentially
leaking as long as container is a valid pointer, and even if they do
cause a leak in the future it's always better than a segfault.

Fixes: #1937
Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
src/libcrun/utils.c