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 0E0F5268C4F; Tue, 8 Apr 2025 12:03:19 +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=1744113799; cv=none; b=M/YwgkU/u5MDxqFqtirFl2QoaKcTTHdsYoHQzkdsbjjjTNw5GCsm5iP8VNSAurNEIJb81Wh+2czNt0IjO/D7no/ZSbhgIwJGecBJ02tyqFUFJMhJDehxoTS+N+I8wEuWfLQ0LbwaECFOmC0FrtUFrs8dGqla5sqo+/wSMlBwTU8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744113799; c=relaxed/simple; bh=IMY7WoyGjvLecLHQ6xxcD5iUvGYS9RtZCJpZFaRIOcQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JVXLnRoQ7atzyRXZ6M+aZB/GqYKA4IyCfdEcyijMpi13IxXVwMIJUJ8l5VL77YPvNoU6jnrW2a/sEpPqw7Jr1VXRf5Ot2YtWFsRE4A/vCWUzztSKokt59T3wgVD6ZKUQPtIMIadpiNDq7bmN+ky6jmcZZGiITTJ/8Z8pxTDII4E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TN+XdIXy; 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="TN+XdIXy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 952C4C4CEE5; Tue, 8 Apr 2025 12:03:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744113798; bh=IMY7WoyGjvLecLHQ6xxcD5iUvGYS9RtZCJpZFaRIOcQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TN+XdIXy6KVDl493yWSfD+NZVXfl/t8RXOjI3Cjw5AtgqKUCX9n3oAldBw8KjGipi PSDV/8W3gJUSoip1MC/d7a23wElMNL4q70f9zmSJ1KKyyOgYkgdga9QyCw4VeewyNf cbHmIG1p0Ks8f9CDscJqTRb6N01+Ii5bcWboy5Vk= 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 5.4 024/154] iscsi_ibft: Fix UBSAN shift-out-of-bounds warning in ibft_attr_show_nic() Date: Tue, 8 Apr 2025 12:49:25 +0200 Message-ID: <20250408104816.046656530@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250408104815.295196624@linuxfoundation.org> References: <20250408104815.295196624@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-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 7e12cbdf957cc..daf42b5319e89 100644 --- a/drivers/firmware/iscsi_ibft.c +++ b/drivers/firmware/iscsi_ibft.c @@ -311,7 +311,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