diff mbox series

[net-next] ipmr: Copy option to correct variable

Message ID 20200727071834.1651232-1-idosch@mellanox.com
State Accepted
Delegated to: David Miller
Headers show
Series [net-next] ipmr: Copy option to correct variable | expand

Commit Message

Ido Schimmel July 27, 2020, 7:18 a.m. UTC
Cited commit mistakenly copied provided option to 'val' instead of to
'mfc':

```
-               if (copy_from_user(&mfc, optval, sizeof(mfc))) {
+               if (copy_from_sockptr(&val, optval, sizeof(val))) {
```

Fix this by copying the option to 'mfc'.

selftest router_multicast.sh before:

$ ./router_multicast.sh
smcroutectl: Unknown or malformed IPC message 'a' from client.
smcroutectl: failed removing multicast route, does not exist.
TEST: mcast IPv4                                                    [FAIL]
        Multicast not received on first host
TEST: mcast IPv6                                                    [ OK ]
smcroutectl: Unknown or malformed IPC message 'a' from client.
smcroutectl: failed removing multicast route, does not exist.
TEST: RPF IPv4                                                      [FAIL]
        Multicast not received on first host
TEST: RPF IPv6                                                      [ OK ]

selftest router_multicast.sh after:

$ ./router_multicast.sh
TEST: mcast IPv4                                                    [ OK ]
TEST: mcast IPv6                                                    [ OK ]
TEST: RPF IPv4                                                      [ OK ]
TEST: RPF IPv6                                                      [ OK ]

Fixes: 01ccb5b48f08 ("net/ipv4: switch ip_mroute_setsockopt to sockptr_t")
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 net/ipv4/ipmr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christoph Hellwig July 27, 2020, 7:34 a.m. UTC | #1
Looks good, thanks for catching it.

Reviewed-by: Christoph Hellwig <hch@lst.de>
David Miller July 27, 2020, 6:40 p.m. UTC | #2
From: Ido Schimmel <idosch@mellanox.com>
Date: Mon, 27 Jul 2020 10:18:34 +0300

> Cited commit mistakenly copied provided option to 'val' instead of to
> 'mfc':
> 
> ```
> -               if (copy_from_user(&mfc, optval, sizeof(mfc))) {
> +               if (copy_from_sockptr(&val, optval, sizeof(val))) {
> ```
> 
> Fix this by copying the option to 'mfc'.
> 
> selftest router_multicast.sh before:
 ...
> selftest router_multicast.sh after:
 ...
> Fixes: 01ccb5b48f08 ("net/ipv4: switch ip_mroute_setsockopt to sockptr_t")
> Signed-off-by: Ido Schimmel <idosch@mellanox.com>

Applied, thank you.
diff mbox series

Patch

diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index cdf3a40f9ff5..876fd6ff1ff9 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1441,7 +1441,7 @@  int ip_mroute_setsockopt(struct sock *sk, int optname, sockptr_t optval,
 			ret = -EINVAL;
 			break;
 		}
-		if (copy_from_sockptr(&val, optval, sizeof(val))) {
+		if (copy_from_sockptr(&mfc, optval, sizeof(mfc))) {
 			ret = -EFAULT;
 			break;
 		}