Skip to content

Commit fc9306d

Browse files
pvts-matPlaidCat
authored andcommitted
net/ulp: use consistent error code when blocking ULP
jira VULN-3655 cve-bf CVE-2023-0461 commit-author Paolo Abeni <[email protected]> commit 8ccc993 upstream-diff This commit is the closure of 68e4adc, solving two issues: 1. The backported mainline fix 2c02d41 had a follow-up in 8ccc993, which was missing from `ciqlts8_6'. (The original intent of the cherry-picked commit) 2. The way changes to `inet_csk_listen_start' were applied from upstream left a potential branching path which would result in the returned `err' different than before the change, for the exact same inputs. While effectively ignoring the initialization of `err' to `-EADDRINUSE' was justified in upstream because of the inevitable assignment at line 1237, the same cannot be done in the versions prior to 9.2 as the initial `-EADDRINUSE' can survive in `err' up to its returning from function. (The piggy-backed correction included here for the lack of better place) The referenced commit changed the error code returned by the kernel when preventing a non-established socket from attaching the ktls ULP. Before to such a commit, the user-space got ENOTCONN instead of EINVAL. The existing self-tests depend on such error code, and the change caused a failure: RUN global.non_established ... tls.c:1673:non_established:Expected errno (22) == ENOTCONN (107) non_established: Test failed at step #3 FAIL global.non_established In the unlikely event existing applications do the same, address the issue by restoring the prior error code in the above scenario. Note that the only other ULP performing similar checks at init time - smc_ulp_ops - also fails with ENOTCONN when trying to attach the ULP to a non-established socket. Reported-by: Sabrina Dubroca <[email protected]> Fixes: 2c02d41 ("net/ulp: prevent ULP without clone op from entering the LISTEN status") Signed-off-by: Paolo Abeni <[email protected]> Reviewed-by: Sabrina Dubroca <[email protected]> Link: https://lore.kernel.org/r/7bb199e7a93317fb6f8bf8b9b2dc71c18f337cde.1674042685.git.pabeni@redhat.com Signed-off-by: Jakub Kicinski <[email protected]> (cherry picked from commit 8ccc993) Signed-off-by: Marcin Wcisło <[email protected]>
1 parent 8e48e58 commit fc9306d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

net/ipv4/inet_connection_sock.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,7 @@ int inet_csk_listen_start(struct sock *sk, int backlog)
920920
if (unlikely(err))
921921
return err;
922922

923+
err = -EADDRINUSE;
923924
reqsk_queue_alloc(&icsk->icsk_accept_queue);
924925

925926
sk->sk_ack_backlog = 0;

net/ipv4/tcp_ulp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static int __tcp_set_ulp(struct sock *sk, const struct tcp_ulp_ops *ulp_ops)
131131
if (icsk->icsk_ulp_ops)
132132
goto out_err;
133133

134-
err = -EINVAL;
134+
err = -ENOTCONN;
135135
if (!ulp_ops->clone && sk->sk_state == TCP_LISTEN)
136136
goto out_err;
137137

0 commit comments

Comments
 (0)