Re: [RFC PATCH 7/9] lsm,io_uring: add LSM hooks to io_uring

Paul Moore
2021-05-26T20:45:52Z

On Wed, May 26, 2021 at 10:48 AM Stefan Metzmacher <metze@samba.org> wrote:
>
> Hi Paul,

Hi Stefan.

> > #define CREATE_TRACE_POINTS
> > #include <trace/events/io_uring.h>
> > @@ -6537,6 +6538,11 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
> > if (!req->work.creds)
> > return -EINVAL;
> > get_cred(req->work.creds);
> > + ret = security_uring_override_creds(req->work.creds);
> > + if (ret) {
> > + put_cred(req->work.creds);
> > + return ret;
> > + }
>
> Why are you calling this per requests, shouldn't this be done in
> io_register_personality()?

Generally speaking it is more interesting to see when user alice tries
to impersonate bob and not when bob registers his ID as available to
use by others. We could always add a LSM hook to control when bob
registers his ID, but I think the impersonation is the critical code
path.

However, if I'm misunderstanding how this works in io_uring please correct me.

> I'm also not sure if this really gains anything as io_register_personality()
> only captures the value of get_current_cred(), so the process already has changed to
> the credentials (at least once for the io_uring_register(IORING_REGISTER_PERSONALITY)
> call).
>
> metze

--
paul moore