summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Lawrence <paullawrence@google.com>2023-03-30 13:47:33 -0700
committerPaul Lawrence <paullawrence@google.com>2023-06-13 08:35:58 -0700
commit8d5c5de7d943bfde27ed290a8832e65da069cf75 (patch)
tree5e6d922bacb5e4bfcaaa113c41b32fbad1509cb1
parent441b204a9d1f369ca7a6a19c5298135d5eaa87be (diff)
downloadcommon-8d5c5de7d943bfde27ed290a8832e65da069cf75.tar.gz
ANDROID: fuse-bpf: Run bpf with migration disabled
To avoid a BUG_ON, we must disable migration before running any bpf program. Bug: 273620140 Bug: 286939538 Test: fuse-test passes, no bug with CONFIG_DEBUG_ATOMIC_SLEEP Change-Id: I9ed69ae93fc4b922782fccde293cb02b3eae3f06 Signed-off-by: Paul Lawrence <paullawrence@google.com> (cherry picked from commit 0411f8d9dfa88e441456b5bcf684c5ec28ef08a7)
-rw-r--r--fs/fuse/fuse_i.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index a1fee82265ea..e76ae9f2671c 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -1832,6 +1832,16 @@ void __exit fuse_bpf_cleanup(void);
ssize_t fuse_bpf_simple_request(struct fuse_mount *fm, struct fuse_bpf_args *args);
+static inline int fuse_bpf_run(struct bpf_prog *prog, struct fuse_bpf_args *fba)
+{
+ int ret;
+
+ migrate_disable();
+ ret = BPF_PROG_RUN(prog, fba);
+ migrate_enable();
+ return ret;
+}
+
/*
* expression statement to wrap the backing filter logic
* struct inode *inode: inode with bpf and backing inode
@@ -1883,7 +1893,7 @@ ssize_t fuse_bpf_simple_request(struct fuse_mount *fm, struct fuse_bpf_args *arg
fa.out_numargs = fa.in_numargs; \
\
ext_flags = fuse_inode->bpf ? \
- BPF_PROG_RUN(fuse_inode->bpf, &fa) : \
+ fuse_bpf_run(fuse_inode->bpf, &fa) : \
FUSE_BPF_BACKING; \
if (ext_flags < 0) { \
fer = (struct fuse_err_ret) { \
@@ -1938,7 +1948,7 @@ ssize_t fuse_bpf_simple_request(struct fuse_mount *fm, struct fuse_bpf_args *arg
.size = fa.out_args[i].size, \
.value = fa.out_args[i].value, \
}; \
- ext_flags = BPF_PROG_RUN(fuse_inode->bpf, &fa); \
+ ext_flags = fuse_bpf_run(fuse_inode->bpf, &fa); \
if (ext_flags < 0) { \
fer = (struct fuse_err_ret) { \
ERR_PTR(ext_flags), \