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=1796422075; b=jP1y4SSozJKhpF+25zMdB3eooOFARINCfssp1QqtcRGyuu6zVpxlXf66wdBb+H0DGFcL NXPFaVLbeM1/PJPuFESoj6J0a0V+qAmpxe6q/4IoE2IPLivn80HnkvlaqVs+Oogq9GhX+ AaBwjjPMknNgvZYhN9uHe5Wx0NhgQ6mfgQcL4p5rl22t62WK8MAiVebW/yc5ZmxH7DUq3 swnKz5v5ELV8cG2BJg2um6tcGROZFGdH7sq4pZAjIx6rR3pBBgZ1259pQhnGMUJRr3BuW 9zcWKOj6XKiauTfPj/cRUuYsJtSprqCrNa+t4nKvq99RLLdswcYxpNH+aRKfppTLA8Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796422075; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=yLfuRrZbpLA9mg/NT/CGUV6g0q7+MYZINIUbcGfSVDU=; b=Q2ar9cQ/BKl3IRFMdwAW7vmwl9Y25j5h5aIxJN5R6PAjWTbaz1vtosSEXzBGLD/o970z KpOXC1CoF5cDb9oGnlMfBlaC+Pa2oUg5gmntW3ClrCAT33wBzd0nfZ6tFlUDjJuymDFzu ObM7sVUmdpffgpIvOScD6LYjiXuygyXY81Nd/rifRWt78XUGa49Bd8zKKjLa7r5tESFqK Oj2ssrTsQKdfEaRehhRoyfYZBjgvoDp8oNvgoxGAEF/Rf5rx41ka+4xtGbsYxoqOn/Jwd dbrg5yiDMYS5jchl5R/Kz7cMgiH5dKF5eEeT/4hcyF3pYx/Q3mcL2p3ImbmvBNhy6QQ== 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=E62ZoV8O; 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 65523606A339; Fri, 4 Dec 2026 22:07:55 +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=E62ZoV8O Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8A771F0093B; Fri, 4 Dec 2026 22:07:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796422075; bh=yLfuRrZbpLA9mg/NT/CGUV6g0q7+MYZINIUbcGfSVDU=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=E62ZoV8OaZRC4yoznKlPrzfW26LKynZuFtsiOqUHyyNIXhFjR4S0NJHVWx8IyZ8OE vVnJEmQ740I8pXW/x5IzLavUTVKmm3kUMh5tfStFpKLUKdm0NaEWvC71+/Gn0eN/tr NzkuGO26PvigejgQl++avtZYLotXAmwq+T+KCovNpF8a7KR/GHSVjSsb2Wgi5oDKYe lxZIbX64RZJXxEhaPi6jzwF8VAH1zaZYoSWte0PgdDbGlcEufpVQWyDFyNDscNppJ6 Xbycal3b8VvT4usVRQ682x7qvDft4UwE1ee28HuCkmE5/8N8bOgPTeGadhkE43ivLl B0ACJYiL68GWQ== Subject: Re: [PATCH net 05/10] tls: reject unreadable skbs in tls_strp From: netdev-bot+sashiko@kernel.org To: tavip@google.com Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org, andrew+netdev@lunn.ch, ncardwell@google.com, kuniyu@google.com, dsahern@kernel.org, idosch@nvidia.com, john.fastabend@gmail.com, jakub@cloudflare.com, jiayuan.chen@linux.dev, sd@queasysnail.net, shuah@kernel.org, almasrymina@google.com, sdf@fomichev.me, kaiyuanz@google.com, ilias.apalodimas@linaro.org, hawk@kernel.org, mcroce@microsoft.com, herbert@gondor.apana.org.au, ecree.xilinx@gmail.com, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org Date: Fri, 04 Dec 2026 22:07:53 +0000 Message-ID: <179642207345.3146.9826928279954710925@kernel.org> In-Reply-To: References: X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 2 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] The patch only closes part of the bug class it describes. - [Low] After this patch, a NULL return from tls_strp_skb_copy() can mean two things. - [Low] tls_strp_check_queue_ok() now also rejects unreadable skbs, but its comment still says only "Make sure there's no duplicate data in… -- tls: reject unreadable skbs in tls_strp This patch makes tls_strp reject skbs with unreadable (net_iov) frags. It adds readability checks to tls_strp_check_queue_ok(), tls_strp_copyin() and tls_strp_skb_copy(), and aborts the parser with -EFAULT when it finds unreadable data. It also changes the WARN_ON_ONCE() around skb_copy_bits() in tls_strp_skb_copy() into a checked failure path. > 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 sk_buff *in_skb, > struct sk_buff *skb; > int i, err; > > + if (unlikely(!skb_frags_readable(in_skb))) { > + tls_strp_abort_strp(strp, -EFAULT); > + return NULL; > + } > + > skb = 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 sk_buff *in_skb, > for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { > skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; > > - 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; > + } [Severity: Low] With this change, a NULL return from tls_strp_skb_copy() can mean either of two things. It can be a transient alloc_skb_with_frags() failure. It can also be a permanent fault, where tls_strp_abort_strp(strp, -EFAULT) has already set strp->stopped and sk_err. The callers still turn every NULL into -ENOMEM: tls_strp_copyin_skb(): nskb = tls_strp_skb_copy(strp, in_skb, offset, chunk); if (!nskb) return -ENOMEM; tls_strp_msg_cow(): skb = tls_strp_msg_make_copy(strp); if (!skb) return -ENOMEM; tls_device_reencrypt() passes the tls_strp_msg_cow() error up. Also, tls_rx_one_record() in tls_sw.c returns -ENOMEM when tls_strp_msg_detach() returns NULL. Could recvmsg then report ENOMEM while sk_err on the lower socket holds EFAULT? In copy mode, tls_strp_check_rcv() also treats this as memory pressure: if (tls_strp_read_sock(strp) == -ENOMEM) queue_work(tls_strp_wq, &strp->work); The queued work only exits because strp->stopped happens to be set. In practice, the new !skb_frags_readable(in_skb) check here doesn't seem reachable: - From tls_strp_copyin_skb(), tls_strp_copyin() checks first. - From tls_strp_msg_make_copy(), the anchor's unreadable bit is copied from first, which tls_strp_check_queue_ok() has already validated. That leaves only the skb_copy_bits() failure branch, i.e. the nested frag_list case described below. Would returning ERR_PTR(-EFAULT), or passing the error back through an int pointer, better match the commit message's "abort stream parsing cleanly with -EFAULT"? > offset += skb_frag_size(frag); > } > [ ... ] > @@ -349,6 +358,12 @@ static int tls_strp_copyin(read_descriptor_t *desc, struct sk_buff *in_skb, > if (strp->msg_ready) > return 0; > > + if (unlikely(!skb_frags_readable(in_skb))) { > + tls_strp_abort_strp(strp, -EFAULT); > + desc->error = -EFAULT; > + return 0; > + } > + [Severity: Medium] This only checks the unreadable bit on the head in_skb. Can a readable head skb still carry unreadable skbs on its own frag_list? skb_copy_bits() recurses into frag_list members and returns -EFAULT for any member where !skb_frags_readable() is true. tls_strp_copyin_frag() still ignores that return value, both in the header copy and in the "Load up more data" loop: tls_strp_copyin_frag() { ... WARN_ON_ONCE(skb_copy_bits(in_skb, offset, skb_frag_address(frag) + skb_frag_size(frag), chunk)); skb->len += chunk; skb->data_len += chunk; skb_frag_size_add(frag, chunk); ... } If that happens, isn't this still the case the commit message describes: "triggers warnings and advances skb lengths over uninitialized memory when skb_copy_bits() fails"? The pages come from alloc_page() in tls_strp_read_copy() and are not zeroed. tls_rx_msg_size() would parse those bytes, and they would then be passed to decryption. For a record with decrypted set and mixed_decrypted == 0, which goes through tls_strp_copyin_frag(), the bytes would be treated as plaintext. The path would be: tls_strp_read_copy() tls_strp_read_copyin() tcp_read_sock() tls_strp_copyin() <- head check passes tls_strp_copyin_frag() skb_copy_bits() <- -EFAULT on a frag_list child, ignored tls_strp_check_queue_ok() has the same gap. It checks each top-level queue skb, but not the skbs on their frag_list. As far as I can tell, the merge path in skb_gro_receive() and tcp_gro_receive() doesn't compare unreadable between p and skb before chaining onto frag_list. It checks pp_recycle, zcopy and decrypted, but not readability. The series adds a mixed-readability rejection for IP defrag, but I couldn't find an equivalent for GRO. I also couldn't find a concrete in-tree producer of a readable head with an unreadable child, since devmem RX needs tcp-data-split with hds-thresh=0. So this may be theoretical. This patch already converts the same pattern in tls_strp_skb_copy(). Should the two skb_copy_bits() calls in tls_strp_copyin_frag() also abort with -EFAULT and return an error, without advancing skb->len, skb->data_len and the frag size? [ ... ] > @@ -438,6 +453,8 @@ static bool tls_strp_check_queue_ok(struct tls_strparser *strp, > u32 seq; > > first = skb_shinfo(strp->anchor)->frag_list; > + if (unlikely(!skb_frags_readable(first))) > + return false; > skb = first; > seq = TCP_SKB_CB(first)->seq; > > @@ -449,6 +466,9 @@ static bool tls_strp_check_queue_ok(struct tls_strparser *strp, > remaining -= skb->len; > skb = skb->next; > > + if (unlikely(!skb_frags_readable(skb))) > + return false; > + [Severity: Low] This isn't a bug, but the comment in tls_strp_check_queue_ok() still only mentions the old checks: /* Make sure there's no duplicate data in the queue, * and the decrypted status matches. */ Should it also mention the readability check? A false return now has two meanings. It can mean the zero-copy anchor isn't usable but copy mode will work, as before. It can also mean the data is unreadable and copy mode can't help. Both callers in tls_strp_read_sock() still handle it the same way: if (!tls_strp_check_queue_ok(strp, strp->stm.full_len)) return tls_strp_read_copy(strp, false); With qshort == false, tls_strp_read_copy() allocates up to TLS_MAX_PAYLOAD_SIZE + PAGE_SIZE worth of pages and switches to copy mode. It then calls tls_strp_read_copyin() and ignores the return value. Only after that does tls_strp_copyin() abort on the unreadable skb, and the -EFAULT is only visible through strp->stopped and sk_err. The pages are freed later on tls_strp_done(), so nothing leaks. Would it be cleaner to abort directly from tls_strp_read_sock() in the unreadable case, rather than setting up copy mode first? > if (TCP_SKB_CB(skb)->seq != seq) > return false; > if (skb_cmp_decrypted(first, skb)) -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1796329894.git.tavip%40google.com