Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3730533imm; Mon, 8 Oct 2018 08:37:59 -0700 (PDT) X-Google-Smtp-Source: ACcGV62C+T9NVKlDlXSMpam6F5VWkIX9H4YC8Zs1rlusGDY5hZCjUW0cVEmiittcPhab73C+MYBT X-Received: by 2002:a63:d84a:: with SMTP id k10-v6mr21901816pgj.314.1539013079012; Mon, 08 Oct 2018 08:37:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539013078; cv=none; d=google.com; s=arc-20160816; b=TFCAmiYOh5dpyR/DRlqbifMhQRpR6K/e1u/2Wyd7KtrAfN5CgeICSpke3q4VM9D+ot A6NycZMOZNm0jIMFieQa8H+/wRTwaa0l/w+eOvT+lD0P78Q2atVlRKmJi6b2PSts6nZV zNwvnqH9a+EJQdqLj3UGY7RaHpnQMTGpGyO1cF0fMk4BQy4j7otK10+ZGsMP4hWgpWCA 0j0l3Qt3vndl6SvDsInvhPaGXsksx2lqLnI6DyWKpb2mPrmo82Rb875m/WiLp5kdWOf6 DP+KaKQNrDYlFF6UOtik0DTbQFRTJqDPTNEkUGvZectWJg2r+Ih2MToIxdTJ00rTLsEg wOZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=9pJkAWaIcOMwMYvUmRWacusI9x8141bih9RTkukAydw=; b=dfyNnVoC0yQkhBpZjtff1NVol5E/3MPJZYJsp9hngYKz4wi4rZN1awGcCpdm06gz0o aATqtrqsnn5veKD6TNiLwYJGLtF3scujHIq0h4X0f5TwlEGBzJ2TzqzVPi76WskCKOic NniwqI8yhluHTxj6TQ9icZ+M3MKVhnHcAb6aqK5N5+fD/47LMPBgF8t3hxttsNBdYmLp EI6L8Bg4QWy5r+ChPBGKfpWKCOBn28f+rmFtGcxaJ5DehVz0XoAarcM+8ycinYBGzpTD Hrx+lv9e/CvVZsMFS7gNHW3ItlxSX+H1Q8RS0f7kBagSH1p+7FO5/51w0QWYHPoLHlEN hBBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZX4X16kV; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gn22si17405679plb.139.2018.10.08.08.37.44; Mon, 08 Oct 2018 08:37:58 -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=@kernel.org header.s=default header.b=ZX4X16kV; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727245AbeJHWiB (ORCPT + 99 others); Mon, 8 Oct 2018 18:38:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:56158 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727180AbeJHWiA (ORCPT ); Mon, 8 Oct 2018 18:38:00 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9F2B4214FF; Mon, 8 Oct 2018 15:25:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539012345; bh=10gqXAJoPWk59g7kC2enWNS8xpHeMoIc7qZq32GCm/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZX4X16kVCvbDd48n+bTx4dFUhMuoBdm83+Wc2T6w5PxFKHxC5/laKLCFgVabW0zRY Ov7UTwJHMHCljN5O4+vuGDA2VR8IvgLjk6Crfbd0yM+aRZIQobpXpgBDL3rqLwoOJW LXjpEmmW1SHhDM/fmy38TElaUNzz1TiNOLe+fgR8= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Laura Abbott , "Martin K . Petersen" , Sasha Levin Subject: [PATCH AUTOSEL 4.18 19/58] scsi: ibmvscsis: Fix a stringop-overflow warning Date: Mon, 8 Oct 2018 11:24:44 -0400 Message-Id: <20181008152523.70705-19-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181008152523.70705-1-sashal@kernel.org> References: <20181008152523.70705-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Laura Abbott [ Upstream commit d792d4c4fc866ae224b0b0ca2aabd87d23b4d6cc ] 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 a single snprintf instead of a strcpy + strcat to handle this cleanly. Signed-off-by: Laura Abbott Suggested-by: Kees Cook Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c index c3a76af9f5fa..95bf381413e8 100644 --- a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +++ b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c @@ -3475,8 +3475,7 @@ static int ibmvscsis_probe(struct vio_dev *vdev, vscsi->dds.window[LOCAL].liobn, vscsi->dds.window[REMOTE].liobn); - strcpy(vscsi->eye, "VSCSI "); - strncat(vscsi->eye, vdev->name, MAX_EYE); + snprintf(vscsi->eye, sizeof(vscsi->eye), "VSCSI %s", vdev->name); vscsi->dds.unit_id = vdev->unit_address; strncpy(vscsi->dds.partition_name, partition_name, -- 2.17.1