Skip to contentSkip to conversation

netrom: fix copying in user data in nr_setsockopt

PATCH Applied Christoph Hellwig 3 participants 3 messages Jan 4, 2022 – Jan 6, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netrom: fix copying in user data in nr_setsockopt

This code used to copy in an unsigned long worth of data before the sockptr_t conversion, so restore that.

Fixes a7b75c5a8c41 ("net: pass a sockptr_t into ->setsockopt")
---
 net/netrom/af_netrom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netrom/af_netrom.c +1 -1
index 775064cdd0ee4..f1ba7dd3d253d 100644
@@ -306,7 +306,7 @@ static int nr_setsockopt(struct socket *sock, int level, int optname,
 	if (optlen < sizeof(unsigned int))
 		return -EINVAL;
 
-	if (copy_from_sockptr(&opt, optval, sizeof(unsigned int)))
+	if (copy_from_sockptr(&opt, optval, sizeof(unsigned long)))
 		return -EFAULT;
 
 	switch (optname) {
Signature · 1 line
2.30.2
#1 lore raw
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:

Quoted 8 lines · On Tue, 4 Jan 2022 10:21:26 +0100 you wrote:

This code used to copy in an unsigned long worth of data before the sockptr_t conversion, so restore that.

Fixes a7b75c5a8c41 ("net: pass a sockptr_t into ->setsockopt")

[...]

Here is the summary with links:
- netrom: fix copying in user data in nr_setsockopt

    https://git.kernel.org/netdev/net/c/3087a6f36ee0

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
#2 lore raw
In reply to Christoph Hellwig
Quoted 15 lines · Christoph Hellwig

This code used to copy in an unsigned long worth of data before the sockptr_t conversion, so restore that.

Fixes a7b75c5a8c41 ("net: pass a sockptr_t into ->setsockopt")
---
 net/netrom/af_netrom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netrom/af_netrom.c +0 -0
index 775064cdd0ee4..f1ba7dd3d253d 100644

net/netrom/af_netrom.c static int nr_setsockopt(struct socket *sock, int level, int optname, · line 310

Quoted 6 lines
net/netrom/af_netrom.c +1 -1
@@ -306,7 +306,7 @@ static int nr_setsockopt(struct socket *sock, int level, int optname,
 	if (optlen < sizeof(unsigned int))
 		return -EINVAL;
 
-	if (copy_from_sockptr(&opt, optval, sizeof(unsigned int)))
+	if (copy_from_sockptr(&opt, optval, sizeof(unsigned long)))
 		return -EFAULT;

No this isn't right. In the original code, it copied an unsigned int.

if (get_user(opt, (unsigned int __user *)optval))

The fix is to probably to change "opt" to an unsigned int. I wonder if I need to update all the integer overflow checks to from:

- if (opt > ULONG_MAX / HZ)
+ if (opt > UINT_MAX / HZ)

...

Probably no one cares, right? Ralf?

regards,
dan carpenter