From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.120 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795556513; b=YT07t+E1iEGVWsM6pWKTufJpyKs+r11t89Qkdgzvb+OMtuB6H/XZ9qL4d75z1onoND82 Z3TG70cp3t9TxZrZruTEit+6VlD5tuN6qv24xgPO8lkl65TmvkEP3Xgwl2OplH+a5ocTf pw1WDV50t0PS2UZbrq7OZQ+rYELGupWnzk571tOEWcfDiXSReKk61ZokQVeNaZMKpE7rm 4wGOglUg8D/kJY7xBaTJ/B/bFqmI5pAffMwBOCLcH+3C7vuDYfRErhrLphuUOprXLJXqS gavGQzCxVceUQYGs4sj5XjDDmQozufVrWNouDZlSdjgbDMEPJ1Jz1tlYFlTCwSa3iAw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795556513; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=fBw34VjXI6FKTwxvy5vlUkGqsFf2i9HgNV7OD3Q/bFw=; b=ocvNVbH4mNsBEJkGw2r1DalVZfqEFRCe+z/5d+TadPE2PV3C1n773FxYJxNtjTU+AVka p3BuCy1voldo/HPhiDoCkEpkgmDElsObw0NUIE8MzMr3gYIxWMHE90xRdnCOXF0FgR2Mh qA/YM9/bLjpRGYFhHuKeDnMUNENiHMlEhyoejG2dhBIY5jMWhul3oxIIUqnRFcvnz4wpA JBNgaMqcVtPqFkRjeKZGYGri4X4LstyjKgIEmZ7pmmssKDAkQs4vtgs0vBC/lki4YxgDL Zl62DHCJbBPLRCapFJqULN6eZmKBs3M9PldKteWqV9HhYQpgfXYlFu/Dtan3eaMWJSQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=p1P+u2VA; arc=none smtp.remote-ip=91.218.175.120 Received: from mta0.migadu.com (out-120.mta0.migadu.com [91.218.175.120]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 18B43606A321 for ; Tue, 24 Nov 2026 21:41:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 18B43606A321 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=p1P+u2VA X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=pG0pbDPXEhb0Uhnakajn47AzZb55mJKGr0OFmmS5OzE=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1795556510; v=1; x=1796161310; b=p1P+u2VATRwgRgeGPdN/T4L65GhO+KXASRlFnAJHxZGoRcnQh7BoHo6fZFq8cr/hB/Sw/zGW f2au4ccDguJj2DXcySz/qJf0gtEALrvcsPoDFwF5HSVeRX9uqNF6kqpwTP92ARPzXOJTCgONblp W3kuuFp1y17okGB9F7Floxb4= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id cbd3aa9428031233; Tue, 24 Nov 2026 21:41:49 +0000 X-Mizu-Trace-ID: cbd3aa9428031233 X-Migadu-Flow: FLOW_OUT Message-ID: Date: Tue, 24 Nov 2026 13:41:42 -0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH rdma-rc] RDMA/rxe: Zero struct rxe_mmap_info on allocation To: Andrew Stellman , Zhu Yanjun , "yanjun.zhu@linux.dev" Cc: Jason Gunthorpe , Leon Romanovsky , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org References: <20261123140620.64393-1-astellman@stellman-greene.com> From: Zhu Yanjun In-Reply-To: <20261123140620.64393-1-astellman@stellman-greene.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 在 2026/11/23 6:06, Andrew Stellman 写道: > rxe_create_mmap_info() allocates the structure with kmalloc_obj() and > does not set info.pad. do_mmap_info() copies ip->info to userspace with > copy_to_user(), so the 4 pad bytes of struct mminfo come from > uninitialized kernel heap memory. > > On x86_64 v7.4-rc3 under QEMU with init_on_alloc=0, an unprivileged > user (CapEff 0) issued 300 CQ_CREATE ioctls on rxe0 and read the driver > response. After the guest had run ls -lR on /proc and /sys and read > /proc/*/status and /proc/*/stat, 101 of the 300 pads were nonzero. In a > separate boot with slub_debug=P, all 300 pads were 0x6b6b6b6b. With > this patch, all 300 pads were zero in both configurations. > > Allocate the structure with kzalloc_obj() so the pad is zero. > > The issue was found by Claude Opus 5.5 running Quality Playbook, an LLM-driven code review tool: > https://github.com/andrewstellman/quality-playbook > The fix and this changelog were drafted with Claude Sonnet 5.5 and reviewed by me. > > Fixes: 8700e3e7c485 ("Soft RoCE driver") > Signed-off-by: Andrew Stellman > --- > A reproducer is available on request. > > drivers/infiniband/sw/rxe/rxe_mmap.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/infiniband/sw/rxe/rxe_mmap.c b/drivers/infiniband/sw/rxe/rxe_mmap.c > index a4ead89cc..ac851f245 100644 > --- a/drivers/infiniband/sw/rxe/rxe_mmap.c > +++ b/drivers/infiniband/sw/rxe/rxe_mmap.c > @@ -102,7 +102,7 @@ struct rxe_mmap_info *rxe_create_mmap_info(struct rxe_dev *rxe, u32 size, > if (!udata) > return ERR_PTR(-EINVAL); > > - ip = kmalloc_obj(*ip); > + ip = kzalloc_obj(*ip); Nice catch, thanks a lot. Could you also check for other unzeroed memory allocations like this and fix them? Reviewed-by: Zhu Yanjun Zhu Yanjun > if (!ip) > return ERR_PTR(-ENOMEM); >