Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1329662pxu; Thu, 17 Dec 2020 07:34:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwD+im+7ouMVhH9iY/DHKjE9E86ZZXQUKcS3r5PBBiC7KpiOlFzWpWjL6bJq4fH4O5adnUv X-Received: by 2002:a17:906:f85:: with SMTP id q5mr27167198ejj.105.1608219291370; Thu, 17 Dec 2020 07:34:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608219291; cv=none; d=google.com; s=arc-20160816; b=c6oNsckBFXvzl95zyx3YGPtZIaxpFt4bmMYoPCUobHungtWKvcgESf6zsWd1PBJSwn yBh32S0mEmL6mc1SG5veZ3bVjCZshdCyOJNXZTV7f8eRP/bXiOepI/VRtiYPbAohDrjp LW32GS4Y0mSsOG6shDvYj09CbXV7rWDR3JRX13m/TbCd/RZsXh1/8eNkOb9zr6qMsE6F X/QjVsTkOC6z80VcFlmP8YaTx7r0Eqw8kxhEM+EUOPgV4xdWmuGFkyhpyLlDSYAwep5A UZWZKB5/WfqlXsYf6oa+0j19AKdvjtMpdXpn+iqaQRuAWsfucHxK2Lb58GiDygwoigH/ uVZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=SNLzqNA7Yv8jUaImikGcte3pXfNXnVGyGGbxaqJSnmE=; b=QctxNfw1xPFKap+ZnRqKX9OYwDxjatRpbOa4FmR/vX9TA+3XYv/43JerQaZuB/ybbr 9QG+3Rf/q3bt3zXaR7UiNdebj4yvPs15frRXhbqCxKGj6c3um6NyNSuU0Zif67xz4rZa FeEh75VzkqaEvsZVDgI5/CI1GbZVyQV0655/T6J33+fFhg/E3ugP+lC4Waa84N89aceO 01prHgCXp+xueBAndvyoX1k0zPqv5BYHPQcaX469g+QrgogFqF+q/LqGoZuk8pFQeApT dEywyiqqLXWle9tqbcb92PdJF8gsUI2un9ObnFL0NgIfdqP05muNgEDDXqUKFYf7R9aA uNZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NstEXwcB; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b18si2827860eja.285.2020.12.17.07.34.27; Thu, 17 Dec 2020 07:34:51 -0800 (PST) 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=@chromium.org header.s=google header.b=NstEXwcB; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726291AbgLQPcA (ORCPT + 99 others); Thu, 17 Dec 2020 10:32:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726548AbgLQPb7 (ORCPT ); Thu, 17 Dec 2020 10:31:59 -0500 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81457C0617B0 for ; Thu, 17 Dec 2020 07:31:19 -0800 (PST) Received: by mail-io1-xd32.google.com with SMTP id r9so27884867ioo.7 for ; Thu, 17 Dec 2020 07:31:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SNLzqNA7Yv8jUaImikGcte3pXfNXnVGyGGbxaqJSnmE=; b=NstEXwcBZ58bsIqvPEou/vpNRiwQWHboP9Z0GcBCOZ8Zb8GlpgRMYIix6IgT+k1c7q /ZeFfGVxYFWgLX6Ra5z66ckoBCfcJRLVAijaEbs4WtQkm9kvUtr3hYUGj0cl7RMfjhaU xdRAHAGvTvaTGOVG0cHMEgHCEmVfY0ft1egwM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SNLzqNA7Yv8jUaImikGcte3pXfNXnVGyGGbxaqJSnmE=; b=oqzPi9UseHutSkaPWNFXBl9grrbVO9K35WF4QKhV3yijzR6PyriDu05ArDth1JPa8b DqZS5tlYFVPEHvQVXIMgtJdB6qmLQQnh76Gx7xjrydHcQ7MgSw7uykoppSBosMfyjAl9 pGX7b5pMmCiLvedqd0BB9jCk/N990QLKdYk/M5TQfRJLmTGv81DndEN+lIPjbn3LEmnc E/PO7GEYTUJw9iwwGBfKsA4AInLBU5mUrEVoSQXTf4K4jpKDo1ROtEQw42VUPto4sm1z y7I8FJvf5maYlplwXKFATPVPAdvzUmF+ui+DM1bFv1CzuGkMGT3sznWLKQrUsyc7IaLK /AIQ== X-Gm-Message-State: AOAM531padmBe4BJaDV1dwLTJmkgzDhX74Ryq4Xpyq/0epedOAeL/XE5 HOF0fjQyEvCEX9o6UhArafCq6eF8N8m1bdaJNJfr/w== X-Received: by 2002:a05:6602:387:: with SMTP id f7mr22817510iov.209.1608219078885; Thu, 17 Dec 2020 07:31:18 -0800 (PST) MIME-Version: 1.0 References: <20201126165748.1748417-1-revest@google.com> <50047415-cafe-abab-a6ba-e85bb6a9b651@fb.com> <194b5a6e6e30574a035a3e3baa98d7fde7f91f1c.camel@chromium.org> <221fb873-80fc-5407-965e-b075c964fa13@fb.com> In-Reply-To: <221fb873-80fc-5407-965e-b075c964fa13@fb.com> From: Florent Revest Date: Thu, 17 Dec 2020 16:31:08 +0100 Message-ID: Subject: Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper To: Yonghong Song Cc: Alexei Starovoitov , Andrii Nakryiko , KP Singh , bpf , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Florent Revest , open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 14, 2020 at 7:47 AM Yonghong Song wrote: > On 12/11/20 6:40 AM, Florent Revest wrote: > > On Wed, Dec 2, 2020 at 10:18 PM Alexei Starovoitov > > wrote: > >> I still think that adopting printk/vsnprintf for this instead of > >> reinventing the wheel > >> is more flexible and easier to maintain long term. > >> Almost the same layout can be done with vsnprintf > >> with exception of \0 char. > >> More meaningful names, etc. > >> See Documentation/core-api/printk-formats.rst > > > > I agree this would be nice. I finally got a bit of time to experiment > > with this and I noticed a few things: > > > > First of all, because helpers only have 5 arguments, if we use two for > > the output buffer and its size and two for the format string and its > > size, we are only left with one argument for a modifier. This is still > > enough for our usecase (where we'd only use "%ps" for example) but it > > does not strictly-speaking allow for the same layout that Andrii > > proposed. > > See helper bpf_seq_printf. It packs all arguments for format string and > puts them into an array. bpf_seq_printf will unpack them as it parsed > through the format string. So it should be doable to have more than > "%ps" in format string. This could be a nice trick, thank you for the suggestion Yonghong :) My understanding is that this would also require two extra args (one for the array of arguments and one for the size of this array) so it would still not fit the 5 arguments limit I described in my previous email. eg: this would not be possible: long bpf_snprintf(const char *out, u32 out_size, const char *fmt, u32 fmt_size, const void *data, u32 data_len) Would you then suggest that we also put the format string and its length in the first and second cells of this array and have something along the line of: long bpf_snprintf(const char *out, u32 out_size, const void *args, u32 args_len) ? This seems like a fairly opaque signature to me and harder to verify.