Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4092210ybl; Fri, 20 Dec 2019 23:16:42 -0800 (PST) X-Google-Smtp-Source: APXvYqzAQ4v5R16oZls+CsVuTSSp4JLgHBWZceDjgA5va5jf2mGS7z6CnLcziGu26CQFHcuHOXLv X-Received: by 2002:a05:6830:160c:: with SMTP id g12mr19033544otr.82.1576912602142; Fri, 20 Dec 2019 23:16:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576912602; cv=none; d=google.com; s=arc-20160816; b=qtsSsAcyyw1Ouu8C5bcNJOYQ9xkBw3yRZamv3Bf2hwm7+96wc/w6mXbJOmBO2DK3Av rilVggU5Nt+4cJnQSY3e2kmUesUw79v3RNEBnniZtWZtCFTqpYmQOQfjmx/1z6VpoNg5 wbR+nKnI9Hvwgvg5mRikRp2KU3+JMgurWepv9/ac1oCkj/6rRODN3SuWYXmbkk4iyFkr KKjWOL9Niy7hydMARjsA1X+W0LIPlIGu9rjE1rValH0/Qd0FAaJ8GPtiGnGA/dn4A/SF GGSx1Ye6eyN0BUXn+1yWt9BRI5FlyzvFeEpmt7cfHvOxOJW7etGDp60oXj9wlApURvBZ 9i1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=D2dIbdxaDnpz6QUQwOkR9ct/4+QDAsKK7/1Em2/jr2E=; b=b1CLrP/kq+/Ffdpt5EAdsGQ7HlEUHnbz3rldpHHFqNwerDT+telOpdTLZ9nsGsVioZ hZN2nCCTMzV3hu8WrMpcxa72v1iCw5kaTiobq0XQ9k48+ByTvX6euAt2PZNvrywR5AgU ijW22fpVk1etnQHVf6Jnkm9+qfQds/qvu38KZR8QqIo0uaQj+sJCwkusEgQ/205lVFal HXdjZAeCI/mXnRAXQzjP21NOj5NZqEoGe4CYNioEd2Wy6W2e22YQSZeamdONAaGaDuqb pLBjxY36Q2ZjVi0p26RJv2XjF6VYb6OPpybqkrfYz1OFjCE86KToHOQGP8VK+cqfwHgQ 6DyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v145si5915134oia.68.2019.12.20.23.16.17; Fri, 20 Dec 2019 23:16:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725997AbfLUHKF (ORCPT + 99 others); Sat, 21 Dec 2019 02:10:05 -0500 Received: from [167.172.186.51] ([167.172.186.51]:39792 "EHLO shell.v3.sk" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725774AbfLUHKE (ORCPT ); Sat, 21 Dec 2019 02:10:04 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 9D84DDFCD4; Sat, 21 Dec 2019 07:10:05 +0000 (UTC) Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id TKdS04iwZrAD; Sat, 21 Dec 2019 07:10:03 +0000 (UTC) Received: from localhost (localhost.localdomain [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id C8622DFCD3; Sat, 21 Dec 2019 07:10:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at zimbra.v3.sk Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id iOjmmQTgDlxz; Sat, 21 Dec 2019 07:10:03 +0000 (UTC) Received: from furthur.lan (unknown [109.183.109.54]) by zimbra.v3.sk (Postfix) with ESMTPSA id 4F22EDFCD0; Sat, 21 Dec 2019 07:10:03 +0000 (UTC) From: Lubomir Rintel To: Konrad Rzeszutek Wilk Cc: Peter Jones , linux-kernel@vger.kernel.org, Lubomir Rintel Subject: [RESEND PATCH] iscsi_ibft: Don't limits Targets and NICs to two Date: Sat, 21 Dec 2019 08:09:56 +0100 Message-Id: <20191221070956.268321-1-lkundrak@v3.sk> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org According to iSCSI Boot Firmware Table Version 1.03 [1], the length of the control table is ">=3D 18", where the optional expansion structure pointer follow the mandatory ones. This allows for more than two NICs and Targets. [1] ftp://ftp.software.ibm.com/systems/support/bladecenter/iscsi_boot_fir= mware_table_v1.03.pdf Let's enforce the minimum length of the control structure instead instead of limiting it to the smallest allowed size. Signed-off-by: Lubomir Rintel --- drivers/firmware/iscsi_ibft.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.= c index 7e12cbdf957cc..96758b71a8db8 100644 --- a/drivers/firmware/iscsi_ibft.c +++ b/drivers/firmware/iscsi_ibft.c @@ -104,6 +104,7 @@ struct ibft_control { u16 tgt0_off; u16 nic1_off; u16 tgt1_off; + u16 expansion[0]; } __attribute__((__packed__)); =20 struct ibft_initiator { @@ -235,7 +236,7 @@ static int ibft_verify_hdr(char *t, struct ibft_hdr *= hdr, int id, int length) "found %d instead!\n", t, id, hdr->id); return -ENODEV; } - if (hdr->length !=3D length) { + if (length && hdr->length !=3D length) { printk(KERN_ERR "iBFT error: We expected the %s " \ "field header.length to have %d but " \ "found %d instead!\n", t, length, hdr->length); @@ -749,16 +750,16 @@ static int __init ibft_register_kobjects(struct acp= i_table_ibft *header) control =3D (void *)header + sizeof(*header); end =3D (void *)control + control->hdr.length; eot_offset =3D (void *)header + header->header.length - (void *)control= ; - rc =3D ibft_verify_hdr("control", (struct ibft_hdr *)control, id_contro= l, - sizeof(*control)); + rc =3D ibft_verify_hdr("control", (struct ibft_hdr *)control, id_contro= l, 0); =20 /* iBFT table safety checking */ rc |=3D ((control->hdr.index) ? -ENODEV : 0); + rc |=3D ((control->hdr.length < sizeof(*control)) ? -ENODEV : 0); if (rc) { printk(KERN_ERR "iBFT error: Control header is invalid!\n"); return rc; } - for (ptr =3D &control->initiator_off; ptr < end; ptr +=3D sizeof(u16)) = { + for (ptr =3D &control->initiator_off; ptr + sizeof(u16) <=3D end; ptr += =3D sizeof(u16)) { offset =3D *(u16 *)ptr; if (offset && offset < header->header.length && offset < eot_offset) { --=20 2.24.1