public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] llc: fix data loss when reading from a socket in llc_ui_recvmsg()
@ 2025-05-15 12:20 Ilia Gavrilov
  2025-05-19 11:20 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Ilia Gavrilov @ 2025-05-15 12:20 UTC (permalink / raw)
  To: David S. Miller
  Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Michal Luczaj, Arnaldo Carvalho de Melo, Stephen Hemminger,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	lvc-project@linuxtesting.org, stable@vger.kernel.org

For SOCK_STREAM sockets, if user buffer size (len) is less
than skb size (skb->len), the remaining data from skb
will be lost after calling kfree_skb().

To fix this, move the statement for partial reading
above skb deletion.

Found by InfoTeCS on behalf of Linux Verification Center (linuxtesting.org)

Fixes: 30a584d944fb ("[LLX]: SOCK_DGRAM interface fixes")
Cc: stable@vger.kernel.org
Signed-off-by: Ilia Gavrilov <Ilia.Gavrilov@infotecs.ru>
---
 net/llc/af_llc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 0259cde394ba..cc77ec5769d8 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -887,15 +887,15 @@ static int llc_ui_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
 		if (sk->sk_type != SOCK_STREAM)
 			goto copy_uaddr;
 
+		/* Partial read */
+		if (used + offset < skb_len)
+			continue;
+
 		if (!(flags & MSG_PEEK)) {
 			skb_unlink(skb, &sk->sk_receive_queue);
 			kfree_skb(skb);
 			*seq = 0;
 		}
-
-		/* Partial read */
-		if (used + offset < skb_len)
-			continue;
 	} while (len > 0);
 
 out:
-- 
2.39.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] llc: fix data loss when reading from a socket in llc_ui_recvmsg()
  2025-05-15 12:20 [PATCH net] llc: fix data loss when reading from a socket in llc_ui_recvmsg() Ilia Gavrilov
@ 2025-05-19 11:20 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-05-19 11:20 UTC (permalink / raw)
  To: Ilia Gavrilov
  Cc: davem, edumazet, kuba, pabeni, horms, mhal, acme, stephen, netdev,
	linux-kernel, lvc-project, stable

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Thu, 15 May 2025 12:20:15 +0000 you wrote:
> For SOCK_STREAM sockets, if user buffer size (len) is less
> than skb size (skb->len), the remaining data from skb
> will be lost after calling kfree_skb().
> 
> To fix this, move the statement for partial reading
> above skb deletion.
> 
> [...]

Here is the summary with links:
  - [net] llc: fix data loss when reading from a socket in llc_ui_recvmsg()
    https://git.kernel.org/netdev/net/c/239af1970bcb

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-05-19 11:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-15 12:20 [PATCH net] llc: fix data loss when reading from a socket in llc_ui_recvmsg() Ilia Gavrilov
2025-05-19 11:20 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox