From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9310DC433E0 for ; Mon, 1 Jun 2020 20:29:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6A8832074B for ; Mon, 1 Jun 2020 20:29:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cayfLfkl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728546AbgFAU3q (ORCPT ); Mon, 1 Jun 2020 16:29:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727875AbgFAU3q (ORCPT ); Mon, 1 Jun 2020 16:29:46 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2EB7C061A0E; Mon, 1 Jun 2020 13:29:45 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id c12so8788570qtq.11; Mon, 01 Jun 2020 13:29:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HAs9Kw635YW+HDXvo0zhakrzZhJRnpKHS/Rqz6u5QVM=; b=cayfLfklNNt8EmT631CpwrTFKbLubWMnfHX9UAcGmVVpB72JZ5N7bSspIsqetgItMu hyhsMUWDhHRi/LKEkkvhL3ie9JmTTqzMlrL6BG90PzpHtJVQ+JJnwRZ2yxcusbPhKvWq oTDeYcoDcrQxGU5SwaOMdK7HnAQOaeI4WrzqaJYlSTHCjaoaPoOilMYjzDiAP5gNl2o0 bFMx02zEd8/P4nImlfX12mrOSG/0zWG+GXKschLlTLXoYkgyjDO+NlLN5+FjUAE3IO0c 3MGeLBcyeSuyeifbU82DPV+bAuLqgddgmU6jywwPnhakMlBhaFn6YIbJJIgd1tMWTTWT +D3g== 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=HAs9Kw635YW+HDXvo0zhakrzZhJRnpKHS/Rqz6u5QVM=; b=MYUCl8TzN94TdCeM5BiQMzPpNpHSjdWGbjzlu3jS5tOpLtulLZoXFC8etNF9xP702j knM4yec1F3v53Fc3/ENkLQewelrQHQDHWpwRy8xBF94eP6tJ+CcN0ZT0eYGib/4783aK uBA3wvmKnIF6FHJCG9V3fqCCY3xSv8ZPPbIvbRrUWTvuAoP/pL/7WN+EfAHk/NC4wZNZ kHp/EAPtiSmCvN8JffRKLksaoGaWqwJ9lXbRKSkXlHDZOSzc8NSvOobQ9FDhMubClSlj stUmM4Bh4NvuGf0UMA7fqZBXpFSMvtW/IJObTqVpM1yxptTl/6oVYrJ/hOatKXLmqro5 CT2Q== X-Gm-Message-State: AOAM530h64EhQcbK4rfzZL4A17vVix4BY7dL41YYalYyavhfskhrQH7Q /kiM7AzA5DEp7V+B2hwBE87wvulwIe08IjuNGKRaG8JF X-Google-Smtp-Source: ABdhPJyFqi2sy1XpNUtKnyJCkuPklMuovTOzVIZJEpTDi6XMDFRLM77wlqBxWlNBC9o8/kQn1VsjhpYUIoUmWKs47Fg= X-Received: by 2002:ac8:2dc3:: with SMTP id q3mr23123105qta.141.1591043384218; Mon, 01 Jun 2020 13:29:44 -0700 (PDT) MIME-Version: 1.0 References: <20200526163336.63653-1-kpsingh@chromium.org> <20200526163336.63653-5-kpsingh@chromium.org> In-Reply-To: <20200526163336.63653-5-kpsingh@chromium.org> From: Andrii Nakryiko Date: Mon, 1 Jun 2020 13:29:33 -0700 Message-ID: Subject: Re: [PATCH bpf-next 4/4] bpf: Add selftests for local_storage To: KP Singh Cc: open list , linux-fsdevel@vger.kernel.org, bpf , linux-security-module@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , James Morris , Alexander Viro , Martin KaFai Lau , Florent Revest 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 Tue, May 26, 2020 at 9:34 AM KP Singh wrote: > > From: KP Singh > > inode_local_storage: > > * Hook to the file_open and inode_unlink LSM hooks. > * Create and unlink a temporary file. > * Store some information in the inode's bpf_local_storage during > file_open. > * Verify that this information exists when the file is unlinked. > > sk_local_storage: > > * Hook to the socket_post_create and socket_bind LSM hooks. > * Open and bind a socket and set the sk_storage in the > socket_post_create hook using the start_server helper. > * Verify if the information is set in the socket_bind hook. > > Signed-off-by: KP Singh > --- > .../bpf/prog_tests/test_local_storage.c | 60 ++++++++ > .../selftests/bpf/progs/local_storage.c | 139 ++++++++++++++++++ > 2 files changed, 199 insertions(+) > create mode 100644 tools/testing/selftests/bpf/prog_tests/test_local_storage.c > create mode 100644 tools/testing/selftests/bpf/progs/local_storage.c > [...] > +struct dummy_storage { > + __u32 value; > +}; > + > +struct { > + __uint(type, BPF_MAP_TYPE_INODE_STORAGE); > + __uint(map_flags, BPF_F_NO_PREALLOC); > + __type(key, int); > + __type(value, struct dummy_storage); > +} inode_storage_map SEC(".maps"); > + > +struct { > + __uint(type, BPF_MAP_TYPE_SK_STORAGE); > + __uint(map_flags, BPF_F_NO_PREALLOC | BPF_F_CLONE); > + __type(key, int); > + __type(value, struct dummy_storage); > +} sk_storage_map SEC(".maps"); > + > +/* Using vmlinux.h causes the generated BTF to be so big that the object > + * load fails at btf__load. > + */ That's first time I hear about such issue. Do you have an error log from verifier? Clang is smart enough to trim down used types to only those that are actually necessary, so too big BTF shouldn't be a thing. But let's try to dig into this and fix whatever issue it is, before giving up :) > +struct sock {} __attribute__((preserve_access_index)); > +struct sockaddr {} __attribute__((preserve_access_index)); > +struct socket { > + struct sock *sk; > +} __attribute__((preserve_access_index)); > + > +struct inode {} __attribute__((preserve_access_index)); > +struct dentry { > + struct inode *d_inode; > +} __attribute__((preserve_access_index)); > +struct file { > + struct inode *f_inode; > +} __attribute__((preserve_access_index)); > + > + [...]