From patchwork Sun Dec 29 17:17:32 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: 182549 Delivered-To: patch@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp5455710ild; Sun, 29 Dec 2019 09:40:52 -0800 (PST) X-Google-Smtp-Source: APXvYqyXjYIiqHxa3z92OQn9I8zg80R6ow793uPaoWvdEjjFHpvPcLacXHIXkd/4cLEywd0xdLDh X-Received: by 2002:a9d:3e16:: with SMTP id a22mr71742069otd.259.1577641252791; Sun, 29 Dec 2019 09:40:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577641252; cv=none; d=google.com; s=arc-20160816; b=ZaAGtRvcAcryCkECXEd6mCHv56J9aCc3sEoHG5S/w0ou/CShO8LULILY6JqdbKQl5k pNA+0IpCXngXGTHoiTEBSwbAgjU787YnpC+42uzugdLmLqwlu0urrEp1aUrp+5wixeU1 Go8VGf4lNzqb0fSU8YO0uNtOBuLPDHiWIFMZNatrLF3g6LK/T6wcBQwyf3n/B+h5/D+h wpzvXeCOLYOHp6Q8w4L4CLSKzk8BFwA8SX4tkakGBQCxmMucvboGfYLTgopTGZS4l4c9 5JnOV9ebk+AbcpmLwiz37ZKY/fYYsNG7x0X2IfYKlCuMiQ6AXF7WL3b4wUFxRBQE3r8/ jTgQ== 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=Jsg8SoAmaIXYOqxEJvroijf1A3fyQ999sEjvcfHFxJY=; b=v2/FpUQlLxpqdK8/wqIczJswSVexuZvyPr3jqLgtZc77Muuu0cO+rsCM7FJXdptvL3 c1NwxySQzo8LGTa/KD7n9J/QUs4aLKaqORpaDBkxV5tJyTNhw1R4zVgy9DX3Fp+MKopG S4YW9RIEMQ32si1L8+CT8s8yT+OP7VvpP448EO8TAkk9q+w9iU2f1S6JZMp44mFr3ySN 8tq5LMM4UhvUYprj5kdTJCstXGWq7JrJaf8YI0LXdy69dBWOPJ1quFAO7q7BZCsy+YMq EuRa6giYLvXIbKIajVwa1fhRe7sjlsdfQsfTb1NP3zTaxJGb/J26hxR9O3fAjoMMr0Zn 7hUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RdVlJjiB; 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 w29si24890447oth.313.2019.12.29.09.40.52; Sun, 29 Dec 2019 09:40:52 -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=RdVlJjiB; 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 S1729113AbfL2RbN (ORCPT + 27 others); Sun, 29 Dec 2019 12:31:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:57980 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729093AbfL2RbI (ORCPT ); Sun, 29 Dec 2019 12:31:08 -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 2F6E320722; Sun, 29 Dec 2019 17:31:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640667; bh=h4t23SUmlTtLdC4v+T1ti6aWL9NaAaQmUVYOp73w/Zo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RdVlJjiBhWtY3xWIiyUvUozm5fDT3Jg3G/y9rJwonUf+Hva6YNtOTQHCBw6TYP0tE JWAe9O98XaNIVg7jh/Cbe3fUQpZx3oYY/rO5KhQHqYermd11vUbrQwW6DF4DiP6CfT 1DpmnZ3OLW/px12OiGvTmTVsY4T0ZvMn+wYgUgEI= 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.19 050/219] selftests/bpf: Correct path to include msg + path Date: Sun, 29 Dec 2019 18:17:32 +0100 Message-Id: <20191229162514.999519096@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162508.458551679@linuxfoundation.org> References: <20191229162508.458551679@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 --- tools/testing/selftests/bpf/cgroup_helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 diff --git a/tools/testing/selftests/bpf/cgroup_helpers.c b/tools/testing/selftests/bpf/cgroup_helpers.c index cf16948aad4a..6af24f9a780d 100644 --- a/tools/testing/selftests/bpf/cgroup_helpers.c +++ b/tools/testing/selftests/bpf/cgroup_helpers.c @@ -44,7 +44,7 @@ */ int setup_cgroup_environment(void) { - char cgroup_workdir[PATH_MAX + 1]; + char cgroup_workdir[PATH_MAX - 24]; format_cgroup_path(cgroup_workdir, "");