Skip to content

Commit f60d38c

Browse files
ea1davisbrauner
authored andcommitted
pidfs: when time ns disabled add check for ioctl
syzbot call pidfd_ioctl() with cmd "PIDFD_GET_TIME_NAMESPACE" and disabled CONFIG_TIME_NS, since time_ns is NULL, it will make NULL ponter deref in open_namespace. Fixes: 5b08bd4 ("pidfs: allow retrieval of namespace file descriptors") # mainline only Reported-and-tested-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=34a0ee986f61f15da35d Signed-off-by: Edward Adam Davis <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent b40c8e7 commit f60d38c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/pidfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ static long pidfd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
168168
case PIDFD_GET_TIME_NAMESPACE:
169169
get_time_ns(nsp->time_ns);
170170
ns_common = to_ns_common(nsp->time_ns);
171+
if (!nsp->time_ns)
172+
return -EINVAL;
171173
break;
172174
case PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE:
173175
get_time_ns(nsp->time_ns_for_children);

0 commit comments

Comments
 (0)