Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4630688pxj; Wed, 12 May 2021 09:37:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsIjgTWNO3LJ8Tpz7jhIsyX5cvo2WUzL5H0T7vhGfij+gSusSmnTgmxkeFSL1GZ/mBxq0R X-Received: by 2002:a9d:4e96:: with SMTP id v22mr13812142otk.134.1620837427887; Wed, 12 May 2021 09:37:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620837427; cv=none; d=google.com; s=arc-20160816; b=XtFXPnpA1PnFj7QbRjdKJg3NH/PqOXEGUNklvmz99yPgsRoNJAiLSj18FF3w1urTls Bku6skpVP7mb/lQqGuR3S24kNjRX5Cnz1qxqGznXtADDp/aO6UQ4qsy7CesBOoLnkjUf CjTkH4JcTO/MLuVTmw+RGcCA3hGDS1bWZaN95U0FjsMJJNmLPF9eUu+Rp3umqFDKoVcb 5rq9bODpAOO+TtqqASeqIDzyAgJPkoIitbc0OVX058eY2mzgtX9HGdzD3ff9cHB2L2uu FgtZ0D0K46mBrxHIeCvsJpMiF5mw2GFSBWsa/ichIWVe9gNnc286cjLTdHVvaXBAYYe3 pIeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nwcAi0IP19a8R0Ee6LhnHPjvSbpNZzSiceDADx9xR3g=; b=AHLs/1c6UmoAoW7gpwt2uYjrIi0RAjqNvVOH4FhJbBZ50KkhANjZv6pLNOPyP1XxLP 6TCDAqK216oTnpj/VxzbZJvJkmv1FAOadKXo7p9EoMd9BNvGTx1FKAVVNSUA+JLG2yjK 7eFO+KeFlde4ePg6ba+pkjgKomoqagFxPCJiZGCyhXtSpEovVsDFsAPjlinVLNViTV7q O29JCxzyWYqUKhKUIPmVwg9Sz1o4OJAwpc4RPL00O0qxzMMEve2yKUzTh/Vcsk1vjP0I mL93BfIvivlPmPQmTC8J7f0zv71i3sRN4EbetRrtkpQSPWmhMPDDoVAwOME/oyH9LNQa 9xTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MNwBMSIp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b128si531605oif.208.2021.05.12.09.36.53; Wed, 12 May 2021 09:37:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MNwBMSIp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242676AbhELQf1 (ORCPT + 99 others); Wed, 12 May 2021 12:35:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:56688 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234235AbhELPl0 (ORCPT ); Wed, 12 May 2021 11:41:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0B0B6619A5; Wed, 12 May 2021 15:21:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832897; bh=r7rS+19kqxRSOlQSTefVR0fY2SMfJkNMnf+0aGork74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MNwBMSIpov174NGzjMryFwM+y2IYmUOVSATAg6LrQ2yqhyBluXRtC4H3HG7i0Fo6O vkY2CYUBC4ELP98Lr3ytLigknkJkcvi6/1VqRrIgWFGaSfGYF6iO3Pt5w5bIC1+Y2d 1kSqYrdOp7aEx1NXLw/3I6ph0/VwO+z0U1EeC6Qo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florent Revest , Alexei Starovoitov , Andrii Nakryiko , Sasha Levin Subject: [PATCH 5.10 467/530] libbpf: Initialize the bpf_seq_printf parameters array field by field Date: Wed, 12 May 2021 16:49:37 +0200 Message-Id: <20210512144835.114156372@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Florent Revest [ Upstream commit 83cd92b46484aa8f64cdc0bff8ac6940d1f78519 ] When initializing the __param array with a one liner, if all args are const, the initial array value will be placed in the rodata section but because libbpf does not support relocation in the rodata section, any pointer in this array will stay NULL. Fixes: c09add2fbc5a ("tools/libbpf: Add bpf_iter support") Signed-off-by: Florent Revest Signed-off-by: Alexei Starovoitov Acked-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20210419155243.1632274-5-revest@chromium.org Signed-off-by: Sasha Levin --- tools/lib/bpf/bpf_tracing.h | 40 +++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h index f9ef37707888..1c2e91ee041d 100644 --- a/tools/lib/bpf/bpf_tracing.h +++ b/tools/lib/bpf/bpf_tracing.h @@ -413,20 +413,38 @@ typeof(name(0)) name(struct pt_regs *ctx) \ } \ static __always_inline typeof(name(0)) ____##name(struct pt_regs *ctx, ##args) +#define ___bpf_fill0(arr, p, x) do {} while (0) +#define ___bpf_fill1(arr, p, x) arr[p] = x +#define ___bpf_fill2(arr, p, x, args...) arr[p] = x; ___bpf_fill1(arr, p + 1, args) +#define ___bpf_fill3(arr, p, x, args...) arr[p] = x; ___bpf_fill2(arr, p + 1, args) +#define ___bpf_fill4(arr, p, x, args...) arr[p] = x; ___bpf_fill3(arr, p + 1, args) +#define ___bpf_fill5(arr, p, x, args...) arr[p] = x; ___bpf_fill4(arr, p + 1, args) +#define ___bpf_fill6(arr, p, x, args...) arr[p] = x; ___bpf_fill5(arr, p + 1, args) +#define ___bpf_fill7(arr, p, x, args...) arr[p] = x; ___bpf_fill6(arr, p + 1, args) +#define ___bpf_fill8(arr, p, x, args...) arr[p] = x; ___bpf_fill7(arr, p + 1, args) +#define ___bpf_fill9(arr, p, x, args...) arr[p] = x; ___bpf_fill8(arr, p + 1, args) +#define ___bpf_fill10(arr, p, x, args...) arr[p] = x; ___bpf_fill9(arr, p + 1, args) +#define ___bpf_fill11(arr, p, x, args...) arr[p] = x; ___bpf_fill10(arr, p + 1, args) +#define ___bpf_fill12(arr, p, x, args...) arr[p] = x; ___bpf_fill11(arr, p + 1, args) +#define ___bpf_fill(arr, args...) \ + ___bpf_apply(___bpf_fill, ___bpf_narg(args))(arr, 0, args) + /* * BPF_SEQ_PRINTF to wrap bpf_seq_printf to-be-printed values * in a structure. */ -#define BPF_SEQ_PRINTF(seq, fmt, args...) \ - ({ \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wint-conversion\"") \ - static const char ___fmt[] = fmt; \ - unsigned long long ___param[] = { args }; \ - _Pragma("GCC diagnostic pop") \ - int ___ret = bpf_seq_printf(seq, ___fmt, sizeof(___fmt), \ - ___param, sizeof(___param)); \ - ___ret; \ - }) +#define BPF_SEQ_PRINTF(seq, fmt, args...) \ +({ \ + static const char ___fmt[] = fmt; \ + unsigned long long ___param[___bpf_narg(args)]; \ + \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wint-conversion\"") \ + ___bpf_fill(___param, args); \ + _Pragma("GCC diagnostic pop") \ + \ + bpf_seq_printf(seq, ___fmt, sizeof(___fmt), \ + ___param, sizeof(___param)); \ +}) #endif -- 2.30.2