Proposing SELinux support in strace

Dmitry V. Levin ldv at altlinux.org
Mon Mar 15 22:34:15 UTC 2021


On Mon, Mar 15, 2021 at 06:09:34PM +0100, Renaud Métrich wrote:
[...]
> > @@ -896,6 +922,13 @@ alloctcb(int pid)
> >>   			tcp->pid = pid;
> >>   #if SUPPORTED_PERSONALITIES > 1
> >>   			tcp->currpers = current_personality;
> >> +#endif
> >> +#ifdef USE_SELINUX
> >> +#ifndef AT_FDCWD
> >> +# define AT_FDCWD>------100
> >> +#endif
> > What is this? :)
> Well, that was defined multiple times in the pre 5.11 sources. I removed 
> this right now.

Anyway, "# define AT_FDCWD>------100" is not quite preprocessor-friendly.

> >> @@ -3220,6 +3275,9 @@ next_event(void)
> >>   			if (!tcp)
> >>   				goto next_event_wait_next;
> >>   		}
> >> +#ifdef USE_SELINUX
> >> +		tcp->dirfd = AT_FDCWD;
> >> +#endif
> >>   
> >>   		if (cflag) {
> >>   			tcp->stime.tv_sec = ru.ru_stime.tv_sec;
> > I'm not sure this is the most optimal place to reset tcp->last_dirfd.
> > For example, if you want to assign it on entering syscall and use it on
> > exiting (e.g. in case of getdents below), this is not the right place
> > to reset it.
> Actually this has to be done in trace_syscall() upon entering the syscall.

I'd suggest syscall_exiting_finish() for that kind of resets.


-- 
ldv


More information about the Strace-devel mailing list