From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DCCB12566F6; Tue, 25 Mar 2025 12:25:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742905549; cv=none; b=dRyYR5DbNfSOewpB1O3P1V+VJkfCQbwYnC725zkl47WcvLIFZa8ifFI3pQ8qOeOLh4F2DYbkqxA7l76eOwIURjDTg79oRr4G4FeQFjyrih4DBfMX77DNVFwMuqDjx2apBwdY+u2mKjhj2rZ0hnQRfVArsF9Imp9KMXNOoWl6HA4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742905549; c=relaxed/simple; bh=ABHkyN4/4sYiB3bYcWFyHfrW749ETodvgwQI1nNd3KE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tpq7JLcGrpzsfj8UCOp7ilFNM/9+rksWOG/KI9Z/8HLv1diQ4QoDHugjUxH0s/UDnoBHL4m0wyNBAu9O6ys+Ze1Wi0CA73QHhRfky7az5EoD+dS96WTC5heeRMU6QkD/erjer9xcwNLB3/AQbPzOA4FGYmwMwwTT/wFvpl/JKeM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=VZYM+0lv; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="VZYM+0lv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8871EC4CEE9; Tue, 25 Mar 2025 12:25:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1742905548; bh=ABHkyN4/4sYiB3bYcWFyHfrW749ETodvgwQI1nNd3KE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VZYM+0lv0clE2f+M3HnvM6gBqZBEqPAtTo5BlUpFtrs5guxcxeSyaMpya1wGlMjY3 4+RIkgW9PpmIRF5p7CopMrHhcGVy7tbl6bDugemaKDQHnvSU+7Nub93IOobSbsywV7 aN1Z2Y/C5ZqhZ5KNxSWKlEanWc8e044ERGH56qhA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chengen Du , Konrad Rzeszutek Wilk , Sasha Levin Subject: [PATCH 6.1 034/198] iscsi_ibft: Fix UBSAN shift-out-of-bounds warning in ibft_attr_show_nic() Date: Tue, 25 Mar 2025 08:19:56 -0400 Message-ID: <20250325122157.533988289@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250325122156.633329074@linuxfoundation.org> References: <20250325122156.633329074@linuxfoundation.org> User-Agent: quilt/0.68 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 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chengen Du [ Upstream commit 07e0d99a2f701123ad3104c0f1a1e66bce74d6e5 ] When performing an iSCSI boot using IPv6, iscsistart still reads the /sys/firmware/ibft/ethernetX/subnet-mask entry. Since the IPv6 prefix length is 64, this causes the shift exponent to become negative, triggering a UBSAN warning. As the concept of a subnet mask does not apply to IPv6, the value is set to ~0 to suppress the warning message. Signed-off-by: Chengen Du Signed-off-by: Konrad Rzeszutek Wilk Signed-off-by: Sasha Levin --- drivers/firmware/iscsi_ibft.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c index 6e9788324fea5..371f24569b3b2 100644 --- a/drivers/firmware/iscsi_ibft.c +++ b/drivers/firmware/iscsi_ibft.c @@ -310,7 +310,10 @@ static ssize_t ibft_attr_show_nic(void *data, int type, char *buf) str += sprintf_ipaddr(str, nic->ip_addr); break; case ISCSI_BOOT_ETH_SUBNET_MASK: - val = cpu_to_be32(~((1 << (32-nic->subnet_mask_prefix))-1)); + if (nic->subnet_mask_prefix > 32) + val = cpu_to_be32(~0); + else + val = cpu_to_be32(~((1 << (32-nic->subnet_mask_prefix))-1)); str += sprintf(str, "%pI4", &val); break; case ISCSI_BOOT_ETH_PREFIX_LEN: -- 2.39.5