Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring/bpf_filter: allow filtering on contents of struct open_how

This adds custom filtering for IORING_OP_OPENAT and IORING_OP_OPENAT2,
where the open_how flags, mode, and resolve can be checked by filters.

Signed-off-by: Jens Axboe <axboe@kernel.dk>

+23
+5
include/uapi/linux/io_uring/bpf_filter.h
··· 22 22 __u32 type; 23 23 __u32 protocol; 24 24 } socket; 25 + struct { 26 + __u64 flags; 27 + __u64 mode; 28 + __u64 resolve; 29 + } open; 25 30 }; 26 31 }; 27 32
+6
io_uring/bpf_filter.c
··· 12 12 #include "io_uring.h" 13 13 #include "bpf_filter.h" 14 14 #include "net.h" 15 + #include "openclose.h" 15 16 16 17 struct io_bpf_filter { 17 18 struct bpf_prog *prog; ··· 40 39 case IORING_OP_SOCKET: 41 40 bctx->pdu_size = sizeof(bctx->socket); 42 41 io_socket_bpf_populate(bctx, req); 42 + break; 43 + case IORING_OP_OPENAT: 44 + case IORING_OP_OPENAT2: 45 + bctx->pdu_size = sizeof(bctx->open); 46 + io_openat_bpf_populate(bctx, req); 43 47 break; 44 48 } 45 49 }
+9
io_uring/openclose.c
··· 85 85 return 0; 86 86 } 87 87 88 + void io_openat_bpf_populate(struct io_uring_bpf_ctx *bctx, struct io_kiocb *req) 89 + { 90 + struct io_open *open = io_kiocb_to_cmd(req, struct io_open); 91 + 92 + bctx->open.flags = open->how.flags; 93 + bctx->open.mode = open->how.mode; 94 + bctx->open.resolve = open->how.resolve; 95 + } 96 + 88 97 int io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) 89 98 { 90 99 struct io_open *open = io_kiocb_to_cmd(req, struct io_open);
+3
io_uring/openclose.h
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 3 + #include "bpf_filter.h" 4 + 3 5 int __io_close_fixed(struct io_ring_ctx *ctx, unsigned int issue_flags, 4 6 unsigned int offset); 5 7 6 8 int io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe); 7 9 int io_openat(struct io_kiocb *req, unsigned int issue_flags); 8 10 void io_open_cleanup(struct io_kiocb *req); 11 + void io_openat_bpf_populate(struct io_uring_bpf_ctx *bctx, struct io_kiocb *req); 9 12 10 13 int io_openat2_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe); 11 14 int io_openat2(struct io_kiocb *req, unsigned int issue_flags);