From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBF173242BD; Fri, 4 Sep 2026 05:08:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788498535; cv=none; b=ZezoQ+7hsD86viIWNwr49PrlJjSx+7AAeLHo36gjPRgOTJP0LqquDjmii9HxjwL6tW5Yo1F9UU97GfC1MuYQq1T1nQiRbCHTOG3shTVYtts6rpMPs+/ExzIdqroe2hYXiH7ZLm5W9YCTYo+KqqXNrbpLz372ZwJeibxcwf7Rz08= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788498535; c=relaxed/simple; bh=X60MgYtPZkBQlU0VtAcD2TFDNbMwraHRL7KWVld+xLs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HomQUvvV9dEn0OykfLmy6QVv02QZ0hTmNBfzRB4U9MSBHed26D0ibhCoFT4tG/eHbuPhAaCHyC5K/Oea9gAbKZSSeJ0axL2ZlIg2c5qPnCf9U4G9X8ouB7oQrOb07PwxiR2ik9kdeIET3T9UE5auPIOh6b8L272eBamsRYsDLvA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xrTb9EWT; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="xrTb9EWT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 521B41F00A3D; Fri, 4 Sep 2026 05:08:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788498533; bh=JMvmQiU7mg6Y2SqyozSdlEiJ8Ichz0QQd5ci4DRWKL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=xrTb9EWTctWqMkEDeWKBO6I7IPc3DSOJF0OgD1M8pfolUV9KWJLK8uUHuqXVFAQBf 62u7ZpeXwgaIZ/nTySh90rF6wpbY3LDFGkEnzC4y05preSHuzxQfTkbyTRmxR4m0b8 dQuxpUN75HTkLd/vKpjDw6Bn4j6cmiKKYTyJ+OFA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bryam Vargas , Alexander Graf Subject: [PATCH 7.2 097/713] misc: nsm: bound the device-reported response length Date: Fri, 4 Sep 2026 06:51:05 +0200 Message-ID: <20260904045806.012473438@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260904045803.810145556@linuxfoundation.org> References: <20260904045803.810145556@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bryam Vargas commit 808e530654a5354e6df78863a5d61e4d44e67235 upstream. nsm_sendrecv_msg_locked() stores the virtqueue used-ring length reported by the NSM device into msg->resp.len without bounding it to the response buffer. A malicious or buggy backend can report a length larger than the response buffer; parse_resp_raw() then copies that many bytes out of the fixed buffer to user space, disclosing adjacent kernel heap (an out-of-bounds read). The request path already floors its length in fill_req_raw(); the response path lacks the symmetric check. Clamp the stored length to the size of the response buffer. Well-behaved devices report no more than the posted buffer size, so conforming traffic is unaffected. Fixes: b9873755a6c8 ("misc: Add Nitro Secure Module driver") Cc: stable@vger.kernel.org Signed-off-by: Bryam Vargas Reviewed-by: Alexander Graf Link: https://patch.msgid.link/20260620-b4-disp-a54b7dd6-v1-1-79d1f236a854@proton.me Signed-off-by: Greg Kroah-Hartman --- drivers/misc/nsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/misc/nsm.c +++ b/drivers/misc/nsm.c @@ -243,7 +243,7 @@ static int nsm_sendrecv_msg_locked(struc goto cleanup; } - msg->resp.len = len; + msg->resp.len = min_t(unsigned int, len, sizeof(msg->resp.data)); rc = 0;