From patchwork Sun Dec 29 17:18:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 182535 Delivered-To: patch@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp5440880ild; Sun, 29 Dec 2019 09:22:55 -0800 (PST) X-Google-Smtp-Source: APXvYqzlLhBtyujbhyIBYFq1swX8EtP5VpDAbkVDn6JFMrRFg+FgxcnPsVM3fE5gatdBmh4Oqh+Y X-Received: by 2002:a05:6830:1ecf:: with SMTP id c15mr26599922otj.65.1577640175085; Sun, 29 Dec 2019 09:22:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577640175; cv=none; d=google.com; s=arc-20160816; b=rjWd4qAMziEdclIm00LTKKe13IrCIqp2ML0Vt1ZgpgDE7nhkEQZN6MIIKaJ/kJwo+C blaYSjmdwE8G3ac//9345y++Ny52J/qKgtKASbiawAnFaCwMUMzjSAB79ZcsiJqXZH8/ RawYyjGVsfEAKTdY+D9PZcqNT1a7OESfsSM4MQjANCiOihVs8DXcnPhujKrKUfVygQ6e //+mhwsGKjCOB88puMFlve9nPThhO3veyz7zF/MPTIfxhciNLJBgtMQA9tIUKFordlLd MDbgy5TJoyRghVeckjCSMaSlni4k8krS2I0+w2gf2AGQRp5eHGSKZjPjzFJOfyNkZr4n Ycmg== 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=svlolREnYgtRDtaBzvyr9Uz3A9hDfvINopZcnyLjRQ0=; b=mOgiFyaEnQw5k4lNEQI98QpQAuyc1Qd3UNoRxDFjcz7V27EKMqwj8WH8ndocMrI1uk P3trmO5g6wSPJJyif9+oo9hjkDRCj4s5eGWAUDIG0gZGClyqREzc0wAEbQcRJ2AojwX2 LwTlvj+x2ZZAMMkzJrypOYR2hbXQRLdZG5r8rLX80nehrhJIF4azROJMqHffQp6XBwJo Zbk5TVp197DScpHqBVPE3waySijPDNDrlmWQQMcIW5An5sKUut47xRTgdvuww3QEH3Sq XslOypDOU3v118qSEBK/pl34nNzyjPE9XMWkqfjcsew8wQfYQxmphp9pZwDUqiT8E8Xx YfXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Lnw4DO42; 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 44si22044263otu.77.2019.12.29.09.22.54; Sun, 29 Dec 2019 09:22:55 -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=Lnw4DO42; 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 S1727444AbfL2RWx (ORCPT + 27 others); Sun, 29 Dec 2019 12:22:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:39616 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727416AbfL2RWs (ORCPT ); Sun, 29 Dec 2019 12:22:48 -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 B4ED7207FD; Sun, 29 Dec 2019 17:22:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640168; bh=cGJoQaBLeDWQxSAkGHpykO2M28PK5xPPF5XrwpBF+GI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lnw4DO42JVya9yN+hiyk5AaFQQd47UZHS1GM0iJMGH37nolRpoL4SP4REm7bl9LhF XuPTCrMudCbvdYNgWHPmYiJiD2OlElzxLYZpX33c237jYDCWFuQgQ3uVyhBlSq8oFy NiH7Jrb5nqXUTIhoD7lROwRdtAImCSDnKWtg+teI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ivan Khoronzhuk , Daniel Borkmann , Song Liu , Sasha Levin Subject: [PATCH 4.14 039/161] selftests/bpf: Correct path to include msg + path Date: Sun, 29 Dec 2019 18:18:07 +0100 Message-Id: <20191229162411.621058361@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162355.500086350@linuxfoundation.org> References: <20191229162355.500086350@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ivan Khoronzhuk [ Upstream commit c588146378962786ddeec817f7736a53298a7b01 ] The "path" buf is supposed to contain path + printf msg up to 24 bytes. It will be cut anyway, but compiler generates truncation warns like: " samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c: In function ‘setup_cgroup_environment’: samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:52:34: warning: ‘/cgroup.controllers’ directive output may be truncated writing 19 bytes into a region of size between 1 and 4097 [-Wformat-truncation=] snprintf(path, sizeof(path), "%s/cgroup.controllers", cgroup_path); ^~~~~~~~~~~~~~~~~~~ samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:52:2: note: ‘snprintf’ output between 20 and 4116 bytes into a destination of size 4097 snprintf(path, sizeof(path), "%s/cgroup.controllers", cgroup_path); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:72:34: warning: ‘/cgroup.subtree_control’ directive output may be truncated writing 23 bytes into a region of size between 1 and 4097 [-Wformat-truncation=] snprintf(path, sizeof(path), "%s/cgroup.subtree_control", ^~~~~~~~~~~~~~~~~~~~~~~ cgroup_path); samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:72:2: note: ‘snprintf’ output between 24 and 4120 bytes into a destination of size 4097 snprintf(path, sizeof(path), "%s/cgroup.subtree_control", cgroup_path); " In order to avoid warns, lets decrease buf size for cgroup workdir on 24 bytes with assumption to include also "/cgroup.subtree_control" to the address. The cut will never happen anyway. Signed-off-by: Ivan Khoronzhuk Signed-off-by: Daniel Borkmann Acked-by: Song Liu Link: https://lore.kernel.org/bpf/20191002120404.26962-3-ivan.khoronzhuk@linaro.org Signed-off-by: Sasha Levin --- samples/bpf/cgroup_helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 diff --git a/samples/bpf/cgroup_helpers.c b/samples/bpf/cgroup_helpers.c index 09afaddfc9ba..b5c09cd6c7bd 100644 --- a/samples/bpf/cgroup_helpers.c +++ b/samples/bpf/cgroup_helpers.c @@ -43,7 +43,7 @@ */ int setup_cgroup_environment(void) { - char cgroup_workdir[PATH_MAX + 1]; + char cgroup_workdir[PATH_MAX - 24]; format_cgroup_path(cgroup_workdir, "");