Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4411350imm; Tue, 11 Sep 2018 11:27:12 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYIuRUhGZv4hIL15wKeBQbsAt3y/7m0IMAzMGRwxYk1IVHC+NHdKWXWtrtwNRRc4Dz7QPNz X-Received: by 2002:a17:902:76c5:: with SMTP id j5-v6mr28740901plt.140.1536690432914; Tue, 11 Sep 2018 11:27:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536690432; cv=none; d=google.com; s=arc-20160816; b=FJHUM3kNVtUBcBFVqEvNdmoAxnAAxqIyOJ1X9ZNXuvjLyHy/uaYlPVG52+nwH8yl3u pe8gPmMYk4ABzmuxabc0DwDMw9OJFWUgoywxggnWP77hMARHLgkUOSRZ3HGdSSeri4uk 6cPE6YvCzejNRrDXBPbcfrVYse3y+Riscst1qDZ0Xb4jh1Zj55v7lHupPY1UW1vCVoK6 7tEQUGZ+E5OcoO8D/eVWUW9r2UM/MRuVAPgA2rHbopI9onXY1+D+fUO8aaRCFUBBPwnB nF2gLaF6yxpFyueVGofVwOC1H0Bk1m8DDU8AJX0Xvx5XHzay2olfpxVT2MQlAVL0vY80 1hBg== 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=zHa0CViV8KOs/JPKqRglgPRBbP0M3/iFC0Zd4K7jMEA=; b=f76SP3TLG6FFQUDvR31WZaEzA2qV58YuvWH1V90sMeh3SYisy69v4SoqYpFqOF/6NB Ac1OeO9NaPzccjkV2On2tMPc0kFJh5ZPtCVP+f157J3t4RNdldjQdyMUtN5ZM9zuVQ6u Y53+W5mldvUoGMiGZJQTOsT9kNa6NGHfaotAuOxHmydNX88XvhbxEJvKzvuxX/Ry+oVS 8L9KhDWR4dckzxq2GnMCCZcfnH9ofgo9LXu94zyPgk3zFqpE1xSudQklHsj88PpC5Rab hiVYeGEyypQSqQcnZOc+BEX3xU1lbEu/OqmDRLFI0S9KACJnHkGRe2EB0dUlDw5hIV8C HgwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CMN1xCkP; 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 o11-v6si23259349pgf.71.2018.09.11.11.26.57; Tue, 11 Sep 2018 11:27:12 -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=CMN1xCkP; 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 S1728297AbeIKXZo (ORCPT + 99 others); Tue, 11 Sep 2018 19:25:44 -0400 Received: from mail-yb1-f195.google.com ([209.85.219.195]:34658 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728046AbeIKXZo (ORCPT ); Tue, 11 Sep 2018 19:25:44 -0400 Received: by mail-yb1-f195.google.com with SMTP id t10-v6so9717501ybb.1 for ; Tue, 11 Sep 2018 11:25:12 -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=zHa0CViV8KOs/JPKqRglgPRBbP0M3/iFC0Zd4K7jMEA=; b=CMN1xCkPgWGy4apS+Ys4C6Ym3+JdSzV9heIWQ+0ocOGACrbYs//xDl2Y2FoPkhSKII +JY5nOVeJwByjkRfbr+v0c/7U21VpVwYbg0a+x/uM3zNAfV8FNCv2zN/FXgq3cKLPCqb 9C5VznyDtHKBNyy/WQRK4c2d2QWkwoNyJcK+s= 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=zHa0CViV8KOs/JPKqRglgPRBbP0M3/iFC0Zd4K7jMEA=; b=tLpgNFf5h6tLbbDPdQpiGPW1YJ8wNhgwwSJD/AVZrW7YnStM8goaigVPSd1N27WLqj NPDZgfFDSZeSe144ptTFPSlIUu2D+ClCU5D3/LjrGsHgMGPXvgeEe0UeSiEiqCWlCt/Z BA2+3dIlQ6Aa6SxK9qPfbFBR2UPv413xJXF6LGJdpQihry+y+ZVUwzRvoqYXVVGKVjqs jP70fFrHToKjljQdSnt6kxTU0xMwTVoLJj5WVgzHCaFYx898/B9WaSuVvR6AxW7LyJF+ KCugxxMxMzXY59StdZc/ulMtKILSrto5xKjHFChraS6/n3AFqGdYhuMP+w5clbKgL5jO odsw== X-Gm-Message-State: APzg51BWDn7+ZWaxpRz28vzv5bpaoa2I++tn9kK3Ad1sZMhg8j+/pS0h oZFgL8bP/hKb8EYAK/aw+sauTvQQRsc= X-Received: by 2002:a25:3585:: with SMTP id c127-v6mr13108449yba.194.1536690311775; Tue, 11 Sep 2018 11:25:11 -0700 (PDT) Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com. [209.85.219.174]) by smtp.gmail.com with ESMTPSA id m16-v6sm9208994ywd.32.2018.09.11.11.25.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Sep 2018 11:25:09 -0700 (PDT) Received: by mail-yb1-f174.google.com with SMTP id h22-v6so9693492ybg.12 for ; Tue, 11 Sep 2018 11:25:09 -0700 (PDT) X-Received: by 2002:a25:e5c3:: with SMTP id c186-v6mr13039192ybh.209.1536690308948; Tue, 11 Sep 2018 11:25:08 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:5f04:0:0:0:0:0 with HTTP; Tue, 11 Sep 2018 11:25:08 -0700 (PDT) In-Reply-To: <20180911181534.18553-1-labbott@redhat.com> References: <20180911181534.18553-1-labbott@redhat.com> From: Kees Cook Date: Tue, 11 Sep 2018 11:25:08 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] 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 11:15 AM, 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 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, Please use strscpy() in favor of strlcpy(). -Kees > sizeof(vscsi->dds.partition_name)); > vscsi->dds.partition_num = partition_number; > > -- > 2.17.1 > -- Kees Cook Pixel Security