From patchwork Sun Dec 29 17:22:29 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: 182576 Delivered-To: patch@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp5480085ild; Sun, 29 Dec 2019 10:09:59 -0800 (PST) X-Google-Smtp-Source: APXvYqzSfogwyODinsqYDUIWDFYMJqvmaaAHxHc8kZsKIIYXlhAYSPr6KBZAf2U7LdLxtI7WTMGT X-Received: by 2002:a9d:6b12:: with SMTP id g18mr67444965otp.211.1577642999293; Sun, 29 Dec 2019 10:09:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577642999; cv=none; d=google.com; s=arc-20160816; b=eiUArvfEmtLu/62OuQlLwpfivKaiJJFflSPJ0eKMQFMW9vBf2f69G1f1YehaXSP6JH FXR0CkFHnk8+mS5yZJjVfqdzBPdQkFj2Xt5kpEir0FFtcBjUhXZVxtt/IcROo4RKXx7+ W9TUGHnHS8bUFUAy7YFMCW/YMhrnaYifojnodt82Rv8cyeE7d2OhaU4jaUnkW2YKm4SL npLumY0v/yYdNJVmprLzjFEhWuEhuuRqoI4AhzJ2V7bvknfEyJ8aBbrwsZ9SEHMSGpNp iPvNolCbhNWbM/AOie5Fg2wbTN/6xbWi9pyo8ZIotdBzB9E7jLREsTnk4laMSydIX1ki ukqw== 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=4mhm375tKOHtAzZSCsWZ1NIzf3tFi4+kaNsf9kXkYoI=; b=s2HCMNLRAyh94vOX0hrNHgIpL0tIwG3gC/J0Oxix/9jeJV7d2+NkY+p97I3qcpEUM0 qWuisp8VRjXvowABfFy7C2c6aCC7myA8baDsyYLyGUao9SXGGNc0VUjd6hA2lLlP9c77 zxqhEvxVADXY6KsWh7vku+AH/m6soOsoSyen3ePmk87vDhwXmmuDutlj28Ez+r65VNmo n6oapohdbJvYBMJLwPmw2nj8D64YPXVZtjAoz/tXMrJ1mI3glsJjjwfr2zabRzujeeJN Zp+2RlKIKRIUODaXpmIKvupUko3TVXHGOR47noCdGBjCdkExRlDunudk3T7oqS6wvSzP WQQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MMeU9ghB; 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 z25si17635481oic.23.2019.12.29.10.09.59; Sun, 29 Dec 2019 10:09:59 -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=MMeU9ghB; 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 S1731827AbfL2SJ6 (ORCPT + 27 others); Sun, 29 Dec 2019 13:09:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:54136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730858AbfL2RpO (ORCPT ); Sun, 29 Dec 2019 12:45:14 -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 5C91D206DB; Sun, 29 Dec 2019 17:45:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577641513; bh=bFNiQNRUnwf7NbQH8R9FB9j32/jBKVRVxDZM5wXzECI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MMeU9ghB37hDMMzq+h2zIeCG2WO75taLM/6vZcJingPdEx0Y0PR+VZsmiEvMdMncl v4zj2iWd2Ilhxtz2MTqJwBYwBQdfDsYd3S9S161R7mH/GcXR0V27yheroYaPo0Dcc6 YftG9R14rf+LzI3FMtWao/1cYb6SCqPlRzlc7OZY= 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 5.4 096/434] selftests/bpf: Correct path to include msg + path Date: Sun, 29 Dec 2019 18:22:29 +0100 Message-Id: <20191229172707.955862688@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229172702.393141737@linuxfoundation.org> References: <20191229172702.393141737@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 e95c33e333a4..b29a73fe64db 100644 --- a/tools/testing/selftests/bpf/cgroup_helpers.c +++ b/tools/testing/selftests/bpf/cgroup_helpers.c @@ -98,7 +98,7 @@ int enable_all_controllers(char *cgroup_path) */ int setup_cgroup_environment(void) { - char cgroup_workdir[PATH_MAX + 1]; + char cgroup_workdir[PATH_MAX - 24]; format_cgroup_path(cgroup_workdir, "");