• Kees Cook's avatar
    fs: Add receive_fd() wrapper for __receive_fd() · deefa7f3
    Kees Cook authored
    For both pidfd and seccomp, the __user pointer is not used. Update
    __receive_fd() to make writing to ufd optional via a NULL check. However,
    for the receive_fd_user() wrapper, ufd is NULL checked so an -EFAULT
    can be returned to avoid changing the SCM_RIGHTS interface behavior. Add
    new wrapper receive_fd() for pidfd and seccomp that does not use the ufd
    argument. For the new helper, the allocated fd needs to be returned on
    success. Update the existing callers to handle it.
    
    Cc: Alexander Viro <viro@zeniv.linux.org.uk>
    Cc: linux-fsdevel@vger.kernel.org
    Reviewed-by: default avatarSargun Dhillon <sargun@sargun.me>
    Acked-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
    Signed-off-by: default avatarKees Cook <keescook@chromium.org>
    deefa7f3
scm.c 8.3 KB