[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CA+khW7h=Ykav0c=vZQTMeVumxgNwq-pRgko1VTk4wjzCVnxHFA@mail.gmail.com>
Date: Tue, 15 Mar 2022 12:47:54 -0700
From: Hao Luo <haoluo@...gle.com>
To: Al Viro <viro@...iv.linux.org.uk>
Cc: Alexei Starovoitov <ast@...nel.org>,
Andrii Nakryiko <andrii@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
KP Singh <kpsingh@...nel.org>,
Shakeel Butt <shakeelb@...gle.com>,
Joe Burton <jevburton.kernel@...il.com>,
Tejun Heo <tj@...nel.org>, joshdon@...gle.com, sdf@...gle.com,
bpf@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH bpf-next v1 1/9] bpf: Add mkdir, rmdir, unlink syscalls
for prog_bpf_syscall
On Tue, Mar 15, 2022 at 12:02 PM Al Viro <viro@...iv.linux.org.uk> wrote:
>
> On Tue, Mar 15, 2022 at 10:27:39AM -0700, Hao Luo wrote:
>
> > Option 1: We can put restrictions on the pathname passed into this
> > helper. We can explicitly require the parameter dirfd to be in bpffs
> > (we can verify). In addition, we check pathname to be not containing
> > any dot or dotdot, so the resolved path will end up inside bpffs,
> > therefore won't take ->i_rwsem that is in the callchain of
> > cgroup_mkdir().
>
> Won't be enough - mount --bind the parent under itself and there you go...
> Sure, you could prohibit mountpoint crossing, etc., but at that point
> I'd question the usefulness of pathname resolution in the first place.
[Apologies for resend, my response did not get delivered to mail list]
I don't see a use case where we need to bind mount the directories in
bpffs, right now. So in option 1, we can also prohibit mountpoint
crossing.
Pathname resolution is still useful in this case. Imagine we want to
put all the created dirs under a base dir, we can open the base dir
and reuse its fd for multiple mkdirs, for example:
Userspace:
fd = openat(..., "/sys/fs/bpf", ...);
pass fd to the bpf prog
bpf prog:
bpf_mkdirat(fd, "common1", ...);
bpf_mkdirat(fd, "common1/a", ...);
bpf_mkdirat(fd, "common1/b", ...);
bpf_mkdirat(fd, "common2", ...);
...
It would be very inconvenient if we can't resolve multi-level paths.
As Alexei said, another option is to delegate syscall to a worker
thread. IMHO, we could do that in future if we find there is a need
for the full feature of pathname resolution.
Al, does that sound good?
Powered by blists - more mailing lists