Message ID | 20230921234642.1111903-1-jrife@google.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 26297b4ce1ce4ea40bc9a48ec99f45da3f64d2e2 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net,v5,1/3] net: replace calls to sock->ops->connect() with kernel_connect() | expand |
On Thu, Sep 21, 2023 at 06:46:40PM -0500, Jordan Rife wrote: > commit 0bdf399342c5 ("net: Avoid address overwrite in kernel_connect") > ensured that kernel_connect() will not overwrite the address parameter > in cases where BPF connect hooks perform an address rewrite. This change > replaces direct calls to sock->ops->connect() in net with kernel_connect() > to make these call safe. > > Link: https://lore.kernel.org/netdev/20230912013332.2048422-1-jrife@google.com/ > Fixes: d74bad4e74ee ("bpf: Hooks for sys_connect") > Cc: stable@vger.kernel.org > Reviewed-by: Willem de Bruijn <willemb@google.com> > Signed-off-by: Jordan Rife <jrife@google.com> Reviewed-by: Simon Horman <horms@kernel.org>
Hello: This series was applied to netdev/net.git (main) by David S. Miller <davem@davemloft.net>: On Thu, 21 Sep 2023 18:46:40 -0500 you wrote: > commit 0bdf399342c5 ("net: Avoid address overwrite in kernel_connect") > ensured that kernel_connect() will not overwrite the address parameter > in cases where BPF connect hooks perform an address rewrite. This change > replaces direct calls to sock->ops->connect() in net with kernel_connect() > to make these call safe. > > Link: https://lore.kernel.org/netdev/20230912013332.2048422-1-jrife@google.com/ > Fixes: d74bad4e74ee ("bpf: Hooks for sys_connect") > Cc: stable@vger.kernel.org > Reviewed-by: Willem de Bruijn <willemb@google.com> > Signed-off-by: Jordan Rife <jrife@google.com> > > [...] Here is the summary with links: - [net,v5,1/3] net: replace calls to sock->ops->connect() with kernel_connect() https://git.kernel.org/netdev/net/c/26297b4ce1ce - [net,v5,2/3] net: prevent rewrite of msg_name in sock_sendmsg() https://git.kernel.org/netdev/net/c/86a7e0b69bd5 - [net,v5,3/3] net: prevent address rewrite in kernel_bind() https://git.kernel.org/netdev/net/c/c889a99a21bf You are awesome, thank you!
diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c index da5af28ff57b5..6e4ed1e11a3b7 100644 --- a/net/netfilter/ipvs/ip_vs_sync.c +++ b/net/netfilter/ipvs/ip_vs_sync.c @@ -1505,8 +1505,8 @@ static int make_send_sock(struct netns_ipvs *ipvs, int id, } get_mcast_sockaddr(&mcast_addr, &salen, &ipvs->mcfg, id); - result = sock->ops->connect(sock, (struct sockaddr *) &mcast_addr, - salen, 0); + result = kernel_connect(sock, (struct sockaddr *)&mcast_addr, + salen, 0); if (result < 0) { pr_err("Error connecting to the multicast addr\n"); goto error; diff --git a/net/rds/tcp_connect.c b/net/rds/tcp_connect.c index f0c477c5d1db4..d788c6d28986f 100644 --- a/net/rds/tcp_connect.c +++ b/net/rds/tcp_connect.c @@ -173,7 +173,7 @@ int rds_tcp_conn_path_connect(struct rds_conn_path *cp) * own the socket */ rds_tcp_set_callbacks(sock, cp); - ret = sock->ops->connect(sock, addr, addrlen, O_NONBLOCK); + ret = kernel_connect(sock, addr, addrlen, O_NONBLOCK); rdsdebug("connect to address %pI6c returned %d\n", &conn->c_faddr, ret); if (ret == -EINPROGRESS)