Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2759752imj; Mon, 11 Feb 2019 08:04:38 -0800 (PST) X-Google-Smtp-Source: AHgI3IbU3qkG6kZlivBZ6Kfx9ShfEK15lGJ8TqgNUB8tbbUkh5YyN20rE71IN5048sGtffmwnB1/ X-Received: by 2002:a63:c40a:: with SMTP id h10mr20550885pgd.131.1549901078150; Mon, 11 Feb 2019 08:04:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549901078; cv=none; d=google.com; s=arc-20160816; b=oSXtP93252fIZ4qVujpbHhSZvcdkkZQvfDGEP8B95dtgGs4TxO65OnqeBuOBldCBqL thAeOYxGOPZuZtWdP8Ivyz2gD5TOnJSloGgQSfAe2jDvlezzsAmFOVHlvrnbBU7e5phS AX6iGYfRA8ScqjDq1oQzvaVNPnCtHdMQKF5zoZFbkcyel101MyfY5/0Q4SE/CMgAvhk1 A01GoYVRk9FtnErV0a8dcdUuWeybjI8RH/LcYoDctaRiS7pumlBxhJsRpLct2kl0p/jp c1Bq7DJQMyseFoiFBWiPn4WPd0WwNGPdkEQAUGQaMAao4hGpiU6m7KEwFvrjoMRR+hmQ RToA== 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=s528t09E8MkqgD5miClHTwYrCAXyfNLQiL/Og3x59hk=; b=Lg20nJh9bDOhzNGrp4WMbweWhRPmARk2sTiiz03krY0VxsbCI+sIjpnqIWCh8huwsd TMYYQmsvAGEz39ZTZ6N0lo5XbkGE5tR7QtD/70Uu5UqqHrrB5gqMQ9TWKyjup+g3G2MG Rdu9QHrPRXJk0hoLrvi5NV3TM4gy5jbJNBnvQ30xv/juKt6X04eVJs6oYwn+FBe+D4js ZAgJIM7RvMebb+1eERXfOzCVMC2Ulu4yQAiAhBa4CEe40hVBvVrx4S3z20RWHpj8x8zE MqB12zaoLwvgh8a3FkoggEneefvvrfgto1oQI7mPeFiLCC+YEdrham7PzwLGfCuwzKxC mQUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qHjlhoyp; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q20si9694898pgl.268.2019.02.11.08.04.10; Mon, 11 Feb 2019 08:04:38 -0800 (PST) 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=qHjlhoyp; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730019AbfBKO3o (ORCPT + 99 others); Mon, 11 Feb 2019 09:29:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:35816 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730017AbfBKO3m (ORCPT ); Mon, 11 Feb 2019 09:29:42 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 62D2C20675; Mon, 11 Feb 2019 14:29:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895381; bh=YgYl8C4U7Mi0j6Dl9o1yps0br3RxPdmZWJah6lt6hYE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qHjlhoypb15Ou8+qTC+ovrsUFQu35R2rJAUCUiuY0neE/X1U2R0bQ97ATqcspPBuy IHZksKDzIbQNQRDj5slUileUmTz+R/a+aDLo6BWsbY2c5yVD07H8bIXsYcdLXvauI8 YJk9cWQ5pA+J8LH3RcFPI/srArxKhz2+zGgSjJIs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , Jiri Olsa , Namhyung Kim , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.20 187/352] perf dso: Fix unchecked usage of strncpy() Date: Mon, 11 Feb 2019 15:16:54 +0100 Message-Id: <20190211141859.022631166@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit fca5085c15255bbde203b7322c15f07ebb12f63e ] The strncpy() function may leave the destination string buffer unterminated, better use strlcpy() that we have a __weak fallback implementation for systems without it. This fixes this warning on an Alpine Linux Edge system with gcc 8.2: In function 'decompress_kmodule', inlined from 'dso__decompress_kmodule_fd' at util/dso.c:305:9: util/dso.c:298:3: error: 'strncpy' destination unchanged after copying no bytes [-Werror=stringop-truncation] strncpy(pathname, tmpbuf, len); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CC /tmp/build/perf/util/values.o CC /tmp/build/perf/util/debug.o cc1: all warnings being treated as errors Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Fixes: c9a8a6131fb6 ("perf tools: Move the temp file processing into decompress_kmodule") Link: https://lkml.kernel.org/n/tip-tl2hdxj64tt4k8btbi6a0ugw@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/dso.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index bbed90e5d9bb..cee717a3794f 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -295,7 +295,7 @@ static int decompress_kmodule(struct dso *dso, const char *name, unlink(tmpbuf); if (pathname && (fd >= 0)) - strncpy(pathname, tmpbuf, len); + strlcpy(pathname, tmpbuf, len); return fd; } -- 2.19.1