🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19734

Re: [PATCH net] net/mlx5: fix a stack over-read in the QP debugfs files

#19734
From: Aibing Chen
Date: Fri, 20 Nov 2026 09:53
22 lines
9727 bytes
Hi,

How it was found: by code inspection, not from a report or a tool - while
looking at how the mlx5 debugfs field readers use the return value of
snprintf().

Was it triggered: no, I did not reproduce it at runtime.  It is statically
decidable from the code: snprintf() returns the length the output would
have had (23 for "Invalid transport type" plus the newline) instead of the
number of bytes written (18), and simple_read_from_buffer() uses that
value to bound the copy to userspace.  It is only reachable when the
device reports a QP transport value that mlx5_qp_type_str() does not name.

Hardware: not tested on real hardware, I do not have mlx5 hardware
available.  The change only uses scnprintf() so that the length passed to
simple_read_from_buffer() can no longer exceed the buffer, and enlarges
the buffer so that the longest string still fits; neither needs device
specific behaviour.

Thanks,
Aibing Chen
Technical Details
Message-ID: <20261120095340.1564-1-chenaibing@cmss.chinamobile.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367834-linux-kernel-netdev=dewy.ru
References: <179516120532.3291.16859269248680746966@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367834-linux-kernel-netdev=dewy.ru
From: chenaibing@cmss.chinamobile.com (Aibing Chen)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] net/mlx5: fix a stack over-read in the QP debugfs files
Date: Fri, 20 Nov 2026 17:53:40 +0800
Organization: Usenet Network
Message-ID: <20261120095340.1564-1-chenaibing@cmss.chinamobile.com>
References: <179516120532.3291.16859269248680746966@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3125207"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:x70B81wXfsVGkWMQ6IOsSercGY0= sha256:3L23gMK1YTq3cF3uMAvHlFMke4xseD+iWaon/iV7+2Q=
	sha1:c5CukUMOFbRMWXn94vnB59A/ln0= sha256:Tr9oS/wvKTnc9BW9FYKBNnRsSs7HJQBdxNvQ7aNJklE=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 05AA611593A; Fri, 20 Nov 2026 12:54:59 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.751
