Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1147392yba; Fri, 3 May 2019 17:23:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqyv+dQcNGUKEHFrIL0lATZUOpClRPNZ+dNdxNa36qTqAX8LYqpFppByttvbh6sEBKG7vgQQ X-Received: by 2002:a63:541d:: with SMTP id i29mr14282705pgb.174.1556929437917; Fri, 03 May 2019 17:23:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556929437; cv=none; d=google.com; s=arc-20160816; b=Cy78BLORByj7tizE4bjsHH9AjuDAQYYclJ6nM2jWZPwRd5hIGUuLTGZ8cLjNAI4RS8 KFiykAaaPGeZLnF26G1rqGA5bV44OoO7NqBUJtWc3FDYUAYAe432Yj5lTxRntq2DZDg2 CYcB/SFe8Y2zVsngomWgc5c9Zasffd50Ai6UpvtJbgmEhHmxWiMAQQ8pBmNKBrsd6JIA a6Fmo2JXNB4oUVCYSXi8A5qsHsl09G/qeBdciH4sC19NezFIqMCYQS10EphW6VINPkH/ DvvsjxcmAfJTQ3JdzNbSJEJTdPSy7Jo1AOgHDn0FRZGFRa1lFRO+ymqUozlcOP7T5F3h VeUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature:dkim-filter; bh=P85xUkVWJ0dVHjIoSMC9P7JcDgYlOOM9rXQ6Qi0p0vg=; b=S7ERxrpa7Mzu8zjKm9OjA9mKUgBsVB0c19aFX7fIqpjDyG9m5YCf3uA9oHwH8pdy5x KOPfphwPNeAe4ZOrLCjTXE6ajuMrxKiDWgBbB0TnhRCMt5IEeDM83Feag2n9RiSLXVHY uxJklGxVBPe8hqZefH3svpFb3XYE/KZ12pqj4dlPZoHjJIkrK9DoFAU07yaBbpliUuB9 T3DjJyuLNHBoHS8Qm1YpljHWXu2recCU9ImUdOIwmj5S6Wt4HHhpMm5dlhYgyixcwzF/ T0tbBzUss1fbWIrTkv9VszTE5yBbCGcRDtb9uxfz6fPzfITpVEELBdroMZVuXTcIcHvO Bz5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=CQahTyAQ; 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 67si4879866pfe.269.2019.05.03.17.23.42; Fri, 03 May 2019 17:23:57 -0700 (PDT) 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=@nifty.com header.s=dec2015msa header.b=CQahTyAQ; 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 S1726769AbfEDAWj (ORCPT + 99 others); Fri, 3 May 2019 20:22:39 -0400 Received: from conssluserg-02.nifty.com ([210.131.2.81]:52815 "EHLO conssluserg-02.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726059AbfEDAWg (ORCPT ); Fri, 3 May 2019 20:22:36 -0400 Received: from mail-vk1-f171.google.com (mail-vk1-f171.google.com [209.85.221.171]) (authenticated) by conssluserg-02.nifty.com with ESMTP id x440MHP6014335; Sat, 4 May 2019 09:22:18 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-02.nifty.com x440MHP6014335 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1556929338; bh=P85xUkVWJ0dVHjIoSMC9P7JcDgYlOOM9rXQ6Qi0p0vg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=CQahTyAQ45r3fagnlthGRnySZMZTYWUjqC6LECJL9xJGfKxJJLNQn5rq6/g26ko2e pB1fM739t7Y/nY5hjamdvPlVuacNNc+JcXJQAUV7+CqgijZZxH8fyn3+j1nhFMUYeJ CsPUnIK1FJMeTVVifmPyDvbt9FDOEgtsd8MrMoF/5o7agKBjl+6S6b8n6D+Jpijuzp ctXoX8yQSTysY1ZQDxhIoX7gDVwWcn6FqDulUcT5jGKRC+rHsWYgE59r6msaY5L24f mzceQufaEs9s6IeYWEhPhYMU2kRE9AAWJkKVpNUt5BA3A2xAnwkE9l9L4Ei7dVRn22 dXFaKyJDcn6oA== X-Nifty-SrcIP: [209.85.221.171] Received: by mail-vk1-f171.google.com with SMTP id r195so1833317vke.0; Fri, 03 May 2019 17:22:18 -0700 (PDT) X-Gm-Message-State: APjAAAWk45h/xia1A/6pvA5Oz30UMBX1HE7+b1aYhYXaLzmISfciKfn1 tik/Z2TE1zI+bwmQfKkPd8kWnZLUHtq0cbrSA/0= X-Received: by 2002:a1f:38b:: with SMTP id f11mr2437795vki.34.1556929337068; Fri, 03 May 2019 17:22:17 -0700 (PDT) MIME-Version: 1.0 References: <20190503182459.159121-1-joel@joelfernandes.org> In-Reply-To: From: Masahiro Yamada Date: Sat, 4 May 2019 09:21:41 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] kheaders: Move from proc to sysfs To: "Joel Fernandes (Google)" Cc: Linux Kernel Mailing List , Steven Rostedt , Adrian Ratiu , Alexei Starovoitov , Andrew Morton , atish patra , bpf@vger.kernel.org, Brendan Gregg , Brendan Gregg , Daniel Colascione , Daniel Borkmann , Dan Williams , Dietmar Eggemann , duyuchao , Greg Kroah-Hartman , Guenter Roeck , Jonathan Corbet , Karim Yaghmour , Kees Cook , "Cc: Android Kernel" , "open list:DOCUMENTATION" , "open list:KERNEL SELFTEST FRAMEWORK" , linux-trace-devel@vger.kernel.org, Manjo Raja Rao , Masami Hiramatsu , =?UTF-8?Q?Micha=C5=82_Gregorczyk?= , Michal Gregorczyk , Mohammad Husain , Olof Johansson , Qais Yousef , Randy Dunlap , Shuah Khan , Srinivas Ramana , Tamir Carmeli , Yonghong Song Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 4, 2019 at 9:18 AM Masahiro Yamada wrote: > > On Sat, May 4, 2019 at 3:27 AM Joel Fernandes (Google) > wrote: > > > > The kheaders archive consisting of the kernel headers used for compiling > > bpf programs is in /proc. However there is concern that moving it here > > will make it permanent. Let us move it to /sys/kernel as discussed [1]. > > > > [1] https://lore.kernel.org/patchwork/patch/1067310/#1265969 > > > > Suggested-by: Steven Rostedt > > Signed-off-by: Joel Fernandes (Google) > > --- > > This patch applies on top of the previous patch that was applied to the > > driver tree: > > https://lore.kernel.org/patchwork/patch/1067310/ > > > > kernel/kheaders.c | 40 ++++++++++++++++------------------------ > > > Please rename CONFIG_IKHEADERS_PROC. > > Thanks. Please adjust Kconfig prompt. tristate "Enable kernel header artifacts through /proc/kheaders.tar.xz" "depends on PROC_FS" -> "depends on SYSFS" > > > > > 1 file changed, 16 insertions(+), 24 deletions(-) > > > > diff --git a/kernel/kheaders.c b/kernel/kheaders.c > > index 70ae6052920d..6a16f8f6898d 100644 > > --- a/kernel/kheaders.c > > +++ b/kernel/kheaders.c > > @@ -8,9 +8,8 @@ > > > > #include > > #include > > -#include > > +#include > > #include > > -#include > > > > /* > > * Define kernel_headers_data and kernel_headers_data_end, within which the > > @@ -31,39 +30,32 @@ extern char kernel_headers_data; > > extern char kernel_headers_data_end; > > > > static ssize_t > > -ikheaders_read_current(struct file *file, char __user *buf, > > - size_t len, loff_t *offset) > > +ikheaders_read(struct file *file, struct kobject *kobj, > > + struct bin_attribute *bin_attr, > > + char *buf, loff_t off, size_t len) > > { > > - return simple_read_from_buffer(buf, len, offset, > > - &kernel_headers_data, > > - &kernel_headers_data_end - > > - &kernel_headers_data); > > + memcpy(buf, &kernel_headers_data + off, len); > > + return len; > > } > > > > -static const struct file_operations ikheaders_file_ops = { > > - .read = ikheaders_read_current, > > - .llseek = default_llseek, > > +static struct bin_attribute kheaders_attr __ro_after_init = { > > + .attr = { > > + .name = "kheaders.tar.xz", > > + .mode = S_IRUGO, > > + }, > > + .read = &ikheaders_read, > > }; > > > > static int __init ikheaders_init(void) > > { > > - struct proc_dir_entry *entry; > > - > > - /* create the current headers file */ > > - entry = proc_create("kheaders.tar.xz", S_IRUGO, NULL, > > - &ikheaders_file_ops); > > - if (!entry) > > - return -ENOMEM; > > - > > - proc_set_size(entry, > > - &kernel_headers_data_end - > > - &kernel_headers_data); > > - return 0; > > + kheaders_attr.size = (&kernel_headers_data_end - > > + &kernel_headers_data); > > + return sysfs_create_bin_file(kernel_kobj, &kheaders_attr); > > } > > > > static void __exit ikheaders_cleanup(void) > > { > > - remove_proc_entry("kheaders.tar.xz", NULL); > > + sysfs_remove_bin_file(kernel_kobj, &kheaders_attr); > > } > > > > module_init(ikheaders_init); > > -- > > 2.21.0.1020.gf2820cf01a-goog > > > > -- > Best Regards > Masahiro Yamada -- Best Regards Masahiro Yamada