Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4481034imm; Tue, 11 Sep 2018 12:35:10 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ8LfhaNKoTyJS5L87dMmIK2SzRhHkF8+PLBVcAkdOngLEajC5kMz6T7eBE1XI1U5YiUHlM X-Received: by 2002:a17:902:2e83:: with SMTP id r3-v6mr28876776plb.80.1536694510500; Tue, 11 Sep 2018 12:35:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536694510; cv=none; d=google.com; s=arc-20160816; b=LH69D+pqDCWpDJKxYALqyBZQ3tBxUs75h/cGj0YSyfnxmLDyI9IZ6wnD6YMJ3fXAP3 uKSWZpueO6EWEeyjaKPrbmCHWVCO/w5VFRp5XyZ5wLBoWawP5kzssDfarQ+JVgL2trl9 vP78bya5ZnGNGSpIk7lizUrFwy4ZP2Imy3g5gLTTs4Yxja+yF/LKrqQRxa2EpTyse52i bAl+uY9Lp7kmG3i9YYPKbJ8Fr5Q21dzdGl55Xllr1lNftNX0xwX9oKN9sT43xpY92A0g ckcR2LfybY/6fdPAjPNdAiZOwXe6Ba5+u9V8gNeEcci4SeiBpovyHo99L46+/X3LnZiT jSXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=syNwMSHRGJ6VqGWZ3VZd14w7801JFjU1YHYZQIEq/yk=; b=cUJELfhUH9YaeM+qJWlrMgdKJaBHZmZWBX2SPmZcKbRWoY6LGEIHYJegZFYibnce+X 2jD7PbI08kPvPfk8/ZQ9iJbDefCmHmnGM4mpLfnZHFQWlx8hoErsrmjSmpbM3YikXKoi V+LamV5+juiIBl/waB5H0veXv/Dp1zm+rfesch/APe/zItqBtJFlL1MAcDwtUUBO8eSC VHmfQrOEh9xXmpbKAccjZK+I6EfdZO9XjFDrjgTrH129RRunnJ6YrnHJ4oIFvR1M6r6d fKOXsz5JUSWpSCW7TWyJjPwiXVjLsenoB27WiG9S7/Plx57QN+TN830J8hq5CdgMkNxO x17g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=RNOifkup; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 15-v6si22382961pld.157.2018.09.11.12.34.54; Tue, 11 Sep 2018 12:35:10 -0700 (PDT) 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; dkim=pass header.i=@chromium.org header.s=google header.b=RNOifkup; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728127AbeILAeC (ORCPT + 99 others); Tue, 11 Sep 2018 20:34:02 -0400 Received: from mail-yw1-f67.google.com ([209.85.161.67]:39867 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726810AbeILAeC (ORCPT ); Tue, 11 Sep 2018 20:34:02 -0400 Received: by mail-yw1-f67.google.com with SMTP id m62-v6so9680134ywd.6 for ; Tue, 11 Sep 2018 12:33:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=syNwMSHRGJ6VqGWZ3VZd14w7801JFjU1YHYZQIEq/yk=; b=RNOifkupAAPnG+1bw7bC5lqLXlW4BrDOR9rgI6aip24Jp3Js4QA7xn2N9QWtJv5sF7 b7SC74ogLUjqknuJFfH+1w7BZGh146JvVQCiTrWKSr0nAvpnnuEzaHS0DBmmYjhcGKFG DzrM6i+Aock58y+mVKUDjzulVeaJc4NBrbYI8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=syNwMSHRGJ6VqGWZ3VZd14w7801JFjU1YHYZQIEq/yk=; b=JrhnqSw7jn+Jn1J+Jvgi+RLmXOMV8WESFQ288DebX2SEnlvu3io8WAw4dVUsjrxXBT 5IPYFz++13FWKg5GmN8ed7XiXx31SR2776fZrhHbxAGpUrT0oT1zQghPvx2C+Zlvvyah 7gjXVDDslXEYUSFU7UdQep5Q0/DNK7zNgwpFrk/kggXS9nlhpknfUASR7A3beCrOTVV0 x07b/QZcuLqsBj6B6svubLKrKOS35cHhHobKiOLeg/tAAEJEhwINiZcovJ/LDEuockPV BrdVDiK0GICZRwVvAPlzpwGJIoNLM2BUVShw18ZPAOtBOMhk7a8W2JVl4X6X9A5pSxrk DiFw== X-Gm-Message-State: APzg51BUGoQilKRgkgG2ddWsGrisO0bFP1bh1UlMeZ03Axg4c6tqwvGF 3M8W0X5B4X5cdQy3ytEx10KfhCJssgQ= X-Received: by 2002:a81:d40c:: with SMTP id z12-v6mr13439824ywi.388.1536694395166; Tue, 11 Sep 2018 12:33:15 -0700 (PDT) Received: from mail-yw1-f41.google.com (mail-yw1-f41.google.com. [209.85.161.41]) by smtp.gmail.com with ESMTPSA id m82-v6sm8379538ywc.29.2018.09.11.12.33.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Sep 2018 12:33:13 -0700 (PDT) Received: by mail-yw1-f41.google.com with SMTP id j131-v6so9658515ywc.13 for ; Tue, 11 Sep 2018 12:33:13 -0700 (PDT) X-Received: by 2002:a0d:db10:: with SMTP id d16-v6mr13866974ywe.124.1536694393155; Tue, 11 Sep 2018 12:33:13 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:5f04:0:0:0:0:0 with HTTP; Tue, 11 Sep 2018 12:33:12 -0700 (PDT) In-Reply-To: <20180911192226.3620-3-labbott@redhat.com> References: <20180911192226.3620-1-labbott@redhat.com> <20180911192226.3620-3-labbott@redhat.com> From: Kees Cook Date: Tue, 11 Sep 2018 12:33:12 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCHv2 2/2] scsi: ibmvscsis: Ensure partition name is properly NUL terminated To: Laura Abbott Cc: "Bryant G. Ly" , Michael Cyr , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, target-devel , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 11, 2018 at 12:22 PM, Laura Abbott wrote: > > 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 strscpy which does this safely. > > Reported-by: Kees Cook > Signed-off-by: Laura Abbott Reviewed-by: Kees Cook -Kees > --- > v2: Switch to strscpy instead of just strlcpy > --- > 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 b3a029ad07cd..f42a619198c4 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, > + strscpy(vscsi->dds.partition_name, partition_name, > sizeof(vscsi->dds.partition_name)); > vscsi->dds.partition_num = partition_number; > > -- > 2.17.1 > -- Kees Cook Pixel Security