[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241119-sockptr-copy-fixes-v3-2-d752cac4be8e@rbox.co>
Date: Tue, 19 Nov 2024 14:31:41 +0100
From: Michal Luczaj <mhal@...x.co>
To: Marcel Holtmann <marcel@...tmann.org>,
Johan Hedberg <johan.hedberg@...il.com>,
Luiz Augusto von Dentz <luiz.dentz@...il.com>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>,
David Howells <dhowells@...hat.com>, Marc Dionne <marc.dionne@...istor.com>
Cc: Luiz Augusto von Dentz <luiz.von.dentz@...el.com>,
linux-bluetooth@...r.kernel.org, netdev@...r.kernel.org,
linux-afs@...ts.infradead.org, Jakub Kicinski <kuba@...nel.org>,
Michal Luczaj <mhal@...x.co>, David Wei <dw@...idwei.uk>
Subject: [PATCH net v3 2/4] llc: Improve setsockopt() handling of malformed
user input
copy_from_sockptr() is used incorrectly: return value is the number of
bytes that could not be copied. Since it's deprecated, switch to
copy_safe_from_sockptr().
Note: Keeping the `optlen != sizeof(int)` check as copy_safe_from_sockptr()
by itself would also accept optlen > sizeof(int). Which would allow a more
lenient handling of inputs.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Suggested-by: David Wei <dw@...idwei.uk>
Signed-off-by: Michal Luczaj <mhal@...x.co>
---
net/llc/af_llc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 4eb52add7103b0f83d6fe7318abf1d1af533d254..0259cde394ba09795a6bf0d44c4ea6767e200aea 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -1098,7 +1098,7 @@ static int llc_ui_setsockopt(struct socket *sock, int level, int optname,
lock_sock(sk);
if (unlikely(level != SOL_LLC || optlen != sizeof(int)))
goto out;
- rc = copy_from_sockptr(&opt, optval, sizeof(opt));
+ rc = copy_safe_from_sockptr(&opt, sizeof(opt), optval, optlen);
if (rc)
goto out;
rc = -EINVAL;
--
2.46.2
Powered by blists - more mailing lists