From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796418576; b=wDNdnIuTBnwxWIU/PQ4DEnTA4JTNMc4NmseoYemefZFnapxdJmmBqrHSOvsYKOzItICd zKk4KN8PywmhrrPcX4OSd8KM9GrEiFN7I1tk9CLuqD88YwepWofzV3EcSn6btqIEMpKBu yXeEz5JAFZlOQl3KMwngGS5rSaiRSoC6+lyjZVQq4YhgVU8DqD94Wz9SzH7pg9zYFpB1b V8v16R3MjSXrGQbkcDmGDwn9s2kaJ0tL+iUMV/v5G/LBDU7jebM3DMxk6wniG/0MMWris zdOM8PfAXOHpAsofCbmRh9gf5r/jkw7nI3Wj+SwxykRXjpQaBE5TRC0GUq1eKrxob3w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796418576; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=WDDS/GAE5KdEeA47DhVzvxmKNxKO7fZSOt7XLpr1URA=; b=gJyfbn1dUobIYnH3+XwjN2wuFsIfWjRqE1Y6ahtKLh7m/216+q2MqVAtT+Dl71Nsb+Td lsWMqN9iyD1IIAZVOE/Q24CQQPLXh2upcDv45MeAMlE2F2DrzYWc0vxO1hzw7k9sTqMdM cpypvFlKe0YahjOQ9zZ3vP3ej6BGZofd3fgP/N+0fK8XCFXb8j7p8t68SfMCpUVPIHVRK TR2nV8OxMQQdrbRKbQZdq+UN5rRQfzoTqE8CwOcVHt501YfrM6wEyMdVONN6j7hJv4tV1 balDSDzNF++xe2pOGN7ZZfEwggWZ2BHJQOTFIC+SyNbG0JebkEsahx/+zjLixJs+pGg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SHUYEX2Z; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7FFC606A33D for ; Fri, 4 Dec 2026 21:09:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SHUYEX2Z Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6EBBD1F00A06; Fri, 4 Dec 2026 21:09:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796418576; bh=WDDS/GAE5KdEeA47DhVzvxmKNxKO7fZSOt7XLpr1URA=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=SHUYEX2ZUa9rDYxKC12affMyMDjUcmLcIpq/BLhHnyUxLqX8b4ABwX8QpGZffWup2 h/FBca0XDpxlruAMnmkFWyrdat21uP4y04l0JY+KHtXif/ZQBthVVrFe9/1/aG58ey pKDP8SVwjQgAcldHkwSY4w5hjFQ9A0n+yxIVHJ/QfUYlF2erhE4EdRIgdbQhjFAPni EkMNuAwhQBLlpzZK+ft9zj4PypjZp71/CQpzAGa+SiCmigyJ94xKx/Hcrx6YyhVjmx xDFT64sMjlrUm1vL1j39gP2NA7/0EbfJJe0bPT+6c/DRAGWLKaXJkBkVt6OsywYoy1 1ZoxqhOvSQ7eg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net 05/10] tls: reject unreadable skbs in tls_strp Reply-To: sashiko-reviews@lists.linux.dev To: "Octavian Purdila" Cc: bpf@vger.kernel.org In-Reply-To: References: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 21:09:36 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [Medium] tls: tls_strp_check_queue_ok() enters copy mode on unreadable skbs - [Medium] tls: tls_strp_skb_copy() returns NULL on -EFAULT, misreported as -ENOMEM - [Medium] tls: tls_strp_msg_load() skips queue validation on force_refresh - [Medium] tls: tls_strp_copyin_frag() ignores skb_copy_bits() errors on frag_list -- commit 2c01b4221727542d5938c961d8c4dd858cff2e10 Author: Octavian Purdila tls: reject unreadable skbs in tls_strp This commit checks skb_frags_readable() in tls_strp_skb_copy(), tls_strp_copyin(), and tls_strp_check_queue_ok(), and aborts stream parsing with -EFAULT when unreadable fragments or skb_copy_bits() failures are encountered. > diff --git a/net/tls/tls_strp.c b/net/tls/tls_strp.c > index 53d3256d0114a..a9e49384a1692 100644 > --- a/net/tls/tls_strp.c > +++ b/net/tls/tls_strp.c > @@ -45,6 +45,11 @@ tls_strp_skb_copy(struct tls_strparser *strp, struct s= k_buff *in_skb, > struct sk_buff *skb; > int i, err; > =20 > + if (unlikely(!skb_frags_readable(in_skb))) { > + tls_strp_abort_strp(strp, -EFAULT); > + return NULL; > + } > + > skb =3D alloc_skb_with_frags(0, len, TLS_PAGE_ORDER, > &err, strp->sk->sk_allocation); > if (!skb) > @@ -53,9 +58,13 @@ tls_strp_skb_copy(struct tls_strparser *strp, struct s= k_buff *in_skb, > for (i =3D 0; i < skb_shinfo(skb)->nr_frags; i++) { > skb_frag_t *frag =3D &skb_shinfo(skb)->frags[i]; > =20 > - WARN_ON_ONCE(skb_copy_bits(in_skb, offset, > + if (unlikely(skb_copy_bits(in_skb, offset, > skb_frag_address(frag), > - skb_frag_size(frag))); > + skb_frag_size(frag)))) { > + kfree_skb(skb); > + tls_strp_abort_strp(strp, -EFAULT); > + return NULL; > + } > offset +=3D skb_frag_size(frag); > } [Severity: Medium] Does returning NULL after tls_strp_abort_strp() cause callers to misreport -EFAULT as -ENOMEM? All callers of tls_strp_skb_copy() (tls_strp_copyin_skb(), tls_strp_msg_cow(), and tls_decrypt_device() via tls_strp_msg_detach()) treat a NULL return as an allocation failure and return -ENOMEM. On the hardware offload path, tls_rx_one_record() then calls tls_err_abort(sk, -EBADMSG), overwriting the EFAULT just written to sk->sk_err, and returns -ENOMEM to userspace. On the copyin path, tls_strp_check_rcv() sees -ENOMEM and queues strp->work on tls_strp_wq even though strp->stopped is already set. Returning ERR_PTR(-EFAULT) vs ERR_PTR(-ENOMEM) from tls_strp_skb_copy() and tls_strp_msg_make_copy() would preserve -EFAULT and avoid clobbering sk->sk_err or scheduling dead work. > @@ -349,6 +358,12 @@ static int tls_strp_copyin(read_descriptor_t *desc, = struct sk_buff *in_skb, > if (strp->msg_ready) > return 0; > =20 > + if (unlikely(!skb_frags_readable(in_skb))) { > + tls_strp_abort_strp(strp, -EFAULT); > + desc->error =3D -EFAULT; > + return 0; > + } > + > skb =3D strp->anchor; > if (!skb->len) > skb_copy_decrypted(skb, in_skb); [Severity: Medium] Can an skb with a readable head and an unreadable frag_list member still bypass this check and hit unchecked skb_copy_bits() calls in tls_strp_copyin_frag()? skb_gro_receive() checks p->pp_recycle !=3D skb->pp_recycle but not p->unreadable !=3D skb->unreadable, so a readable pp_recycle head skb can chain an unreadable devmem skb onto frag_list (for example via gro_cells_receive() or a driver sharing one NAPI across RX queues). When that happens, tls_strp_copyin() passes the head skb check and enters tls_strp_copyin_frag(), where both WARN_ON_ONCE(skb_copy_bits(...)) calls ignore -EFAULT, trigger a kernel warning, skip tls_strp_abort_strp(), and advance skb->len, skb->data_len, and frag size over uninitialized pages from alloc_page(). Checking the return value of both skb_copy_bits() calls in tls_strp_copyin_frag() and aborting with tls_strp_abort_strp(strp, -EFAULT) would match tls_strp_skb_copy(). > @@ -438,6 +453,8 @@ static bool tls_strp_check_queue_ok(struct tls_strpar= ser *strp, > u32 seq; > =20 > first =3D skb_shinfo(strp->anchor)->frag_list; > + if (unlikely(!skb_frags_readable(first))) > + return false; > skb =3D first; > seq =3D TCP_SKB_CB(first)->seq; > =20 > @@ -449,6 +466,9 @@ static bool tls_strp_check_queue_ok(struct tls_strpar= ser *strp, > remaining -=3D skb->len; > skb =3D skb->next; > =20 > + if (unlikely(!skb_frags_readable(skb))) > + return false; > + > if (TCP_SKB_CB(skb)->seq !=3D seq) > return false; > if (skb_cmp_decrypted(first, skb)) [Severity: Medium] Should tls_strp_check_queue_ok() abort directly on unreadable skbs instead of returning false and entering copy mode? Both callers in tls_strp_read_sock() treat a false return as a recoverable queue anomaly and call tls_strp_read_copy(strp, false). That allocates up to 20 KiB of pages (under GFP_ATOMIC in softirq) and discards the -EFAULT from tls_strp_read_copyin(), leaving those pages pinned on strp->anchor until socket close. It also defers to tls_strp_wq on allocation failure instead of aborting, and consumes and ACKs any preceding readable skbs in the same record before hitting the unreadable skb. Aborting with -EFAULT directly and returning an error status to tls_strp_read_sock() would avoid the copy-mode fallback. [Severity: Medium] What about tls_strp_msg_load() when force_refresh is true? tls_strp_msg_load() is the other caller of tls_strp_load_anchor_with_queue(), and it reloads strp->anchor without calling tls_strp_check_queue_ok(). If a validated readable record is drained from sk_receive_queue (for example via getsockopt(IPPROTO_TCP, TCP_ZEROCOPY_RECEIVE) forwarded by tls_getsockopt()) while an unreadable devmem skb of at least strp->stm.full_len bytes remains queued behind it, tls_strp_msg_load() anchors the unreadable skb and hands it to tls_rx_one_record(). tls_rx_one_record() then allocates decrypt buffers, fails, and calls tls_err_abort(sk, -EBADMSG) without stopping strp or clearing strp->msg_ready, so SO_ERROR reports EBADMSG, tls_sk_poll() keeps reporting EPOLLIN | EPOLLRDNORM, and later reads keep re-anchoring and failing on the same skb. Re-checking tls_strp_check_queue_ok(strp, strp->stm.full_len) in tls_strp_msg_load() and clearing strp->msg_ready on failure would route it back through tls_strp_read_sock() to abort cleanly with -EFAULT. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796329894.gi= t.tavip@google.com?part=3D5