From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Eric Dumazet <edumazet@google.com>,
Kees Cook <keescook@chromium.org>,
"David S . Miller" <davem@davemloft.net>,
Sasha Levin <sashal@kernel.org>,
kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 6.2 53/53] scm: add user copy checks to put_cmsg()
Date: Sun, 26 Feb 2023 09:44:45 -0500 [thread overview]
Message-ID: <20230226144446.824580-53-sashal@kernel.org> (raw)
In-Reply-To: <20230226144446.824580-1-sashal@kernel.org>
From: Eric Dumazet <edumazet@google.com>
[ Upstream commit 5f1eb1ff58ea122e24adf0bc940f268ed2227462 ]
This is a followup of commit 2558b8039d05 ("net: use a bounce
buffer for copying skb->mark")
x86 and powerpc define user_access_begin, meaning
that they are not able to perform user copy checks
when using user_write_access_begin() / unsafe_copy_to_user()
and friends [1]
Instead of waiting bugs to trigger on other arches,
add a check_object_size() in put_cmsg() to make sure
that new code tested on x86 with CONFIG_HARDENED_USERCOPY=y
will perform more security checks.
[1] We can not generically call check_object_size() from
unsafe_copy_to_user() because UACCESS is enabled at this point.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Kees Cook <keescook@chromium.org>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/core/scm.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/core/scm.c b/net/core/scm.c
index 5c356f0dee30c..acb7d776fa6ec 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -229,6 +229,8 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
if (msg->msg_control_is_user) {
struct cmsghdr __user *cm = msg->msg_control_user;
+ check_object_size(data, cmlen - sizeof(*cm), true);
+
if (!user_write_access_begin(cm, cmlen))
goto efault;
--
2.39.0
prev parent reply other threads:[~2023-02-26 14:48 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-26 14:43 [PATCH AUTOSEL 6.2 01/53] wifi: ath9k: Fix use-after-free in ath9k_hif_usb_disconnect() Sasha Levin
2023-02-26 14:43 ` [PATCH AUTOSEL 6.2 02/53] wifi: ath11k: fix monitor mode bringup crash Sasha Levin
2023-02-26 14:43 ` [PATCH AUTOSEL 6.2 03/53] wifi: brcmfmac: Fix potential stack-out-of-bounds in brcmf_c_preinit_dcmds() Sasha Levin
2023-02-26 14:44 ` [PATCH AUTOSEL 6.2 09/53] wifi: ath11k: debugfs: fix to work with multiple PCI devices Sasha Levin
2023-02-26 14:44 ` [PATCH AUTOSEL 6.2 14/53] wifi: brcmfmac: ensure CLM version is null-terminated to prevent stack-out-of-bounds Sasha Levin
2023-02-26 14:44 ` [PATCH AUTOSEL 6.2 15/53] wifi: rtw89: fix assignation of TX BD RAM table Sasha Levin
2023-02-26 14:44 ` [PATCH AUTOSEL 6.2 16/53] wifi: mt7601u: fix an integer underflow Sasha Levin
2023-02-26 14:44 ` [PATCH AUTOSEL 6.2 17/53] inet: fix fast path in __inet_hash_connect() Sasha Levin
2023-02-26 14:44 ` [PATCH AUTOSEL 6.2 18/53] ice: restrict PTP HW clock freq adjustments to 100, 000, 000 PPB Sasha Levin
2023-02-26 14:44 ` [PATCH AUTOSEL 6.2 19/53] ice: add missing checks for PF vsi type Sasha Levin
2023-02-26 14:44 ` [PATCH AUTOSEL 6.2 26/53] netpoll: Remove 4s sleep during carrier detection Sasha Levin
2023-02-27 18:15 ` Jakub Kicinski
2023-03-01 2:10 ` Sasha Levin
2023-02-26 14:44 ` [PATCH AUTOSEL 6.2 27/53] net: bcmgenet: Add a check for oversized packets Sasha Levin
2023-02-26 14:44 ` [PATCH AUTOSEL 6.2 30/53] netfilter: nf_tables: NULL pointer dereference in nf_tables_updobj() Sasha Levin
2023-02-26 14:44 ` [PATCH AUTOSEL 6.2 31/53] neighbor: fix proxy_delay usage when it is zero Sasha Levin
2023-02-27 18:15 ` Jakub Kicinski
2023-03-01 14:13 ` Sasha Levin
2023-02-26 14:44 ` [PATCH AUTOSEL 6.2 32/53] can: isotp: check CAN address family in isotp_bind() Sasha Levin
2023-02-26 14:44 ` [PATCH AUTOSEL 6.2 36/53] wifi: mt76: dma: free rx_head in mt76_dma_rx_cleanup Sasha Levin
2023-02-26 14:44 ` [PATCH AUTOSEL 6.2 38/53] net/mlx5: fw_tracer: Fix debug print Sasha Levin
2023-02-26 14:44 ` [PATCH AUTOSEL 6.2 48/53] wifi: rtw89: debug: avoid invalid access on RTW89_DBG_SEL_MAC_30 Sasha Levin
2023-02-26 14:44 ` [PATCH AUTOSEL 6.2 49/53] hv_netvsc: Check status in SEND_RNDIS_PKT completion message Sasha Levin
2023-02-26 14:44 ` [PATCH AUTOSEL 6.2 51/53] devlink: health: Fix nla_nest_end in error flow Sasha Levin
2023-02-27 18:13 ` Jakub Kicinski
2023-03-01 14:13 ` Sasha Levin
2023-02-26 14:44 ` Sasha Levin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230226144446.824580-53-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=keescook@chromium.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).