Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp823873lqh; Thu, 28 Mar 2024 19:06:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWOUNcVYp4/p6RJQSJAitR0K8pCP5r5g//8BX6uA7HOORvp1iw5ih6LV2l6Zks5ZaTHc6ykJLFQwQDccdSL52MjlZnK8ZAGsbDjzXFZOQ== X-Google-Smtp-Source: AGHT+IGx/wgUxTJcMGlpz6ZlXjKPCWpo/SL94gSb7mpJwIVxs2oyUCkrfuGjn4RalxuxVAAewWc9 X-Received: by 2002:a17:902:da87:b0:1e0:e2c2:578c with SMTP id j7-20020a170902da8700b001e0e2c2578cmr1548999plx.11.1711677982017; Thu, 28 Mar 2024 19:06:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711677981; cv=pass; d=google.com; s=arc-20160816; b=JlgjpEwAFjjOU1TMzQ+RKT7fD9sjqnQ/bmIdxJhPK4irasyLEYkVOmStowC1FnsNZn y14Y0Uy+cVLI76Bkncf46jqecTlxtFZZTR1jUfz55KDtWCO+BWnJTmsaHWdAPgqKdwYr Qi9BSxoee1Y2K0kcg0mWFzdaZDNGj8z4y4M/efGOQCDVdPOWxeZtLqpPXc0ibUfEbdjG WFcSi6ljNM+j3KBs46Cygxgdv3mIoFGoHIaBhU/kCVwnMYE0sMLG25s7UlnEDEMT20Lq QWGAVIFZde6VKlSUP6bSX9UiO5El4rgavdGYmo1n1BS64zSt8YbWmzhOs6HrstLQva/A Ryjg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=dc0/1tSRu57hk2+lOEsBiEE+YFsUFGOWDNxYukZQ2Us=; fh=flCZlotB1BK1ulk6C5erU4/8bJiwTDUoqVslKdj9B0I=; b=UzkNzSsXeDg+pm9hTebL0Ybtc+SyUScYKuR5AWnYtfBRhG+8lmSVC616cT5CeUsUdu EtXvt59sxCyM+a+HQ+CGVWxlwgslR6NjnGZBJyW8H+U6uBzHMhw5tfm78E2iXFJQEgyu wpam5LtQPh2/Agv+HsMpcSYREkzzXrjIi/U3iK4hz6Fg6fkJsb7tjifFWIDmZ7DuhuIz M7py98iDrKNiVslLKrbljB6lddl6meu2Gmi0CIvOgT6PhlJfraHKZGgrsrZTuje13deh HwGITusyunGhuexqkZGmQZDLzp59366HNPcG9zGYaZD8CiEEcc1pkdPONG0N0GejfErS gwOA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=EhIZlclk; arc=pass (i=1 spf=pass spfdomain=flex--drosen.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-124014-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124014-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l6-20020a170903120600b001e098ad43d7si2665797plh.216.2024.03.28.19.06.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 19:06:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124014-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=EhIZlclk; arc=pass (i=1 spf=pass spfdomain=flex--drosen.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-124014-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124014-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A42F828CBF8 for ; Fri, 29 Mar 2024 02:06:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA4DD13BC1A; Fri, 29 Mar 2024 01:55:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="EhIZlclk" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40B4B13B5A1 for ; Fri, 29 Mar 2024 01:55:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711677317; cv=none; b=pogYlA0BTIrhRVp9Ow7BhgZuBrV3U7fJjkxy8XZmhZHfyCZbrpcvUemxFs9pXTasUAy7S6utguoRjWtQSFrvuechhbA7Wmwnn/CR3viku/jC3moiL9kAyx95F0AnXh4swEKuKvxYbOtv+8Pr0yNXmirOr79TuQhJaYS6qbxIC4s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711677317; c=relaxed/simple; bh=sqy3xAPgmjgOiWHaXJZZi1ooyhcDWUkMY7GvNQ4f4EQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=drLLhHWkyeOX/I1nywn3FaBVlWwTvUhkCD5LwWC7vZq5/OdVl1Zz2HJIzSZ9kEtp1M4Kwo2qUvAEKN4n1acDMVvBimb0vwUr3myWFITEYlGX299GDXtQhHEVUcc8s7OdiSChXC+XdQs/LbxNIWU22TNyOxnvw1p5PC5b3Cgw7j0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--drosen.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=EhIZlclk; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--drosen.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc743cc50a6so1959816276.2 for ; Thu, 28 Mar 2024 18:55:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711677313; x=1712282113; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=dc0/1tSRu57hk2+lOEsBiEE+YFsUFGOWDNxYukZQ2Us=; b=EhIZlclkOK4/1KI15NEBKCSrzt0al0Nnw5GpN9W8hi/5riwvqUchqEa3ci7OUcSTtz 6hAimfpK/aleBDLJcmkirbm0XDaiwqmWkJ/L1R/CILT/El41vZP5rspLH0UGp6Bw2Vee ewBXUYGFvoDEDJLthGvXd4ORV/Dx1tIrmp0CyVtkBn3dPhEPxOcmpso/SKS6SJLVh946 ygJXRXyF/kqJXrvfVayGZ0WDIwZV6niMgA8HNkcD6wuBPSyjwtslzmq/eSmwgXYAeNeY ufJiwELyKhoFZtRkguNdCcVm5UXZJbdI9qBwvJT73rS2vbHcIYaGpDkSveirt916NyvX 27+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711677313; x=1712282113; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dc0/1tSRu57hk2+lOEsBiEE+YFsUFGOWDNxYukZQ2Us=; b=eSiUCakluIHylKz1x9mTpAai5RFV3ngP2IFfCpa4u1aMr8M0/kxQapj34CToIeEP6u 7n/DEsnFtBig71LKNobAy7IXfb9qDNupd2CvMRF6jppk9bJDjBOrme8lkjSQ2+UOV/R+ jVPQqze3FbuRS5ULZeqVCnsGGCc8gr30BsWo0jeZkJek/Pwap8MStZ1AiuD2Ucn7Srpm QQhxITkshn6XKiobz17cWCYWY8+EoUTjHEB58fIeW+V3ByXXcixneOjgjGR5Yb9eJYJ2 TmuT6zMyiaxI9QZTmDEYw7LRQ7eh1Iy34LtLXFWdmGwXKJ+bGPqvNuMqUgH4cbGtMsXq GxAw== X-Forwarded-Encrypted: i=1; AJvYcCWVmNQLwPz+weynFEXQ0Br/kxal8ltPEsI0d7gBMdoRza2WHyBD7t7U6S8Kq/YIkC6rCZtUcl5hLb6M9Xpq9i7vzWxaYwWDyVZuEh3W X-Gm-Message-State: AOJu0Yw82AHgYzRWeQqRfU9srcAarhsAUdSx1tksVLGy+WVAm70407Iz f9kqzfSj1K4DCO++M0M01NIa1+l5PNs9s42IMZxZ1iFvwU5vNWjqKq2bViKXXQWeepxTiB6Cd9Y /2A== X-Received: from drosen.mtv.corp.google.com ([2620:15c:211:201:fcce:d6ab:804c:b94b]) (user=drosen job=sendgmr) by 2002:a05:6902:220e:b0:dc7:865b:22c6 with SMTP id dm14-20020a056902220e00b00dc7865b22c6mr86787ybb.8.1711677313466; Thu, 28 Mar 2024 18:55:13 -0700 (PDT) Date: Thu, 28 Mar 2024 18:53:48 -0700 In-Reply-To: <20240329015351.624249-1-drosen@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240329015351.624249-1-drosen@google.com> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240329015351.624249-34-drosen@google.com> Subject: [RFC PATCH v4 33/36] fuse-bpf: Add default filter op From: Daniel Rosenberg To: Miklos Szeredi , bpf@vger.kernel.org, Alexei Starovoitov Cc: Amir Goldstein , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org, Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Eduard Zingerman , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Jonathan Corbet , Joanne Koong , Mykola Lysenko , Christian Brauner , kernel-team@android.com, Daniel Rosenberg Content-Type: text/plain; charset="UTF-8" Add a default bpf func to call if the specific one is not present. Useful if you wish to track when different ops are handled. Signed-off-by: Daniel Rosenberg --- fs/fuse/backing.c | 136 +++++++++++++++++++++------------------ include/linux/bpf_fuse.h | 2 + include/uapi/linux/bpf.h | 1 + 3 files changed, 77 insertions(+), 62 deletions(-) diff --git a/fs/fuse/backing.c b/fs/fuse/backing.c index 9227e62b8734..ec554a2bc93f 100644 --- a/fs/fuse/backing.c +++ b/fs/fuse/backing.c @@ -244,6 +244,12 @@ static inline void bpf_fuse_free_alloced(struct bpf_fuse_args *fa) &fa.info, &feo); \ else \ bpf_next = BPF_FUSE_CONTINUE; \ + if (bpf_next == BPF_FUSE_CALL_DEFAULT) { \ + if (fuse_ops->default_filter) \ + bpf_next = fuse_ops->default_filter(&fa.info); \ + else \ + bpf_next = BPF_FUSE_CONTINUE; \ + } \ if (bpf_next < 0) { \ error = bpf_next; \ break; \ @@ -283,6 +289,12 @@ static inline void bpf_fuse_free_alloced(struct bpf_fuse_args *fa) fa.info.opcode |= FUSE_POSTFILTER; \ if (bpf_next == BPF_FUSE_POSTFILTER) \ bpf_next = call_postfilter(fuse_ops, &fa.info, &feo);\ + if (bpf_next == BPF_FUSE_CALL_DEFAULT) { \ + if (fuse_ops->default_filter) \ + bpf_next = fuse_ops->default_filter(&fa.info); \ + else \ + bpf_next = BPF_FUSE_CONTINUE; \ + } \ if (bpf_next < 0) { \ error = bpf_next; \ break; \ @@ -611,7 +623,7 @@ static int fuse_open_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_info * if (ops->opendir_prefilter) return ops->opendir_prefilter(meta, &open->in); } - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_open_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -625,7 +637,7 @@ static int fuse_open_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info if (ops->opendir_postfilter) return ops->opendir_postfilter(meta, &open->in, &open->out); } - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_open_backing(struct bpf_fuse_args *fa, int *out, @@ -767,7 +779,7 @@ static int fuse_create_open_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta { if (ops->create_open_prefilter) return ops->create_open_prefilter(meta, &args->in, &args->name); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_create_open_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -775,7 +787,7 @@ static int fuse_create_open_postfilter(struct fuse_ops *ops, struct bpf_fuse_met { if (ops->create_open_postfilter) return ops->create_open_postfilter(meta, &args->in, &args->name, &args->entry_out, &args->open_out); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_open_file_backing(struct inode *inode, struct file *file) @@ -931,7 +943,7 @@ static int fuse_release_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_inf { if (ops->release_prefilter) return ops->release_prefilter(meta, args); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_release_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -939,7 +951,7 @@ static int fuse_release_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_in { if (ops->release_postfilter) return ops->release_postfilter(meta, args); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_releasedir_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -947,7 +959,7 @@ static int fuse_releasedir_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_ { if (ops->releasedir_prefilter) return ops->releasedir_prefilter(meta, args); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_releasedir_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -955,7 +967,7 @@ static int fuse_releasedir_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta { if (ops->releasedir_postfilter) return ops->releasedir_postfilter(meta, args); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_release_backing(struct bpf_fuse_args *fa, int *out, @@ -1022,7 +1034,7 @@ static int fuse_flush_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_info { if (ops->flush_prefilter) return ops->flush_prefilter(meta, args); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_flush_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -1030,7 +1042,7 @@ static int fuse_flush_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info { if (ops->flush_postfilter) return ops->flush_postfilter(meta, args); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_flush_backing(struct bpf_fuse_args *fa, int *out, struct file *file, fl_owner_t id) @@ -1102,7 +1114,7 @@ static int fuse_lseek_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_info { if (ops->lseek_prefilter) return ops->lseek_prefilter(meta, &args->in); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_lseek_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -1110,7 +1122,7 @@ static int fuse_lseek_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info { if (ops->lseek_postfilter) return ops->lseek_postfilter(meta, &args->in, &args->out); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_lseek_backing(struct bpf_fuse_args *fa, loff_t *out, @@ -1217,7 +1229,7 @@ static int fuse_copy_file_range_prefilter(struct fuse_ops *ops, struct bpf_fuse_ { if (ops->copy_file_range_prefilter) return ops->copy_file_range_prefilter(meta, &args->in); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_copy_file_range_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -1225,7 +1237,7 @@ static int fuse_copy_file_range_postfilter(struct fuse_ops *ops, struct bpf_fuse { if (ops->copy_file_range_postfilter) return ops->copy_file_range_postfilter(meta, &args->in, &args->out); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_copy_file_range_backing(struct bpf_fuse_args *fa, ssize_t *out, struct file *file_in, @@ -1303,7 +1315,7 @@ static int fuse_fsync_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_info { if (ops->fsync_prefilter) return ops->fsync_prefilter(meta, in); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_fsync_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -1311,7 +1323,7 @@ static int fuse_fsync_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info { if (ops->fsync_postfilter) return ops->fsync_postfilter(meta, in); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_fsync_backing(struct bpf_fuse_args *fa, int *out, @@ -1376,7 +1388,7 @@ static int fuse_dir_fsync_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_i { if (ops->dir_fsync_prefilter) return ops->fsync_prefilter(meta, in); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_dir_fsync_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -1384,7 +1396,7 @@ static int fuse_dir_fsync_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_ { if (ops->dir_fsync_postfilter) return ops->dir_fsync_postfilter(meta, in); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } int fuse_bpf_dir_fsync(int *out, struct inode *inode, struct file *file, loff_t start, loff_t end, int datasync) @@ -1466,7 +1478,7 @@ static int fuse_getxattr_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_in { if (ops->getxattr_prefilter) return ops->getxattr_prefilter(meta, &args->in, &args->name); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_getxattr_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -1474,7 +1486,7 @@ static int fuse_getxattr_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_i { if (ops->getxattr_postfilter) return ops->getxattr_postfilter(meta, &args->in, &args->name, &args->value, &args->out); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_getxattr_backing(struct bpf_fuse_args *fa, int *out, @@ -1580,7 +1592,7 @@ static int fuse_listxattr_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_i { if (ops->listxattr_prefilter) return ops->listxattr_prefilter(meta, &args->in); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_listxattr_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -1588,7 +1600,7 @@ static int fuse_listxattr_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_ { if (ops->listxattr_postfilter) return ops->listxattr_postfilter(meta, &args->in, &args->value, &args->out); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_listxattr_backing(struct bpf_fuse_args *fa, ssize_t *out, struct dentry *dentry, @@ -1701,7 +1713,7 @@ static int fuse_setxattr_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_in { if (ops->setxattr_prefilter) return ops->setxattr_prefilter(meta, &args->in, &args->name, &args->value); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_setxattr_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -1709,7 +1721,7 @@ static int fuse_setxattr_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_i { if (ops->setxattr_postfilter) return ops->setxattr_postfilter(meta, &args->in, &args->name, &args->value); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_setxattr_backing(struct bpf_fuse_args *fa, int *out, struct dentry *dentry, @@ -1777,7 +1789,7 @@ static int fuse_removexattr_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta { if (ops->removexattr_prefilter) return ops->removexattr_prefilter(meta, in); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_removexattr_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -1785,7 +1797,7 @@ static int fuse_removexattr_postfilter(struct fuse_ops *ops, struct bpf_fuse_met { if (ops->removexattr_postfilter) return ops->removexattr_postfilter(meta, in); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_removexattr_backing(struct bpf_fuse_args *fa, int *out, @@ -1904,7 +1916,7 @@ static int fuse_file_read_iter_prefilter(struct fuse_ops *ops, struct bpf_fuse_m { if (ops->read_iter_prefilter) return ops->read_iter_prefilter(meta, &args->in); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_file_read_iter_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -1912,7 +1924,7 @@ static int fuse_file_read_iter_postfilter(struct fuse_ops *ops, struct bpf_fuse_ { if (ops->read_iter_postfilter) return ops->read_iter_postfilter(meta, &args->in, &args->out); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } // TODO: use backing-file.c @@ -2044,7 +2056,7 @@ static int fuse_write_iter_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_ { if (ops->write_iter_prefilter) return ops->write_iter_prefilter(meta, &args->in); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_write_iter_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -2052,7 +2064,7 @@ static int fuse_write_iter_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta { if (ops->write_iter_postfilter) return ops->write_iter_postfilter(meta, &args->in, &args->out); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_file_write_iter_backing(struct bpf_fuse_args *fa, ssize_t *out, @@ -2232,7 +2244,7 @@ static int fuse_file_fallocate_prefilter(struct fuse_ops *ops, struct bpf_fuse_m { if (ops->file_fallocate_prefilter) return ops->file_fallocate_prefilter(meta, in); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_file_fallocate_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -2240,7 +2252,7 @@ static int fuse_file_fallocate_postfilter(struct fuse_ops *ops, struct bpf_fuse_ { if (ops->file_fallocate_postfilter) return ops->file_fallocate_postfilter(meta, in); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_file_fallocate_backing(struct bpf_fuse_args *fa, int *out, @@ -2339,7 +2351,7 @@ static int fuse_lookup_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_info { if (ops->lookup_prefilter) return ops->lookup_prefilter(meta, &args->name); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_lookup_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -2347,7 +2359,7 @@ static int fuse_lookup_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_inf { if (ops->lookup_postfilter) return ops->lookup_postfilter(meta, &args->name, &args->out, &args->bpf_entries); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_lookup_backing(struct bpf_fuse_args *fa, struct dentry **out, struct inode *dir, @@ -2603,7 +2615,7 @@ static int fuse_mknod_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_info { if (ops->mknod_prefilter) return ops->mknod_prefilter(meta, &args->in, &args->name); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_mknod_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -2611,7 +2623,7 @@ static int fuse_mknod_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info { if (ops->mknod_postfilter) return ops->mknod_postfilter(meta, &args->in, &args->name); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_mknod_backing(struct bpf_fuse_args *fa, int *out, @@ -2773,7 +2785,7 @@ static int fuse_mkdir_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_info { if (ops->mkdir_prefilter) return ops->mkdir_prefilter(meta, &args->in, &args->name); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_mkdir_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -2781,7 +2793,7 @@ static int fuse_mkdir_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info { if (ops->mkdir_prefilter) return ops->mkdir_postfilter(meta, &args->in, &args->name); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } int fuse_bpf_mkdir(int *out, struct inode *dir, struct dentry *entry, umode_t mode) @@ -2827,7 +2839,7 @@ static int fuse_rmdir_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_info { if (ops->rmdir_prefilter) return ops->rmdir_prefilter(meta, name); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_rmdir_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -2835,7 +2847,7 @@ static int fuse_rmdir_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info { if (ops->rmdir_postfilter) return ops->rmdir_postfilter(meta, name); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_rmdir_backing(struct bpf_fuse_args *fa, int *out, @@ -3020,7 +3032,7 @@ static int fuse_rename2_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_inf { if (ops->rename2_prefilter) return ops->rename2_prefilter(meta, &args->in, &args->old_name, &args->new_name); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_rename2_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -3028,7 +3040,7 @@ static int fuse_rename2_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_in { if (ops->rename2_postfilter) return ops->rename2_postfilter(meta, &args->in, &args->old_name, &args->new_name); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_rename2_backing(struct bpf_fuse_args *fa, int *out, @@ -3124,7 +3136,7 @@ static int fuse_rename_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_info { if (ops->rename_prefilter) return ops->rename_prefilter(meta, &args->in, &args->old_name, &args->new_name); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_rename_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -3132,7 +3144,7 @@ static int fuse_rename_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_inf { if (ops->rename_postfilter) return ops->rename_postfilter(meta, &args->in, &args->old_name, &args->new_name); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_rename_backing(struct bpf_fuse_args *fa, int *out, @@ -3195,7 +3207,7 @@ static int fuse_unlink_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_info { if (ops->unlink_prefilter) return ops->unlink_prefilter(meta, name); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_unlink_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -3203,7 +3215,7 @@ static int fuse_unlink_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_inf { if (ops->unlink_postfilter) return ops->unlink_postfilter(meta, name); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_unlink_backing(struct bpf_fuse_args *fa, int *out, struct inode *dir, struct dentry *entry) @@ -3300,7 +3312,7 @@ static int fuse_link_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_info * { if (ops->link_prefilter) return ops->link_prefilter(meta, &args->in, &args->name); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_link_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -3308,7 +3320,7 @@ static int fuse_link_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info { if (ops->link_postfilter) return ops->link_postfilter(meta, &args->in, &args->name); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } @@ -3433,7 +3445,7 @@ static int fuse_getattr_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_inf { if (ops->getattr_prefilter) return ops->getattr_prefilter(meta, &args->in); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_getattr_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -3441,7 +3453,7 @@ static int fuse_getattr_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_in { if (ops->getattr_postfilter) return ops->getattr_postfilter(meta, &args->in, &args->out); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } /* TODO: unify with overlayfs */ @@ -3597,7 +3609,7 @@ static int fuse_setattr_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_inf { if (ops->setattr_prefilter) return ops->setattr_prefilter(meta, &args->in); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_setattr_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -3605,7 +3617,7 @@ static int fuse_setattr_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_in { if (ops->setattr_postfilter) return ops->setattr_postfilter(meta, &args->in, &args->out); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_setattr_backing(struct bpf_fuse_args *fa, int *out, @@ -3680,7 +3692,7 @@ static int fuse_statfs_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_info { if (ops->statfs_prefilter) return ops->statfs_prefilter(meta); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_statfs_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -3688,7 +3700,7 @@ static int fuse_statfs_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_inf { if (ops->statfs_postfilter) return ops->statfs_postfilter(meta, out); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_statfs_backing(struct bpf_fuse_args *fa, int *out, @@ -3801,7 +3813,7 @@ static int fuse_get_link_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_in { if (ops->get_link_prefilter) return ops->get_link_prefilter(meta, &args->name); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_get_link_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -3809,7 +3821,7 @@ static int fuse_get_link_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_i { if (ops->get_link_postfilter) return ops->get_link_postfilter(meta, &args->name); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_get_link_backing(struct bpf_fuse_args *fa, const char **out, @@ -3907,7 +3919,7 @@ static int fuse_symlink_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_inf { if (ops->symlink_prefilter) return ops->symlink_prefilter(meta, &args->name, &args->path); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_symlink_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -3915,7 +3927,7 @@ static int fuse_symlink_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_in { if (ops->symlink_postfilter) return ops->symlink_postfilter(meta, &args->name, &args->path); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_symlink_backing(struct bpf_fuse_args *fa, int *out, @@ -4047,7 +4059,7 @@ static int fuse_readdir_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_inf { if (ops->readdir_prefilter) return ops->readdir_prefilter(meta, &args->in); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_readdir_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -4055,7 +4067,7 @@ static int fuse_readdir_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_in { if (ops->readdir_postfilter) return ops->readdir_postfilter(meta, &args->in, &args->out, &args->buffer); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } struct fusebpf_ctx { @@ -4223,7 +4235,7 @@ static int fuse_access_prefilter(struct fuse_ops *ops, struct bpf_fuse_meta_info { if (ops->access_prefilter) return ops->access_prefilter(meta, in); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_access_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_info *meta, @@ -4231,7 +4243,7 @@ static int fuse_access_postfilter(struct fuse_ops *ops, struct bpf_fuse_meta_inf { if (ops->access_postfilter) return ops->access_postfilter(meta, in); - return BPF_FUSE_CONTINUE; + return BPF_FUSE_CALL_DEFAULT; } static int fuse_access_backing(struct bpf_fuse_args *fa, int *out, struct inode *inode, int mask) diff --git a/include/linux/bpf_fuse.h b/include/linux/bpf_fuse.h index 15646ba59c41..0747790c47ec 100644 --- a/include/linux/bpf_fuse.h +++ b/include/linux/bpf_fuse.h @@ -86,6 +86,8 @@ static inline unsigned bpf_fuse_arg_size(const struct bpf_fuse_arg *arg) } struct fuse_ops { + uint32_t (*default_filter)(const struct bpf_fuse_meta_info *meta); + uint32_t (*open_prefilter)(const struct bpf_fuse_meta_info *meta, struct fuse_open_in *in); uint32_t (*open_postfilter)(const struct bpf_fuse_meta_info *meta, diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 46c1a3e3166d..fe8b485c9335 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -7467,6 +7467,7 @@ struct bpf_iter_num { #define BPF_FUSE_USER_PREFILTER 2 #define BPF_FUSE_POSTFILTER 3 #define BPF_FUSE_USER_POSTFILTER 4 +#define BPF_FUSE_CALL_DEFAULT 5 /* Op Code Filter values for BPF Programs */ #define FUSE_OPCODE_FILTER 0x0ffff -- 2.44.0.478.gd926399ef9-goog