From patchwork Wed May 2 22:55:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10376771 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 822E76037D for ; Wed, 2 May 2018 22:56:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73BE829183 for ; Wed, 2 May 2018 22:56:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6823629186; Wed, 2 May 2018 22:56:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B77529183 for ; Wed, 2 May 2018 22:56:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751573AbeEBWzt (ORCPT ); Wed, 2 May 2018 18:55:49 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:46013 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751148AbeEBWzs (ORCPT ); Wed, 2 May 2018 18:55:48 -0400 Received: by mail-pf0-f193.google.com with SMTP id c10so13023259pfi.12 for ; Wed, 02 May 2018 15:55:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=+MIrHLa2R+IEtpgmg0S/zDhtXsyGW1JGyfsWADZRbqw=; b=CeiS5dB4YVl+U3NdbEHEYuywPibNXtYUVQlReyNM2nER0TrQp5tMrUX5ljAn8PPGWd Kt0nMpXwit14JoB4yrh1UNYPhd0MK8MAcc6ZIMScvBdRQgnhlMykPp31lVV56f2x9vQP eU9y69s86QM4wVI9w2Wy4En31wZM8uhorZF70= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=+MIrHLa2R+IEtpgmg0S/zDhtXsyGW1JGyfsWADZRbqw=; b=MC/nJiNrDlP+wwjh8kF0fSKRKL/iUkUlMGx4Lfca9fFTyN9Gco82wQKkbjcsD9QQrT kkOOeYt9JI8E6WtfQxr10yl5dajn8mM3K5bUGvtGpKl+SUFwtj3B7io8+85e3vSRJ7gj V+Iss22k/VZxM9SvA3EVjIAUmegWmQ5dm9OOmHbxT10yLeJ8qn8/8I8zKivjru4s7wf0 Sxh0H1JKLIt52PhsJfqn0J3LgG23k9V9G0pSj3IAMhXknvpL1MkvzB7yJR7mJF3CDFxX kvSaTWdvurqqJbKEYjsPGk88K2WvXadzg3O83p4Vb2ZqcjuKUqsS/49hAV81s7J4+p7w kzZQ== X-Gm-Message-State: ALQs6tCsygoT17MVrhhUC1uOL/DJCoyuSPj3GnlD9RN/e+tNPLFv4T/l nbmGGK/c7nbkvuJHvrozZB9MOA== X-Google-Smtp-Source: AB8JxZpdclIVqxhXK0SOfWGifQ78Yn7hIth20EDAzIuRlBMhdFXg/ugdgklN7dmcUzLtOW9PmWqLSQ== X-Received: by 2002:a17:902:aa95:: with SMTP id d21-v6mr20585524plr.73.1525301748191; Wed, 02 May 2018 15:55:48 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id l19-v6sm19605692pgn.44.2018.05.02.15.55.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 02 May 2018 15:55:46 -0700 (PDT) Date: Wed, 2 May 2018 15:55:45 -0700 From: Kees Cook To: "Martin K. Petersen" Cc: Boaz Harrosh , "James E.J. Bottomley" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: libosd: Remove VLA usage Message-ID: <20180502225545.GA45533@beast> MIME-Version: 1.0 Content-Disposition: inline Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On the quest to remove all VLAs from the kernel[1] this rearranges the code to avoid a VLA warning under -Wvla (gcc doesn't recognize "const" variables as not triggering VLA creation). Additionally cleans up variable naming to avoid 80 character column limit. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com Signed-off-by: Kees Cook --- drivers/scsi/osd/osd_initiator.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/osd/osd_initiator.c b/drivers/scsi/osd/osd_initiator.c index e18877177f1b..917a86a2ae8c 100644 --- a/drivers/scsi/osd/osd_initiator.c +++ b/drivers/scsi/osd/osd_initiator.c @@ -1842,14 +1842,14 @@ int osd_req_decode_sense_full(struct osd_request *or, case osd_sense_response_integrity_check: { struct osd_sense_response_integrity_check_descriptor - *osricd = cur_descriptor; - const unsigned len = - sizeof(osricd->integrity_check_value); - char key_dump[len*4 + 2]; /* 2nibbles+space+ASCII */ - - hex_dump_to_buffer(osricd->integrity_check_value, len, - 32, 1, key_dump, sizeof(key_dump), true); - OSD_SENSE_PRINT2("response_integrity [%s]\n", key_dump); + *d = cur_descriptor; + /* 2nibbles+space+ASCII */ + char dump[sizeof(d->integrity_check_value) * 4 + 2]; + + hex_dump_to_buffer(d->integrity_check_value, + sizeof(d->integrity_check_value), + 32, 1, dump, sizeof(dump), true); + OSD_SENSE_PRINT2("response_integrity [%s]\n", dump); } case osd_sense_attribute_identification: {