From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31153227BA4; Mon, 2 Jun 2025 14:49:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748875793; cv=none; b=CLuo8h21BhSdSv7kHPxF3ej9f9wnPv5526eomDz6ZgGRcKChhECU9+G1LbEYZrEqxNDSeplp7joMTZEBlY6M7b/BLbPxjoGhBYA/TWk+ilLiSghwKw5vrEUiATS64YXzOe+SyCcqnLGWF4dtWR22GHalIvkh90xNapf3dZkrVWA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748875793; c=relaxed/simple; bh=/yJkE7PoAHPSgI9cxxDunh3p3yDVskEOmTvhPgy+8EU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WktQwKNVyHmjR2IZbS5vx8syA9DR5Ty8bTQJiDuIyQrfCvXqv6mGWF/j76f9WtyrQ27dKyMa/6pl2JuSUzymS/Awpvqe8DotFP9w99Oiu2bxOqpi6umgpzBp2je75a2xU/sdv24xkYrMiPq/EdOFNAd66sUhPDfQ85U2654mvqo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=T5asv/R7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="T5asv/R7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE68EC4CEEB; Mon, 2 Jun 2025 14:49:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1748875793; bh=/yJkE7PoAHPSgI9cxxDunh3p3yDVskEOmTvhPgy+8EU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T5asv/R73NRsDAFxmNZmr25xlB80F6SrUqs567BIjqxWIEaZNER3UW2zj65d7Pd+P Uuoy212KT+5qhlnzA8HyfaHnNgXNqhChmCsTsv2r/HOSE4LQgJ8GskRopMexCdlJr0 1MbzfLVeVPpam4S/8HPQ6tAefCP8YEGVACZU6ZwE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ilia Gavrilov , "David S. Miller" Subject: [PATCH 5.10 245/270] llc: fix data loss when reading from a socket in llc_ui_recvmsg() Date: Mon, 2 Jun 2025 15:48:50 +0200 Message-ID: <20250602134317.344947991@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250602134307.195171844@linuxfoundation.org> References: <20250602134307.195171844@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ilia Gavrilov commit 239af1970bcb039a1551d2c438d113df0010c149 upstream. 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 Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/llc/af_llc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/net/llc/af_llc.c +++ b/net/llc/af_llc.c @@ -887,15 +887,15 @@ static int llc_ui_recvmsg(struct socket 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: