diff mbox series

[net] net/ulp: use consistent error code when blocking ULP

Message ID 7bb199e7a93317fb6f8bf8b9b2dc71c18f337cde.1674042685.git.pabeni@redhat.com (mailing list archive)
State Accepted
Commit 8ccc99362b60c6f27bb46f36fdaaccf4ef0303de
Delegated to: Netdev Maintainers
Headers show
Series [net] net/ulp: use consistent error code when blocking ULP | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2 this patch: 2
netdev/cc_maintainers warning 2 maintainers not CCed: yoshfuji@linux-ipv6.org dsahern@kernel.org
netdev/build_clang success Errors and warnings before: 1 this patch: 1
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 2 this patch: 2
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Paolo Abeni Jan. 18, 2023, 12:24 p.m. UTC
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 <sd@queasysnail.net>
Fixes: 2c02d41d71f9 ("net/ulp: prevent ULP without clone op from entering the LISTEN status")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/ipv4/tcp_ulp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sabrina Dubroca Jan. 19, 2023, 9:58 a.m. UTC | #1
2023-01-18, 13:24:12 +0100, Paolo Abeni wrote:
> 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 <sd@queasysnail.net>
> Fixes: 2c02d41d71f9 ("net/ulp: prevent ULP without clone op from entering the LISTEN status")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>

Thanks Paolo.
patchwork-bot+netdevbpf@kernel.org Jan. 19, 2023, 5:30 p.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 18 Jan 2023 13:24:12 +0100 you wrote:
> 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:
> 
> [...]

Here is the summary with links:
  - [net] net/ulp: use consistent error code when blocking ULP
    https://git.kernel.org/netdev/net/c/8ccc99362b60

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/ipv4/tcp_ulp.c b/net/ipv4/tcp_ulp.c
index 05b6077b9f2c..2aa442128630 100644
--- a/net/ipv4/tcp_ulp.c
+++ b/net/ipv4/tcp_ulp.c
@@ -139,7 +139,7 @@  static int __tcp_set_ulp(struct sock *sk, const struct tcp_ulp_ops *ulp_ops)
 	if (sk->sk_socket)
 		clear_bit(SOCK_SUPPORT_ZC, &sk->sk_socket->flags);
 
-	err = -EINVAL;
+	err = -ENOTCONN;
 	if (!ulp_ops->clone && sk->sk_state == TCP_LISTEN)
 		goto out_err;