* [PATCH] llc: Return -EINPROGRESS from llc_ui_connect()
@ 2026-04-15 6:34 Ernestas Kulik
2026-04-20 18:41 ` Jakub Kicinski
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Ernestas Kulik @ 2026-04-15 6:34 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel, Ernestas Kulik
Given a zero sk_sndtimeo, llc_ui_connect() skips waiting for state
change and returns 0, confusing userspace applications that will assume
the socket is connected, making e.g. getpeername() calls error out.
Set rc to -EINPROGRESS before considering blocking, akin to AF_INET
sockets.
Signed-off-by: Ernestas Kulik <ernestas.k@iconn-networks.com>
---
net/llc/af_llc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 59d593bb5d18..9317d092ba84 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -515,10 +515,12 @@ static int llc_ui_connect(struct socket *sock, struct sockaddr_unsized *uaddr,
sock->state = SS_UNCONNECTED;
sk->sk_state = TCP_CLOSE;
goto out;
}
+ rc = -EINPROGRESS;
+
if (sk->sk_state == TCP_SYN_SENT) {
const long timeo = sock_sndtimeo(sk, flags & O_NONBLOCK);
if (!timeo || !llc_ui_wait_for_conn(sk, timeo))
goto out;
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] llc: Return -EINPROGRESS from llc_ui_connect()
2026-04-15 6:34 [PATCH] llc: Return -EINPROGRESS from llc_ui_connect() Ernestas Kulik
@ 2026-04-20 18:41 ` Jakub Kicinski
2026-04-21 5:48 ` Ernestas Kulik
2026-04-21 5:54 ` [PATCH v2] " Ernestas Kulik
2026-04-21 6:02 ` [PATCH v3] " Ernestas Kulik
2 siblings, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2026-04-20 18:41 UTC (permalink / raw)
To: Ernestas Kulik; +Cc: netdev, linux-kernel
On Wed, 15 Apr 2026 09:34:57 +0300 Ernestas Kulik wrote:
> Given a zero sk_sndtimeo, llc_ui_connect() skips waiting for state
> change and returns 0, confusing userspace applications that will assume
> the socket is connected, making e.g. getpeername() calls error out.
>
> Set rc to -EINPROGRESS before considering blocking, akin to AF_INET
> sockets.
Please add a note on how you discovered this issue.
Including whether you're actively using this code or just scanning it
for bugs.
> diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
> index 59d593bb5d18..9317d092ba84 100644
> --- a/net/llc/af_llc.c
> +++ b/net/llc/af_llc.c
> @@ -515,10 +515,12 @@ static int llc_ui_connect(struct socket *sock, struct sockaddr_unsized *uaddr,
> sock->state = SS_UNCONNECTED;
> sk->sk_state = TCP_CLOSE;
> goto out;
> }
>
> + rc = -EINPROGRESS;
Isn't this a bit of an odd placement? ..
> if (sk->sk_state == TCP_SYN_SENT) {
> const long timeo = sock_sndtimeo(sk, flags & O_NONBLOCK);
>
> if (!timeo || !llc_ui_wait_for_conn(sk, timeo))
> goto out;
.. I suspect you mean to target this branch, right?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] llc: Return -EINPROGRESS from llc_ui_connect()
2026-04-20 18:41 ` Jakub Kicinski
@ 2026-04-21 5:48 ` Ernestas Kulik
0 siblings, 0 replies; 5+ messages in thread
From: Ernestas Kulik @ 2026-04-21 5:48 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: netdev, linux-kernel
On 2026-04-20 21:41, Jakub Kicinski wrote:
> On Wed, 15 Apr 2026 09:34:57 +0300 Ernestas Kulik wrote:
>> Given a zero sk_sndtimeo, llc_ui_connect() skips waiting for state
>> change and returns 0, confusing userspace applications that will assume
>> the socket is connected, making e.g. getpeername() calls error out.
>>
>> Set rc to -EINPROGRESS before considering blocking, akin to AF_INET
>> sockets.
>
> Please add a note on how you discovered this issue.
> Including whether you're actively using this code or just scanning it
> for bugs.
Will do. It was discovered while adding support for AF_LLC sockets in
libcoap, the usual code path for client connections was failing due to
this specific issue, so I figured the behavior should be analogous to
AF_INET.
>> diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
>> index 59d593bb5d18..9317d092ba84 100644
>> --- a/net/llc/af_llc.c
>> +++ b/net/llc/af_llc.c
>> @@ -515,10 +515,12 @@ static int llc_ui_connect(struct socket *sock, struct sockaddr_unsized *uaddr,
>> sock->state = SS_UNCONNECTED;
>> sk->sk_state = TCP_CLOSE;
>> goto out;
>> }
>>
>> + rc = -EINPROGRESS;
>
> Isn't this a bit of an odd placement? ..
>
>> if (sk->sk_state == TCP_SYN_SENT) {
>> const long timeo = sock_sndtimeo(sk, flags & O_NONBLOCK);
>>
>> if (!timeo || !llc_ui_wait_for_conn(sk, timeo))
>> goto out;
>
> .. I suspect you mean to target this branch, right?
I can’t remember now why I put it there, but you’re right, that would be
the better place.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] llc: Return -EINPROGRESS from llc_ui_connect()
2026-04-15 6:34 [PATCH] llc: Return -EINPROGRESS from llc_ui_connect() Ernestas Kulik
2026-04-20 18:41 ` Jakub Kicinski
@ 2026-04-21 5:54 ` Ernestas Kulik
2026-04-21 6:02 ` [PATCH v3] " Ernestas Kulik
2 siblings, 0 replies; 5+ messages in thread
From: Ernestas Kulik @ 2026-04-21 5:54 UTC (permalink / raw)
To: netdev; +Cc: kuba, linux-kernel, Ernestas Kulik
Given a zero sk_sndtimeo, llc_ui_connect() skips waiting for state
change and returns 0, confusing userspace applications that will assume
the socket is connected, making e.g. getpeername() calls error out.
More specifically, the issue was discovered in libcoap, where
newly-added AF_LLC socket support was behaving differently from AF_INET
connections due to EINPROGRESS handling being skipped.
Set rc to -EINPROGRESS before considering blocking, akin to AF_INET
sockets.
Signed-off-by: Ernestas Kulik <ernestas.k@iconn-networks.com>
---
net/llc/af_llc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 59d593bb5d18..1b210db3119e 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -518,12 +518,14 @@ static int llc_ui_connect(struct socket *sock, struct sockaddr_unsized *uaddr,
}
if (sk->sk_state == TCP_SYN_SENT) {
const long timeo = sock_sndtimeo(sk, flags & O_NONBLOCK);
- if (!timeo || !llc_ui_wait_for_conn(sk, timeo))
+ if (!timeo || !llc_ui_wait_for_conn(sk, timeo)) {
+ rc = -EINPROGRESS;
goto out;
+ }
rc = sock_intr_errno(timeo);
if (signal_pending(current))
goto out;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3] llc: Return -EINPROGRESS from llc_ui_connect()
2026-04-15 6:34 [PATCH] llc: Return -EINPROGRESS from llc_ui_connect() Ernestas Kulik
2026-04-20 18:41 ` Jakub Kicinski
2026-04-21 5:54 ` [PATCH v2] " Ernestas Kulik
@ 2026-04-21 6:02 ` Ernestas Kulik
2 siblings, 0 replies; 5+ messages in thread
From: Ernestas Kulik @ 2026-04-21 6:02 UTC (permalink / raw)
To: netdev; +Cc: kuba, linux-kernel, Ernestas Kulik
Given a zero sk_sndtimeo, llc_ui_connect() skips waiting for state
change and returns 0, confusing userspace applications that will assume
the socket is connected, making e.g. getpeername() calls error out.
More specifically, the issue was discovered in libcoap, where
newly-added AF_LLC socket support was behaving differently from AF_INET
connections due to EINPROGRESS handling being skipped.
Set rc to -EINPROGRESS if connect() would not block, akin to AF_INET
sockets.
Signed-off-by: Ernestas Kulik <ernestas.k@iconn-networks.com>
---
v2:
- Add note about discovering the issue
- Make rc assignment conditional
v3:
- Fix commit message after v2 changes
---
net/llc/af_llc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 59d593bb5d18..1b210db3119e 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -518,12 +518,14 @@ static int llc_ui_connect(struct socket *sock, struct sockaddr_unsized *uaddr,
}
if (sk->sk_state == TCP_SYN_SENT) {
const long timeo = sock_sndtimeo(sk, flags & O_NONBLOCK);
- if (!timeo || !llc_ui_wait_for_conn(sk, timeo))
+ if (!timeo || !llc_ui_wait_for_conn(sk, timeo)) {
+ rc = -EINPROGRESS;
goto out;
+ }
rc = sock_intr_errno(timeo);
if (signal_pending(current))
goto out;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-04-21 6:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-15 6:34 [PATCH] llc: Return -EINPROGRESS from llc_ui_connect() Ernestas Kulik
2026-04-20 18:41 ` Jakub Kicinski
2026-04-21 5:48 ` Ernestas Kulik
2026-04-21 5:54 ` [PATCH v2] " Ernestas Kulik
2026-04-21 6:02 ` [PATCH v3] " Ernestas Kulik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox