ceph: use kernel_connect()
Subsystems (2)
PATCH 1/1 ceph: use kernel_connect()
Direct calls to ops->connect() can overwrite the address parameter when used in conjunction with BPF SOCK_ADDR hooks. Recent changes to kernel_connect() ensure that callers are insulated from such side effects. This patch wraps the direct call to ops->connect() with kernel_connect() to prevent unexpected changes to the address passed to ceph_tcp_connect().
This change was originally part of a larger patch targeting the net tree addressing all instances of unprotected calls to ops->connect() throughout the kernel, but this change was split up into several patches targeting various trees.
--- net/ceph/messenger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/ceph/messenger.c +2 -2
@@ -459,8 +459,8 @@ int ceph_tcp_connect(struct ceph_connection *con)set_sock_callbacks (sock, con);con_sock_state_connecting (con); - ret = sock->ops->connect (sock, (struct sockaddr *)&ss,sizeof (ss), -O_NONBLOCK ); + ret =kernel_connect (sock, (struct sockaddr *)&ss,sizeof (ss), +O_NONBLOCK );if (ret == -EINPROGRESS ) { dout("connect %s EINPROGRESS sk_state = %u\n", ceph_pr_addr(&con->peer_addr),
Signature · 1 line
2.42.0.582.g8ccd20d70d-goog
Ilya Dryomov
maintainerQuoted 38 lines · Jordan Rife
Direct calls to
ops->connect()can overwrite the address parameter when used in conjunction with BPFSOCK_ADDRhooks. Recent changes tokernel_connect()ensure that callers are insulated from such side effects. This patch wraps the direct call toops->connect()withkernel_connect()to prevent unexpected changes to the address passed toceph_tcp_connect().This change was originally part of a larger patch targeting the net tree addressing all instances of unprotected calls to
ops->connect()throughout the kernel, but this change was split up into several patches targeting various trees.Fixes d74bad4e74ee ("bpf: Hooks for sys_connect")Signed-off-by Jordan Rife <[email protected]>--- net/ceph/messenger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)net/ceph/messenger.c +2
-3@@ -459,8 +459,8 @@ int ceph_tcp_connect(struct ceph_connection *con)set_sock_callbacks (sock, con);con_sock_state_connecting (con); - ret = sock->ops->connect (sock, (struct sockaddr *)&ss,sizeof (ss), -O_NONBLOCK ); + ret =kernel_connect (sock, (struct sockaddr *)&ss,sizeof (ss), +O_NONBLOCK );if (ret == -EINPROGRESS ) { dout("connect %s EINPROGRESS sk_state = %u\n", ceph_pr_addr(&con->peer_addr), --
Quoted 2 lines
2.42.0.582.g8ccd20d70d-goog
Hi Jordan,
I'm a bit confused. This is marked as fixing commit d74bad4e74ee ("bpf: Hooks for sys_connect") and also for stable, but doesn't (explicitly, at least) mention the prerequisite commit 0bdf399342c5 ("net: Avoid address overwrite in kernel_connect") which isn't marked for stable. Was it forwarded to the stable team separately?
Thanks,
Ilya
Ilya,
Sorry for the confusion. I forgot to mark 0bdf399342c5 ("net: Avoid address overwrite in kernel_connect") for stable initially, so I forwarded it separately to the stable team a while back. It has since been backported to all stable branches 4.19+.
-Jordan
Quoted 54 lines · Ilya Dryomov
Quoted 38 lines · Jordan Rife
Direct calls to
ops->connect()can overwrite the address parameter when used in conjunction with BPFSOCK_ADDRhooks. Recent changes tokernel_connect()ensure that callers are insulated from such side effects. This patch wraps the direct call toops->connect()withkernel_connect()to prevent unexpected changes to the address passed toceph_tcp_connect().This change was originally part of a larger patch targeting the net tree addressing all instances of unprotected calls to
ops->connect()throughout the kernel, but this change was split up into several patches targeting various trees.Fixes d74bad4e74ee ("bpf: Hooks for sys_connect")Signed-off-by Jordan Rife <[email protected]>--- net/ceph/messenger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)net/ceph/messenger.c +2
-3@@ -459,8 +459,8 @@ int ceph_tcp_connect(struct ceph_connection *con)set_sock_callbacks (sock, con);con_sock_state_connecting (con); - ret = sock->ops->connect (sock, (struct sockaddr *)&ss,sizeof (ss), -O_NONBLOCK ); + ret =kernel_connect (sock, (struct sockaddr *)&ss,sizeof (ss), +O_NONBLOCK );if (ret == -EINPROGRESS ) { dout("connect %s EINPROGRESS sk_state = %u\n", ceph_pr_addr(&con->peer_addr), --Quoted 2 lines
2.42.0.582.g8ccd20d70d-goog
Hi Jordan,
I'm a bit confused. This is marked as fixing commit
d74bad4e74ee("bpf: Hooks forsys_connect") and also for stable, but doesn't (explicitly, at least) mention the prerequisite commit0bdf399342c5("net: Avoid address overwrite inkernel_connect") which isn't marked for stable. Was it forwarded to the stable team separately?Thanks,
Ilya
Ilya Dryomov
maintainerQuoted 7 lines · Jordan Rife
Ilya,
Sorry for the confusion. I forgot to mark
0bdf399342c5("net: Avoid address overwrite inkernel_connect") for stable initially, so I forwarded it separately to the stable team a while back. It has since been backported to all stable branches 4.19+.
Thanks for the clarification, now applied.
Ilya