]> git.baikalelectronics.ru Git - kernel.git/commit
net/scm: Regularize compat handling of scm_detach_fds()
authorKees Cook <keescook@chromium.org>
Tue, 9 Jun 2020 23:11:29 +0000 (16:11 -0700)
committerKees Cook <keescook@chromium.org>
Mon, 13 Jul 2020 18:03:44 +0000 (11:03 -0700)
commitc085ddf6bdb741eacccd4c6c33fdcc9fe40fb125
tree3452e01c860c87aa389cb5f4f5f95f629173fd00
parentdea12ce84ff68bb161412243677f77bceaa3ef71
net/scm: Regularize compat handling of scm_detach_fds()

Duplicate the cleanups from commit eb1960064e26 ("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 4126eac58915 ("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 067b771ceca1 ("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: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
include/net/scm.h
net/compat.c
net/core/scm.c