Re: [RFC PATCH v19 1/5] exec: Add a new AT_CHECK flag to execveat(2)
From: Mickaël Salaün
Date: Tue Jul 09 2024 - 16:42:55 EST
On Tue, Jul 09, 2024 at 12:05:50PM +0200, Florian Weimer wrote:
> * Mickaël Salaün:
>
> >> > If we want to avoid that, we could have an agreed-upon error code which
> >> > the LSM can signal that it'll never fail AT_CHECK checks, so we only
> >> > have to perform the extra system call once.
> >
> > I'm not sure to follow. Either we check executable code or we don't,
> > but it doesn't make sense to only check some parts (except for migration
> > of user space code in a system, which is one purpose of the securebits
> > added with the next patch).
> >
> > The idea with AT_CHECK is to unconditionnaly check executable right the
> > same way it is checked when a file is executed. User space can decide
> > to check that or not according to its policy (i.e. securebits).
>
> I meant it purely as a performance optimization, to skip future system
> calls if we know they won't provide any useful information for this
> process. In the grand scheme of things, the extra system call probably
> does not matter because we already have to do costly things like mmap.
Indeed, the performance impact of execveat+AT_CHECK should be negligible
compared to everything else needed to interpret a script or spawn a
process. Moreover, these checks should only be performed when
SECBIT_SHOULD_EXEC_CHECK is set for the caller.