Skip to content

Commit 07e0d99

Browse files
yukariatlaskonradwilk
authored andcommitted
iscsi_ibft: Fix UBSAN shift-out-of-bounds warning in ibft_attr_show_nic()
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 <chengen.du@canonical.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
1 parent e1e17a1 commit 07e0d99

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/firmware/iscsi_ibft.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,10 @@ static ssize_t ibft_attr_show_nic(void *data, int type, char *buf)
310310
str += sprintf_ipaddr(str, nic->ip_addr);
311311
break;
312312
case ISCSI_BOOT_ETH_SUBNET_MASK:
313-
val = cpu_to_be32(~((1 << (32-nic->subnet_mask_prefix))-1));
313+
if (nic->subnet_mask_prefix > 32)
314+
val = cpu_to_be32(~0);
315+
else
316+
val = cpu_to_be32(~((1 << (32-nic->subnet_mask_prefix))-1));
314317
str += sprintf(str, "%pI4", &val);
315318
break;
316319
case ISCSI_BOOT_ETH_PREFIX_LEN:

0 commit comments

Comments
 (0)