Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp752473ybg; Mon, 1 Jun 2020 13:32:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhQdC4kdBPydxgRrxasH9hWLR0FQ0/NTQmgfupzltQjwWqN/OjLwwySlYFCUmUE4luH7OV X-Received: by 2002:a17:906:60d3:: with SMTP id f19mr19581825ejk.478.1591043522081; Mon, 01 Jun 2020 13:32:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591043522; cv=none; d=google.com; s=arc-20160816; b=GzYDEXJ2GOqujxX9sZfqGcDlnZ2Ko7Prq5zqAQrcS0BSP+kI7OZDymZRIfGvhp2KDB NF0cZK550lRGDEMn8Hd02pylKYr7gU2MwQqDgIo7LfJ3IcvmGJu8WY5v8LWgZiH2Jn7T r5OkpxbNxVl5rsgsZBcoVN9MXS4azlJsSJg6nIw8KIxR67whZ2tMp1rvtZkV8geugqfv 4rh7rnsCBbaQdi1ROFtWQYD8mjnCKQolBAN6wYHmP+fJM1Y8TrzUukJzm7fpeEVyorzC ohf1wT1b4IPXu6r5tTA3A4GQakzlqnKpBEbn7z6ugEM7EMHdQJNbqglVsJO+oeJgXy2g pZsQ== 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; bh=HAs9Kw635YW+HDXvo0zhakrzZhJRnpKHS/Rqz6u5QVM=; b=x1Chgjz97anjU3gMPl1LaEfl5TjHE/EET0aWBj4zuXLXjivvBrxjqZM1w24sWIVkdN eL4eO1QorgP8MxLaQFNBrOsIi/0DUe9xuFVPzoWMRjTdM0I/maKx8B0Wh7QNUWy20ymn gzRUu2VJ0zeUIGl3uhXpwk4M0iO24yw0TY9eWSN6xm8jLYzBdf2pDt1YwQpNyci4SAtY IiHDD+7guAqSbqn139RkDo3gnddxrStBKNTdUE4ZIFYzHPb/0DC6DYQgxlR4CcIeuvGD 0Gf+W3KsE04tiw/FH9eiCWjakXcu+msPV1cxqpevsvl6N5vn0zME/79WfNk8Ze4KrJNP xgcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cayfLfkl; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u7si366466ejr.69.2020.06.01.13.31.37; Mon, 01 Jun 2020 13:32:02 -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=@gmail.com header.s=20161025 header.b=cayfLfkl; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728444AbgFAU3q (ORCPT + 99 others); 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-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)); > + > + [...]