Received: by 10.223.185.111 with SMTP id b44csp823735wrg; Fri, 9 Mar 2018 14:34:47 -0800 (PST) X-Google-Smtp-Source: AG47ELuOGhCH+/LMSiS6KIxJ3S65qH1VqWcRVtgerdzY8iCvGunhp1vj+4/sQfISmBZP1fFT0ShM X-Received: by 10.98.66.89 with SMTP id p86mr75870pfa.228.1520634887207; Fri, 09 Mar 2018 14:34:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520634887; cv=none; d=google.com; s=arc-20160816; b=u8ccQDqJbY1o4Z9VD+xQ4uHD9hAqMVDEKt41Gg2+Z0I1nnHkPO/egggvYVQt7TdscZ 1Kweu69jkLJcngwToCCCr+k4IFU+CANpHtq7Mmylk2gZhfmKozdwHb8SATJz9Y71OaIG XmHjgbVFsgAyGy9bMau20cnhUxbpUBp6K7TwSM/f+o34EqRBztAp0vU9SLhjvcbWxzqR 8F/7C3aGU/NsLrHw9VVDvA2nzl4sYFaTZa13di+dAvZl8G+688qcz7OKrv7kbDo1CtH1 foctMtTmKT0pj1gGIev9aQ58IknxYRs23B1/936ve7bn3RG9GBSoOIl/NNOQR81Vj1om l1wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=TzGJL5rQN5RUtGhgQ/iqCzq8IqMQorRHAoyOheKtGYY=; b=lRj6tZmsOqxOdaF7LWK50pA9eobjkiW0Isif83axZOeb2NXxT7rCKD/5CoiS4jRJFm LLFjF1Vyck/cfrPzmJGBZ/F9qDftEZshAtlQgCEfQyisKKsqr8WD0z1zJ4J6+K4ISNKq aqsODxMEL9OP/glrG1UyuMvEsWqzsPMg69swRZ7epzyGWytfBHCdf6+rT3jHpgfIlSz9 SONlJoNi3DO20MfCf8SR3EQLNcB2hYWybwkCDbKmm6anSYev5DxTfQUmVPAaubFRm1le ZBXa0ZQ9wlEAv+hGvBzQtVbLGcUglvHLoVNZxNPIGuzOhXqqtV4U9YyRLHl/q6qYkYqT KXlA== 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 b10si1370884pgn.140.2018.03.09.14.34.32; Fri, 09 Mar 2018 14:34:47 -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 S933033AbeCIWce (ORCPT + 99 others); Fri, 9 Mar 2018 17:32:34 -0500 Received: from smtp5-g21.free.fr ([212.27.42.5]:33830 "EHLO smtp5-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932810AbeCIWca (ORCPT ); Fri, 9 Mar 2018 17:32:30 -0500 Received: from heffalump.sk2.org (unknown [88.186.243.14]) by smtp5-g21.free.fr (Postfix) with ESMTPS id 51AE45FF13; Fri, 9 Mar 2018 23:32:27 +0100 (CET) Received: from steve by heffalump.sk2.org with local (Exim 4.89) (envelope-from ) id 1euQYt-0005Kt-5F; Fri, 09 Mar 2018 23:32:27 +0100 From: Stephen Kitt To: hare@suse.com, axboe@kernel.dk, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, kernel-hardening@lists.openwall.com, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Stephen Kitt Subject: [PATCH] device_handler: remove VLAs Date: Fri, 9 Mar 2018 23:32:11 +0100 Message-Id: <20180309223211.20473-1-steve@sk2.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180309232933.14e39858@heffalump.sk2.org> References: <20180309232933.14e39858@heffalump.sk2.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation to enabling -Wvla, remove VLAs and replace them with fixed-length arrays instead. scsi_dh_{alua,emc,rdac} use variable-length array declarations to store command blocks, with the appropriate size as determined by COMMAND_SIZE. This patch replaces these with fixed-sized arrays using MAX_COMMAND_SIZE, so that the array size can be determined at compile time. This was prompted by https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Stephen Kitt --- drivers/scsi/device_handler/scsi_dh_alua.c | 8 ++++---- drivers/scsi/device_handler/scsi_dh_emc.c | 2 +- drivers/scsi/device_handler/scsi_dh_rdac.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c index 4b44325d1a82..982a52528a1c 100644 --- a/drivers/scsi/device_handler/scsi_dh_alua.c +++ b/drivers/scsi/device_handler/scsi_dh_alua.c @@ -138,12 +138,12 @@ static void release_port_group(struct kref *kref) static int submit_rtpg(struct scsi_device *sdev, unsigned char *buff, int bufflen, struct scsi_sense_hdr *sshdr, int flags) { - u8 cdb[COMMAND_SIZE(MAINTENANCE_IN)]; + u8 cdb[MAX_COMMAND_SIZE]; int req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER; /* Prepare the command. */ - memset(cdb, 0x0, COMMAND_SIZE(MAINTENANCE_IN)); + memset(cdb, 0x0, MAX_COMMAND_SIZE); cdb[0] = MAINTENANCE_IN; if (!(flags & ALUA_RTPG_EXT_HDR_UNSUPP)) cdb[1] = MI_REPORT_TARGET_PGS | MI_EXT_HDR_PARAM_FMT; @@ -166,7 +166,7 @@ static int submit_rtpg(struct scsi_device *sdev, unsigned char *buff, static int submit_stpg(struct scsi_device *sdev, int group_id, struct scsi_sense_hdr *sshdr) { - u8 cdb[COMMAND_SIZE(MAINTENANCE_OUT)]; + u8 cdb[MAX_COMMAND_SIZE]; unsigned char stpg_data[8]; int stpg_len = 8; int req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | @@ -178,7 +178,7 @@ static int submit_stpg(struct scsi_device *sdev, int group_id, put_unaligned_be16(group_id, &stpg_data[6]); /* Prepare the command. */ - memset(cdb, 0x0, COMMAND_SIZE(MAINTENANCE_OUT)); + memset(cdb, 0x0, MAX_COMMAND_SIZE); cdb[0] = MAINTENANCE_OUT; cdb[1] = MO_SET_TARGET_PGS; put_unaligned_be32(stpg_len, &cdb[6]); diff --git a/drivers/scsi/device_handler/scsi_dh_emc.c b/drivers/scsi/device_handler/scsi_dh_emc.c index 6a2792f3a37e..95c47909a58f 100644 --- a/drivers/scsi/device_handler/scsi_dh_emc.c +++ b/drivers/scsi/device_handler/scsi_dh_emc.c @@ -249,7 +249,7 @@ static int send_trespass_cmd(struct scsi_device *sdev, struct clariion_dh_data *csdev) { unsigned char *page22; - unsigned char cdb[COMMAND_SIZE(MODE_SELECT)]; + unsigned char cdb[MAX_COMMAND_SIZE]; int err, res = SCSI_DH_OK, len; struct scsi_sense_hdr sshdr; u64 req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c index 7af31a1247ee..d27fabae8ddd 100644 --- a/drivers/scsi/device_handler/scsi_dh_rdac.c +++ b/drivers/scsi/device_handler/scsi_dh_rdac.c @@ -533,7 +533,7 @@ static void send_mode_select(struct work_struct *work) int err = SCSI_DH_OK, retry_cnt = RDAC_RETRY_COUNT; struct rdac_queue_data *tmp, *qdata; LIST_HEAD(list); - unsigned char cdb[COMMAND_SIZE(MODE_SELECT_10)]; + unsigned char cdb[MAX_COMMAND_SIZE]; struct scsi_sense_hdr sshdr; unsigned int data_size; u64 req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | -- 2.11.0