From patchwork Tue Nov 19 05:16:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 179643 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp154298ilf; Mon, 18 Nov 2019 21:32:53 -0800 (PST) X-Google-Smtp-Source: APXvYqzABSK2KiJtaRiBAzvQFq+BU7tGnTSor4Cf7Na6+BQePBAn9PoWdy5eDuUrz98l6jhgtUtx X-Received: by 2002:a17:906:7e41:: with SMTP id z1mr31912830ejr.63.1574141573647; Mon, 18 Nov 2019 21:32:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574141573; cv=none; d=google.com; s=arc-20160816; b=DgBbcHmHEYDgso34j1PG9qfRYYXVcO5k3iYjEftu1FVPybV1+uJsHuCEegpr6JN/vi xKadzOFKIdtMS/HiOVWXxU/aL6/5Pim4gkSToslO9vDyjns82mMXSYearGtCeSs7/Nwt QXLkednfVmNwbC3AcP0QMyjAem3FKyyTAHoJXNfLqSX6nShRoYzXOwQwaJRAp0nUAB/r J8ougUwALZLQx/xHhglqFtjuK5QEjwKNeTfoxXV6Y/nLCBfhXKS0rKbfnCznjaJGEYgr e/qyemSnymhIbE/RM7ajVJCyozjpzkh8RtXpB1xtjWfUY6VyfQeXkYnH5QK/Cpbqcy0Q 37pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4SfYdpMAZA5tF67MBl8gD3vnW3UrMxqN6p0evxCoDm8=; b=OpzdGP9wiGqpRuC8iaNDZQAAn/uxZEGBipirOcUuYI0SESVlfSNvMvRodjqBwIBUrK jg7Kx8WBSV9nSCn7PLDEtgKaeCWu6Sx9YpNGj/6nPSJ//4NTlvJ1AXbVFR5hnIbGLuR9 8NeuKBIpvwol8yPyi3MOC/X6UJcULOfXmyLM+OFfjENvpt8XYreYnobmy7TLEAJ8sPYm bOScl7jsJL9naCudH34tWFPaXpe40QW2XAb/H6eEwadqBpkBrTtceCB7kp440LSahXaR 0SPLmiGvjG5G8IiOjGsLeiW3LQg6D2rtiNS2A53D7B6tiyhVdwp0PF4iKCZZdt2LiA3+ KThg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MpkXx4AG; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p7si13104325edq.227.2019.11.18.21.32.53; Mon, 18 Nov 2019 21:32:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=MpkXx4AG; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729458AbfKSFcw (ORCPT + 15 others); Tue, 19 Nov 2019 00:32:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:53262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729456AbfKSFcw (ORCPT ); Tue, 19 Nov 2019 00:32:52 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 05F8D21783; Tue, 19 Nov 2019 05:32:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574141571; bh=fTe/6jv6vp2P2ZrGxFtNky6NeEAfIueFoy7sJP/UR2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MpkXx4AG63W3WHap3Q+BEeQT71MEoljTR5P8b6FgTE3+QtUQEFg+1EkOdYpDOeVe5 UVyyVA4yOnyDaBM5iEZ4V4bMe/Z3mof55ng+p94AILNXJorLMrQgrVGZL+jRpN8mrp mIJQnt47cfm/jhmiEBxHt+s5ExS98pUSyC/GT3vo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Niklas Cassel , Bjorn Andersson , Andy Gross , Sasha Levin Subject: [PATCH 4.19 206/422] soc: qcom: wcnss_ctrl: Avoid string overflow Date: Tue, 19 Nov 2019 06:16:43 +0100 Message-Id: <20191119051411.937179384@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191119051400.261610025@linuxfoundation.org> References: <20191119051400.261610025@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Niklas Cassel [ Upstream commit 4c96ed170d658d8826d94edec8ac93ee777981a2 ] 'chinfo.name' is used as a NUL-terminated string, but using strncpy() with the length equal to the buffer size may result in lack of the termination: drivers//soc/qcom/wcnss_ctrl.c: In function 'qcom_wcnss_open_channel': drivers//soc/qcom/wcnss_ctrl.c:284:2: warning: 'strncpy' specified bound 32 equals destination size [-Wstringop-truncation] strncpy(chinfo.name, name, sizeof(chinfo.name)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This changes it to use the safer strscpy() instead. Signed-off-by: Niklas Cassel Reviewed-by: Bjorn Andersson Signed-off-by: Andy Gross Signed-off-by: Sasha Levin --- drivers/soc/qcom/wcnss_ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 diff --git a/drivers/soc/qcom/wcnss_ctrl.c b/drivers/soc/qcom/wcnss_ctrl.c index df3ccb30bc2dd..373400dd816d6 100644 --- a/drivers/soc/qcom/wcnss_ctrl.c +++ b/drivers/soc/qcom/wcnss_ctrl.c @@ -281,7 +281,7 @@ struct rpmsg_endpoint *qcom_wcnss_open_channel(void *wcnss, const char *name, rp struct rpmsg_channel_info chinfo; struct wcnss_ctrl *_wcnss = wcnss; - strncpy(chinfo.name, name, sizeof(chinfo.name)); + strscpy(chinfo.name, name, sizeof(chinfo.name)); chinfo.src = RPMSG_ADDR_ANY; chinfo.dst = RPMSG_ADDR_ANY;