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: 10596133 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 280E314BD 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 1074429C2F for ; Tue, 11 Sep 2018 18:15:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 04C0729C43; 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=ham 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 A6B4429C2F for ; Tue, 11 Sep 2018 18:15:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727657AbeIKXQK (ORCPT ); Tue, 11 Sep 2018 19:16:10 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:45650 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727278AbeIKXQK (ORCPT ); Tue, 11 Sep 2018 19:16:10 -0400 Received: by mail-qt0-f196.google.com with SMTP id g44-v6so29221547qtb.12 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=MZbUDFsZrb0Y8lVPRbhNcS4hbKE7qI+gnIttZnXxy9gyfeqlZpJs0y10KyjfjPrnvf Wezm4sJGN8XG0VHcyPq6KDbLVcqPkfG8rU6hV7xOVX2GkJcK/u+yrCkQTNVrl5BTEqfy uxwexZCL0oPQb/cgWv1XDDTSDzT/TZUtcP0FhVqcL2sYhbFsTfioTDASA8W3tqNBF9FZ Lyxz8+vQn0yoBrG7OPzlmX2Jf6eN2L3gZozAcWrQXL6sxuYoK3B+BvIZAdjCEyQAFGuO fB33pftmlX3/n6v4TCpg1YZyPM07R4j6NJXyUaNFjgdmYj13TPGeLTnII4la/v0COHvT 8P5w== X-Gm-Message-State: APzg51BFUrmA6DK/uyhRggpzIQKByMoESxGCVDzd5R/BNggzAYg0IbGD 0IdAb3AM8HX1R/A3G8deo8Auow== 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: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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;