• Kees Cook's avatar
    net/scm: Regularize compat handling of scm_detach_fds() · c0029de5
    Kees Cook authored
    Duplicate the cleanups from commit 2618d530 ("net/scm: cleanup
    scm_detach_fds") into the compat code.
    
    Replace open-coded __receive_sock() with a call to the helper.
    
    Move the check added in commit 1f466e1f ("net: cleanly handle kernel
    vs user buffers for ->msg_control") to before the compat call, even
    though it should be impossible for an in-kernel call to also be compat.
    
    Correct the int "flags" argument to unsigned int to match fd_install()
    and similar APIs.
    
    Regularize any remaining differences, including a whitespace issue,
    a checkpatch warning, and add the check from commit 6900317f ("net,
    scm: fix PaX detected msg_controllen overflow in scm_detach_fds") which
    fixed an overflow unique to 64-bit. To avoid confusion when comparing
    the compat handler to the native handler, just include the same check
    in the compat handler.
    
    Cc: Christoph Hellwig <hch@lst.de>
    Cc: Sargun Dhillon <sargun@sargun.me>
    Cc: Jakub Kicinski <kuba@kernel.org>
    Cc: netdev@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Acked-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
    Signed-off-by: default avatarKees Cook <keescook@chromium.org>
    c0029de5
scm.c 8.74 KB