From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91CFA2E22B5 for ; Sun, 26 Jul 2026 10:56:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785063401; cv=none; b=OuP2HNblIA48NIoLAQb/y18LV7+0sz0JUcelUDDsjqmiC5/eO868wk9foVMswjQkhFQ3TluOsJQMNbNTaJ7gjDjmOho5lBzBrDNLlvWSsSCUFutFrh5BlN7+Ke9xdmXAB1EgwpDPOARimxeqq4As84FkofIaP/BxDqM6kza1o+w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785063401; c=relaxed/simple; bh=FegCKW9FMF1/MnKnXvt8KmJF/dfU+PKJUGTgC6peWLk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=sQbsRrfBhRHMpsedazAGWYIk9WlHkqyxiq9V6zKCS9Rdj+9hdHKSnbAh4Slq5sp42qUZdMfSj70POpPB5rJ+EtnCwEsIyJ2C2ylSuKZD+QvG7fY9XSm3JRQbbwb0sJc90GFA2jMd1i8qCdPWT4NxwGQ6wmGVz1aSWG/miaWtN4o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TPwoYxKL; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TPwoYxKL" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2cc97653887so20999685ad.1 for ; Sun, 26 Jul 2026 03:56:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785063400; x=1785668200; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=6SnhdOfwsu7KEbWY+O+8re8x+bMH7YPIZLb0qYgvEHU=; b=TPwoYxKLSUiDbtlIPk66be8MBSy3nzhJ4Y66lLDzJD9utaiVPoGzoiCBVgn9yIBmDp vfBtgM5VyJutQvEpGWECSw7juWMZPNQ3AOXRkU0tGEA5ejfERIFDedjNJg43HrXkjIqD KQaZ3O9MyCzqe3+iQmktkazKZeULT2r2RlG+dtmh41EEImcBiXZQky0hoKsYwf18pogC kk61onX8jBrQvJH/ASdjXVnUuwGUXlVKvltcr46x2+OxVGb0kgSmEdEnMUuekIe3yvGd IE14acCWxWeZM57nXPF15/jSrx6JufDtqMAf98TL9KHW39lnwncaNZS6EROylF9C/4mO 7veg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785063400; x=1785668200; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=6SnhdOfwsu7KEbWY+O+8re8x+bMH7YPIZLb0qYgvEHU=; b=BckCMG9KSxl/e/IaMDSMCiIrMIl2jlLlmqcBJVF67baNr9x9HMB5X/VH+ChO42HGUn 3Q+o6S2CwkzJzv9I0SbHnN55fx8N0K/9el3h6VL2zKRDBSCCHgRvPNSUQeJC9vmITTd+ TGsRX0EpXBUc/CMT9/M1zgGhfEwZCwDvx4dXCkUKe5FjkBXCKuQ6ph4WWSBwsSHtMzee ahbgEBm+7FJzJWdbAmJ3tju34hA6UFgyIo6UTIEINve1Uli06JqcnKnFvVmuSp0U2V4x YCbShJ+4XCxy8eqjGCL+XFa9q6LXr04gObIJIqSLxQiC3xnEhuYLoPKMT2w0Qch24i7M MDOg== X-Gm-Message-State: AOJu0Yx6TJAOUkigFB4zt42HidZb8JEajRFfabGMbBK3le76jX1IXRc5 sd4VNj59vnrYySdxSRkRo7vpb95dJdDBziqVIpPzSf+aKdB+i38omN2ArZxZqZgv X-Gm-Gg: AR+sD12c7ACwKZ1eknf3ljdH68tJ6Lz5gbyadqz4KInds2S+yA+J55JhembBKspzPE3 M7F+PDgOGHI3vSWF0p5Ie4eoAYYYgUhRt1ddd5+Va8hcYU9puim313STL6wFBTSXg3M+Qed1XCM XKEWRrU8CazLLVJ2wzihrkkQnrtE6feAb24qkraHZ0DzieCymXZbLPzGyz2MegMi6zY2K3KIOuL G2G94cu/opsJKs5yG58pxUZ1Opk7flFIvs0YmwbzUD6E76Eu+Li9jiWvA8n+DYW2NBYYs3BHxpK c/rOZG/O8s4kUqa/PTARDa10uynsI9QLKKDgZkRh0RrWgdqMwPwEWuqVBiXHgCf+hKh0lCDvr2f Glxzci38qC/X0PCanO6iUv0HdaoTgLOXmyqINb7OMzvcBNSjxHVyZ1+qlr5h1K1GQmwM8e/f2vR JAvBY2xJaRIeSM7T7wKB9DWRRwXs0TqrPYsLXRNKET8fffkdk= X-Received: by 2002:a17:90b:1e47:b0:38e:b3fd:d582 with SMTP id 98e67ed59e1d1-38f29885079mr4486728a91.39.1785063399873; Sun, 26 Jul 2026 03:56:39 -0700 (PDT) Received: from anna.. ([114.70.9.168]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38f04175c1asm3645559a91.12.2026.07.26.03.56.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jul 2026 03:56:37 -0700 (PDT) From: chanyoung To: netdev@vger.kernel.org Cc: John Fastabend , Jakub Kicinski , Sabrina Dubroca , David Howells , Shuah Khan , linux-kselftest@vger.kernel.org, chanyoung Subject: [PATCH net 0/2] tls: fix plaintext sk_msg ring over-fill in tls_sw_sendmsg_splice() Date: Sun, 26 Jul 2026 19:55:54 +0900 Message-ID: <20260726105556.2719227-1-ppoo1220@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit An unprivileged local user can oops the kernel by splicing into a kTLS socket whose open record already has a full plaintext scatterlist ring. sk_msg_page_add() has no fullness check of its own and tls_sw_sendmsg_splice() only tests sk_msg_full() at the bottom of its do-while loop, so a page is always added before the ring is checked. That first add writes the reserved slot and wraps sg.end onto sg.start; sk_msg_iter_dist() then returns 0, sk_msg_full() reports the full ring as empty, and the loop keeps overwriting live entries while sg.size grows. Pushing the resulting record drives the AEAD with a cryptlen larger than the walkable scatterlist, so the walk runs past the end-marked entry and dereferences the NULL returned by sg_next(). The ring is left full and unpushed across a syscall by the copy path, which does not set full_record when the fragment it adds is the one that exactly fills the ring. No capabilities, namespaces, io_uring, nftables or BPF are involved; a plain loopback TCP socket with the "tls" ULP attached is enough. Reproduced as an ordinary user (uid 1000) on stock production configs -- CONFIG_TLS=y, no KASAN, no LOCKDEP, no fault injection -- on 7.2.0-rc4 and on 6.12.96. Present since v6.5. Patch 1 evaluates the loop condition before the first sk_msg_page_add() instead of after it. Patch 2 adds a regression test: it oopses an unpatched kernel and passes with patch 1 applied (924/924 for the whole tls suite, with CONFIG_CRYPTO_CHACHA20POLY1305, CONFIG_CRYPTO_SM4 and CONFIG_CRYPTO_ARIA enabled so every cipher variant runs). I found this with AI assistance, so per Documentation/process/security-bugs.rst I am treating it as public and posting here rather than sending it to security@kernel.org. For the same reason I am not posting the standalone reproducer; I can send it privately if that would be useful. chanyoung (2): tls: don't over-fill the plaintext sk_msg ring in tls_sw_sendmsg_splice() selftests: tls: add a test for splicing onto a full plaintext record net/tls/tls_sw.c | 4 +-- tools/testing/selftests/net/tls.c | 52 +++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) -- 2.43.0