From patchwork Tue Sep 11 18:15:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 10596135 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 48CCA1575 for ; Tue, 11 Sep 2018 18:15:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31DE529C3B for ; Tue, 11 Sep 2018 18:15:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 259ED29C2F; Tue, 11 Sep 2018 18:15:42 +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=-7.9 required=2.0 tests=BAYES_00,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 C7F9A29C3B for ; Tue, 11 Sep 2018 18:15:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727278AbeIKXQK (ORCPT ); Tue, 11 Sep 2018 19:16:10 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:35489 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727413AbeIKXQK (ORCPT ); Tue, 11 Sep 2018 19:16:10 -0400 Received: by mail-qt0-f194.google.com with SMTP id j7-v6so29297194qtp.2 for ; Tue, 11 Sep 2018 11:15:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=A743d/wM/mljAAT/I+NbjlnB3etN4k5o3DxXuJzTTUQ=; b=DyOl/8aNf1pA7JEbMpb1nEufy7P/8m5Ls8AQOUakiIsh+3KASHnYl6+hz0i42bLLUg lLYqNKsjfkBB/UfGL68IaxlfSn1P4AX0/lye2ck1u9qkbpdZA8xxCN6ZTMZEp9yOLjE6 +8mXksQXapAZdYrg6rgzOc7OYkmtMayz8N242ivXXhZBpvrYbEsO8hJLjwy2R/E4zOHH wtmUob9pC9peU1f0pWwQSK2J+dc/jEkh8jo8iQHafULgeFeWjFREk63s4H6uvxJSL0cn H+hTqBsSjV2Tc0soW7bSXiHHH1pHKXJj0gfPP6ZfU4t9BsDu6tK4XicKnjhh4zA9uHd0 ZuGw== X-Gm-Message-State: APzg51AuRt9LIeK+U9kdy7jwGz2UaRoyJ7Idrd1JZc+J1wnE1/Lvhwbl H3qZ1b/LYkwW5HKToA1edlkcZg== X-Google-Smtp-Source: ANB0Vdb9SlfG9zUHSdFAP1ap5tuZtyLlfp3M7yI8IJu07ifMJZmn+WiT8b1fy96mFOvpFqYMPpPc4Q== X-Received: by 2002:a0c:c969:: with SMTP id v38-v6mr19726328qvj.192.1536689740060; Tue, 11 Sep 2018 11:15:40 -0700 (PDT) Received: from labbott-redhat.redhat.com ([2601:602:9802:a8dc::42c3]) by smtp.gmail.com with ESMTPSA id 62-v6sm11813115qkx.66.2018.09.11.11.15.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Sep 2018 11:15:38 -0700 (PDT) From: Laura Abbott To: "Bryant G. Ly" , Michael Cyr , Kees Cook Cc: Laura Abbott , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: ibmvscsis: Ensure partition name is properly NUL terminated Date: Tue, 11 Sep 2018 11:15:34 -0700 Message-Id: <20180911181534.18553-1-labbott@redhat.com> X-Mailer: git-send-email 2.17.1 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP While reviewing another part of the code, Kees noticed that the strncpy of the partition name might not always be NUL terminated. Switch to using strlcpy which does this safely. Reported-by: Kees Cook Signed-off-by: Laura Abbott --- I realized looking at this that I probably should have made this and my previous patch a series given this has context depending on the other patch. I can resend if the scsi maintainers want. --- drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c index 9305440a00a1..1217bf2a28db 100644 --- a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +++ b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c @@ -3477,7 +3477,7 @@ static int ibmvscsis_probe(struct vio_dev *vdev, snprintf(vscsi->eye, sizeof(vscsi->eye), "VSCSI%s", vdev->name); vscsi->dds.unit_id = vdev->unit_address; - strncpy(vscsi->dds.partition_name, partition_name, + strlcpy(vscsi->dds.partition_name, partition_name, sizeof(vscsi->dds.partition_name)); vscsi->dds.partition_num = partition_number;