Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4144895imm; Tue, 11 Sep 2018 07:37:40 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb1bkHhLi1EGJXqjxCE3kq0te8lZ+Wd4ko0MmkQWcWp4zOyw49Qc5u8GhJU+MhBPW/XoUAL X-Received: by 2002:a17:902:22:: with SMTP id 31-v6mr27452444pla.190.1536676660770; Tue, 11 Sep 2018 07:37:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536676660; cv=none; d=google.com; s=arc-20160816; b=ndi9nAIUeL/lsH3G7smJQSNMZk+GqrjgNqQE7awtIR/qXCRQdOjCYdOAHsD9tLgoOh iUPZn4lPcVcan6rbqlL0zzKwSNkvnHZfPgNauavntSNTY/+w4pqRjSVOck+ZsGMqkKoi p8YVGTOFOci/TW7c/LcSWkGRYoNuZWpQvh8oIBHagtexiC+m2gBabGmXMSRqJ53Z/bCa KP8UoKLTcgbpw1vh5qqIRCUOXQ/bidBGI0GpxjQ72AowRNYO6A8hGjshnsgRbk0U0ZNz tsx57ppYPo36F4gHYLyNSWrfQq/aYkQLGSQ6OUU1UdYhi1Y/BPH+ZkFUIUyvTPRA/kGk +ZfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :from:references:cc:to:subject; bh=zHtaOx8Zjk/FxWDnrG33rCtUKpMIpDxsgcPh6ntYcPc=; b=NNkpAocVA9KE72COIPTz4BAYwFxS7QjWJluAsO5ahhVgQxvHGH1aNTZpmtOff/tKkf 3lcVq8THUf8W4nfWjuCsQ5k/D6qK+K/WMYhMu4YBvy231VQ9wwOqqmumn+JM4Nj3ixoH ab42iyhCy5bNzOE8ggaWQTsljiCYmxm9OSYoOUHQd1AKhyWHGAIF2u/CH0CMakhnHYfe yL4V+EsX8Po5aoevb8YO745ahxPVTBCfZOKDqLMQQlNpXcBflxMBqvZXGz0LBjQMy7pG +B3E16ZxVc/m6X8YyuiVaU11EL6QFZzM9aiF7XAR7Ay+N2zo16afMhFEnJDH8CrhO2FE 6rOQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w3-v6si9317717pll.449.2018.09.11.07.37.20; Tue, 11 Sep 2018 07:37:40 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727999AbeIKTen (ORCPT + 99 others); Tue, 11 Sep 2018 15:34:43 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:31965 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726761AbeIKTen (ORCPT ); Tue, 11 Sep 2018 15:34:43 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8BETcwx178249 for ; Tue, 11 Sep 2018 10:35:05 -0400 Received: from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203]) by mx0b-001b2d01.pphosted.com with ESMTP id 2medw55akg-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 11 Sep 2018 10:35:04 -0400 Received: from localhost by e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 11 Sep 2018 10:35:02 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e13.ny.us.ibm.com (146.89.104.200) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 11 Sep 2018 10:34:59 -0400 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w8BEYwqk33161432 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 11 Sep 2018 14:34:58 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8B624112062; Tue, 11 Sep 2018 10:34:28 -0400 (EDT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 25423112061; Tue, 11 Sep 2018 10:34:28 -0400 (EDT) Received: from bryants-mbp-4.rchland.ibm.com (unknown [9.10.79.137]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 11 Sep 2018 10:34:28 -0400 (EDT) Subject: Re: [PATCH] scsi: ibmvscsis: Fix a stringop-overflow warning To: Kees Cook , Laura Abbott Cc: "Bryant G. Ly" , Michael Cyr , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, target-devel , LKML , Prarit Bhargava References: <20180910223723.25357-1-labbott@redhat.com> From: "Bryant G. Ly" Date: Tue, 11 Sep 2018 09:34:57 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 18091114-0064-0000-0000-0000034B3C28 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009703; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01086789; UDB=6.00561139; IPR=6.00866800; MB=3.00023231; MTD=3.00000008; XFM=3.00000015; UTC=2018-09-11 14:35:01 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18091114-0065-0000-0000-00003A9B2431 Message-Id: <36c9adee-fbe8-f58d-e407-bbd57fdb1959@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-09-11_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809110148 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/10/18 6:30 PM, Kees Cook wrote: > On Mon, Sep 10, 2018 at 3:37 PM, Laura Abbott wrote: >> There's currently a warning about string overflow with strncat: >> >> drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c: In function 'ibmvscsis_probe': >> drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:3479:2: error: 'strncat' specified >> bound 64 equals destination size [-Werror=stringop-overflow=] >> strncat(vscsi->eye, vdev->name, MAX_EYE); >> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> >> Switch to using strlcat which correctly accounts for lengths that >> are equal to the destination buffer. >> >> Signed-off-by: Laura Abbott >> --- >> 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 fac377320158..53d344d8dc43 100644 >> --- a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c >> +++ b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c >> @@ -3475,7 +3475,7 @@ static int ibmvscsis_probe(struct vio_dev *vdev, >> vscsi->dds.window[REMOTE].liobn); >> >> strcpy(vscsi->eye, "VSCSI "); >> - strncat(vscsi->eye, vdev->name, MAX_EYE); >> + strlcat(vscsi->eye, vdev->name, MAX_EYE); > Can this just get switched to snprintf() instead? > > snprintf(vscsi->eye, sizeof(vscsi->eye), "VSCSI%s", vdev->name); Either works for me. > >> vscsi->dds.unit_id = vdev->unit_address; >> strncpy(vscsi->dds.partition_name, partition_name, > And does this strncpy need a NUL-termination and/or trailing padding? > Yes, good catch, it does need NUL-termination. -Bryant