X-Spam-Status: No, score=-2.751 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_INVALID=0.1, DKIM_SIGNED=0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=fail (1024-bit key)
	reason="fail (body has been altered)" header.d=cmss.chinamobile.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 5TJel2nnlP7G;
	Fri, 20 Nov 2026 12:54:55 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-367834-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=cmss.chinamobile.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 7E686115926; Fri, 20 Nov 2026 12:54:47 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 973BA122594; Fri, 20 Nov 2026 09:54:24 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795168437;
	b=VjVZuTewDWN9azEKhc89US6+eHCZGKuTg0jTZt7Cg/j0Fw0uDU4tOg3xYks1i+oYKPCw
	 IGBDsMtMLO4as91kylPMYKygigE4Kd1SJzzrnUKiDY90THGeDmDwG4B7p9SWggL6mBSTy
	 hwli/HKcvf3cyFth6vGvAt8UtXlhvjyxooUWBf12pXFelfxn4SLncH/N/IjZbXwm8TBwl
	 +ivm2oWYBG2io37AidCNdemrVsecbC93kpwOHjeXXqyTZIv3RcxA+Hq/NeKRH/0WHJN0S
	 fh+g5MAwCjxeI+40A2Qc0yF1uSN1fI8QN9efm/jOdAzpvp2xAmwfBgp9XiwUDk5KOkQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795168437;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:X-RM-TagInfo:
	 X-RM-SPAM-FLAG:Received:X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:
	 Received:X-RM-TRANSID:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=5ofwWF4BbSu2ZoIqY2hK6IvWa8riDyXLn0Lwxc6gChk=;
	b=IkKWR17Z0pCv1fb2qTRjwg3c8kiQhDrOwYpX56x7QQQMRv6+QYwZLoMM6WF8y/0xeHFr
	 z+De6XuLAWInI++y38QGTxmWtjnMi5PBa3ZcseI/rxcejRFWj595NsNB6ITiMoj2RKmGf
	 RI6CUQsJBHWhGsCM2UFVyM28vzPg3TDwQRtob7J7QJknQTqqBA8HhzzaBdHTvFdFQqZZB
	 OAyhf9jo9zbtnDdax8MYNJR2yBPiLSaNJ4eyjtVH+TlahMpVaqA9z0QfMVT2+bSUyD23w
	 tEovDyY3QFD/7ttQGD3Bl0WLulsrihX2nU217QgTuL5bH1bld1ctCUouTQTAKYTFshA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=oNMk6ctz;
	dmarc=pass header.from=cmss.chinamobile.com;
	spf=pass smtp.mailfrom=cmss.chinamobile.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F7E6606A33E;
	Fri, 20 Nov 2026 09:53:57 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=oNMk6ctz
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.137
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795168426;
	b=js/tstw71kj+BUej25bQ1+RoidR0L/KxBZi7bvLEQ3WQxpd+QpFzPG/zxNTpBkHH13E4
	 JalKCw3N8LY5vcPs6UYwN9GXQqdPO6lW8sAnWBrRBv7DXtys7CrzZmh+YgBFrzO16etM3
	 nk4/nAD3FiDLT8uZZyLUjtRjAcfDorlSV/KMt/IL4ceaFvUVgg9lfjK8IHaSA/1EusFwn
	 A4jAIsIFV63+thtcdVm8muCbr5CAxxT1QYIy+qX0y75mHnsRC00sMd2G6gI5io1ujW6WN
	 ok8hbd3cPnA/1JPSLnNEElM9n7TuOt4ShZ50scbzOl8c/v5QcKflF5urXz3U91m41/g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795168426;
	h=DMARC-Filter:DKIM-Signature:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:
	 X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:X-RM-TRANSID:From:
	 To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:
	 MIME-Version:Content-Transfer-Encoding;
	bh=5ofwWF4BbSu2ZoIqY2hK6IvWa8riDyXLn0Lwxc6gChk=;
	b=Ku/yX7m3SAwf2F+9HW6Nv9N7UN2widcFbl+/IVhA5tDMpEy6+ZVqSz2fp/5n4ihep0IK
	 fOo3AMCIqTyZBh/vZy6sy2OLh101LZa2NQOegP8IYCWgo6n9UlDG6DQSvjdAX67+L6n06
	 FfiHneCEM7fqiKUfOwOYWXhbBN7Piyh5f0Yu/r2nBDhxY1XPiKwGZCRKN7pQmSKlxUIPH
	 ijnfvLyq+Ib22AeRYjX1j4+P67EIb7VjfMSbWHwSFR1uxywGPiCYfHoLTbeTpkG5TkOsl
	 PQDWOKTrTilu92Gubs9/hJBzWs5dtgyuTKIFO002Pj4AOOacuHv9aumZKCWJSdnM81g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=cmss.chinamobile.com;
	spf=pass smtp.mailfrom=cmss.chinamobile.com;
	dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=oNMk6ctz;
	arc=none smtp.remote-ip=111.22.67.137
X-Received: from cmccmta4.chinamobile.com (cmccmta4.chinamobile.com [111.22.67.137])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 96993606A33B;
	Fri, 20 Nov 2026 09:53:44 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 96993606A33B
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmss.chinamobile.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmss.chinamobile.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=cmss.chinamobile.com; s=default; l=0;
	h=from:subject:message-id:to:cc:mime-version;
	bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=;
	b=oNMk6ctzGqaLhfVyU3qsOK6FrF65dzVgWFJQCXhhOaAe+ByUhLuZlCgZ548DMNcGeAR3oF+0sgboG
	 USb2XGDq0NvwlacFx92RLfh3cBW+pw84tkEdGpGm16pOfwYy/wHIRXY7Q/YZahnZvpMH8BpQKpADJF
	 hq0VyMFL+yLiNOeM=
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from spf.mail.chinamobile.com (unknown[10.188.0.87])
	by rmmx-syy-dmz-app04-12004 (RichMail) with SMTP id 2ee46b0018a4ceb-c82a4;
	Fri, 20 Nov 2026 17:53:42 +0800 (CST)
X-RM-TRANSID: 2ee46b0018a4ceb-c82a4
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from FHD-W7400297 (unknown[10.55.1.70])
	by rmsmtp-syy-appsvr10-12010 (RichMail) with SMTP id 2eea6b0018a444e-206a2;
	Fri, 20 Nov 2026 17:53:42 +0800 (CST)
X-RM-TRANSID: 2eea6b0018a444e-206a2
X-Cc: Saeed Mahameed <saeedm@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>,
	Tariq Toukan <tariqt@nvidia.com>,
	Mark Bloch <mbloch@nvidia.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org,
	linux-rdma@vger.kernel.org,
	linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.50.1.windows.1
X-In-Reply-To: <179516120532.3291.16859269248680746966@kernel.org>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list