From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f41.google.com (mail-dl1-f41.google.com [74.125.82.41]) (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 799F4497B81 for ; Thu, 8 Oct 2026 12:49:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791463789; cv=none; b=fvb5oiGBD/+5aXSeiVI0IJsRfNoCz+1/AY7PUjOknUEs+nAyXzRVNQXzA/NdhbkTw1Hszf1xe2eUMGiKXJlERx9hS0fGo51/qVobe+RSCHsM1mV+paVoju01qEYBilieS+OjK1aNx/Sjj20zrrfo0HVO53DkyrcnIgf3giU/hnA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791463789; c=relaxed/simple; bh=B8O4UyYWgKHjCyiEvWQaDVeXppuTnbg4pu4xhsW+PqI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=afRFbSr56qxSdzDZDAHjVIsSEuzN5zwkIeGVUaSgjPsYse1memxyIFkwKzRKs0x8jYp1ttSS2T4oRDK2fbFFKJck24Wu5gggX45ihZL52prFgKb+pBNhDL9+a/D1n7KIldvAMEvs6hJnWRt933FqJlX82oKixkT8G9VT3b7SSGQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=octane.security; spf=pass smtp.mailfrom=octane.security; dkim=pass (2048-bit key) header.d=octane.security header.i=@octane.security header.b=QU2PqQAX; arc=none smtp.client-ip=74.125.82.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=octane.security Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=octane.security Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=octane.security header.i=@octane.security header.b="QU2PqQAX" Received: by mail-dl1-f41.google.com with SMTP id a92af1059eb24-15354aa70e8so1572025c88.1 for ; Thu, 08 Oct 2026 05:49:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=octane.security; s=google; t=1791463787; x=1792068587; 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=Aw49x50i74crGqe52PxPoi4v9QJFpR0yZ1MGPQQ+JH8=; b=QU2PqQAXbY0/Xx88zUSVelSV7Hcx4Ugt71ZgsD+PMsQkp3+EgDS1kUlbJ1M7441+W/ ewXvtSK15+rVc1OHtXG+kNoqYAAfPKkLZNQ60c7HDqAiD58dewNM5/0TxaxdKT3oVtnm EEFUxmEO8CHMUVwRP7gMoEINkYVMXCLe+4wV4SCE4SwCHLX4SmS5Cg0lcmy3SWAK0vuS 1+a/xPMnq1sNJ7Zj9it1e7ZiO9NUkq17/99Ifk0UQ56II6xpueZ3V0OY2pRTxNnsACZ1 Z2j/K9IYT65Uh8WfHr5QMB51J4bFfGbWryCyFTmZQhcQwosV20DAGXhRNCRdJYdW39Sp i69w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791463787; x=1792068587; 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=Aw49x50i74crGqe52PxPoi4v9QJFpR0yZ1MGPQQ+JH8=; b=Ry5Bk4gQpZj9tTJm1dldBW8LzZaN7OrVlWkn1SYybWLhDcOFL4kZPFXcrSpw1lCluw lWx7LQs+eY4c70y85U1SvryhsNlDnKmOUUcmiCiYvfqeku/r+3n7CAUQfMb2zinzfIkp YYhx7JDaWyhIvwrTTNJClAiNx25SmG3wQo1QWkGMDByg3jtOsBaPcfQ97LQNK5zkCVRz 1JR3vY5hBq5RrfPQ5N3Mzy1a34fZ/jVbhEhB52PsN4ZfAuHSSWk0oi7nmXBOxZH/VLkl vQCghOGX/Uj1yu8ysbIWDM+dv+WD7+qKdC4yn6wEVk7du9Zw5Y2YWnQEVjlcMjfhP73z rl5Q== X-Gm-Message-State: AFuF++lVSAbuWM0BBfeM1bd8b5Ae8FBQVwqkAL/d+jU+DbxATzh4twDn DclfSwm1j2vE3Vo/IPTTtnkH8ucptlIhgSaro0qDDdYCSrmD0aXwFBoA1jSl1KbPQpVI1nEcyB8 eysLo X-Gm-Gg: AYBFou3oBDWvn8rYlXrDLn4cjQAMuWHhugpVdwh0TMBxgzp/Oscd/KRZ8OdGdGvOeuS wsvfPJmngJWmctXYU69bYyH4UrUeWvuy1TmQRZhspGjg4UzB7HothwTACNGxDSEyx/3tHxSzZXj 97/EO8h6Gry4zTwARAUH0dxxG9Jsz4PB2/Mj7shJL9J24+VYVCM2qINUX2lWTWwf542kG9vj9N1 4DbA7ZeYzK528kHVDjoHpUc2u3L+NnnXbOJcifYAnhABzE09s5aaSVu8kp7ZtpqxTpN/AWeL/NY 0gFuaLZ/1kuPMxh1RCReB+dsXPjzvmgmTiTQiTKxmr9mgFBkL3ky6WG88RhdyUO41OXfNOT8Avc L0V5KHIXGWouydNaBuYymMgkPnyPQaRDBXv5vLBzdLYvICaynj0iUqr9XOqCB2ks7uAiGgLqupe MbTSEckg3UCAyHqT79RZpJoHAIRiD5Tk/xsDCdKBOlt4KvyjhLQRMqanvAgolQENS6nPhXQuzjK iJPhuPFDuOxNvmVFpDsYXdLMkOOvUc1pdr7vTtWmedk3E1N5ZJJ/JDHP9A6NsJfoD+nZA7uib78 7JAOOAhfUpk6Ow== X-Received: by 2002:a05:701b:2419:b0:168:3243:c911 with SMTP id a92af1059eb24-1683243ccb8mr540174c88.37.1791463787193; Thu, 08 Oct 2026 05:49:47 -0700 (PDT) Received: from localhost.localdomain ([103.207.175.177]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1630180f6a5sm11100896c88.22.2026.10.08.05.49.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 08 Oct 2026 05:49:46 -0700 (PDT) From: Shubham Antil To: netdev@vger.kernel.org, linux-rdma@vger.kernel.org Cc: Allison Henderson , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , linux-kernel@vger.kernel.org, Giovanni Vignone , sungbyeongchan Subject: [PATCH net v3] net/rds: ib: zero the unwritten tail of a short receive fragment Date: Thu, 8 Oct 2026 18:19:40 +0530 Message-ID: <20261008124940.13371-1-shubham@octane.security> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit rds_ib_process_recv() accepts an RDS/IB fragment once the receive completion reports at least an RDS header, and then trusts the header-declared message length h_len: rds_ib_inc_copy_to_user() later copies up to h_len bytes from the fragment pages to userspace on recvmsg(). When a fragment carries fewer payload bytes than h_len accounts for, the bytes between the end of the received payload and h_len are read from the unwritten tail of the fragment page. That page comes from the per-CPU receive cache and is not zeroed, so recvmsg() returns stale page contents to userspace. Zero the unwritten tail of a short fragment page on receipt, so the copy can only ever return received payload or zeros. Fragments that fill the page are unaffected. Confirmed under KMSAN: without this change recvmsg() returns stale frag-page bytes and KMSAN flags an uninitialised copy in rds_ib_inc_copy_to_user(); with it the same over-read returns zeros and KMSAN is clean. Fixes: 1e23b3ee0e94 ("RDS/IB: Receive datagrams via IB") Reported-by: sungbyeongchan Closes: https://lore.kernel.org/netdev/20261006205204.1322102-1-tjdqudcks0424@naver.com/ Reported-by: Shubham Antil Reported-by: Giovanni Vignone Reported-by: Robert van Eijk Reported-by: Paolo Gentry Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Shubham Antil --- v3: - Zero the unwritten fragment tail instead of dropping the connection. A zero-copy send with a small iovec segment can legitimately produce a non-final fragment shorter than RDS_FRAG_SIZE, so the v2 length check could force a reconnect on well-formed traffic; zeroing the tail avoids that while still keeping uninitialised bytes out of recvmsg(). (Raised by the Sashiko review.) - Drop Reviewed-by, since the approach changed. v2: - Add Reported-by (sungbyeongchan, first to report, and the Octane Security reporters). net/rds/ib_recv.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c index bd6cb3ffa..9695c7f24 100644 --- a/net/rds/ib_recv.c +++ b/net/rds/ib_recv.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include "rds_single_path.h" @@ -949,6 +950,19 @@ static void rds_ib_process_recv(struct rds_connection *conn, } } + /* The device wrote only data_len bytes into this recycled fragment + * page. Zero the unwritten tail so a later rds_ib_inc_copy_to_user(), + * which copies up to the peer-declared h_len, cannot hand stale page + * contents to userspace. + */ + if (data_len < RDS_FRAG_SIZE) { + void *frag = kmap_local_page(sg_page(&recv->r_frag->f_sg)); + + memset(frag + recv->r_frag->f_sg.offset + data_len, 0, + RDS_FRAG_SIZE - data_len); + kunmap_local(frag); + } + list_add_tail(&recv->r_frag->f_item, &ibinc->ii_frags); recv->r_frag = NULL; -- 2.43.0