[PATCH v1] [GSoC Microproject] Implement -e trace=%id option

Dmitry V. Levin ldv at altlinux.org
Fri Apr 5 00:25:18 UTC 2019


On Thu, Mar 28, 2019 at 11:14:05PM +0800, Daniel Lim Wee Soong wrote:
> Add a syscall class covering all dealing with uid/gid
> 
> Files in linux/*/syscallent*.h are updated by:
>     sed -i -E -e '/uid|gid|sid|pgrp|groups/ s/0(,[[:space:]]*SEN)/TID\1/' \
>         -e '/uid|gid|sid|pgrp|groups/ s/NF,/NF|TID,/' \
> 	-e 's/(PU\|NF\|TID,)[[:space:]]/\1/' linux/*/syscallent*.h

Thanks.  I don't think you really want to include *pgid, *pgrp, and setsid
syscalls into the list, but you are going in the right direction.

> diff --git a/basic_filters.c b/basic_filters.c
> index 5f691eae..978e8a2e 100644
> --- a/basic_filters.c
> +++ b/basic_filters.c
> @@ -164,6 +164,7 @@ lookup_class(const char *s)
>  		{ "%fstatfs",	TRACE_FSTATFS	},
>  		{ "%%statfs",	TRACE_STATFS_LIKE	},
>  		{ "%pure",	TRACE_PURE	},
> +		{ "%id", TRACE_ID },
>  		/* legacy class names */
>  		{ "desc",	TRACE_DESC	},
>  		{ "file",	TRACE_FILE	},

There are so many identifiers that %id looks too ambiguous.
I think it should either be %ugid or two separate classes (%uid and %gid).

> diff --git a/strace.1.in b/strace.1.in
> index 76a74119..b77d7658 100644
> --- a/strace.1.in
> +++ b/strace.1.in
> @@ -550,6 +550,19 @@ Currently, this list includes
>  .BR metag_get_tls "(2)"
>  syscalls.
>  .TP
> +.BR "\-e\ trace" = %id
> +Trace syscalls dealing with uid/gid.
> +Currently, this list includes
> +.BR geteuid "(0), " getegid "(0)" getgid "(0), " getgroups "(2),"
> +.BR getpgid "(1), " getresgid "(3), " getresuid "(3), " getsid "(1),"
> +.BR getuid "(0), " setfsgid "(1), " setfsuid "(1), " setgid "(1),"
> +.BR setgroups "(2), " setpgid "(2), " setregid "(2), " setresgid "(3),"
> +.BR setresuid "(3), " setreuid "(2), setsid "(0), " " setuid "(1)"
> +(on architectures other than x86),
> +.BR getpgrp "(0), " getxgid "(0), " getxuid "(0)"
> +syscalls,
> +and variants of the above (e.g. setresuid32, osf_alt_setsid),
> +.TP

Process group id and session id have nothing to do with group id.
Please re-check the list of syscalls.

> diff --git a/sysent_shorthand_defs.h b/sysent_shorthand_defs.h
> index 009f9a4b..b8666d72 100644
> --- a/sysent_shorthand_defs.h
> +++ b/sysent_shorthand_defs.h
> @@ -51,6 +51,7 @@
>  # define SI	MEMORY_MAPPING_CHANGE
>  # define SE	STACKTRACE_CAPTURE_ON_ENTER
>  # define CST	COMPAT_SYSCALL_TYPES
> +# define TID TRACE_ID
>  /* SEN(a) is defined elsewhere */
>  
>  #endif

This is not enough.  There is another branch in sysent_shorthand_defs.h
that needs to have a definition of TID, otherwise the test suite won't
compile with the following diagnostics:

In file included from ../../tests/ksysent.c:20:
../../linux/x86_64/syscallent.h:110:20: error: 'TID' undeclared here (not in a function); did you mean 'TD'?
 [102] = { 0, PU|NF|TID, SEN(getuid),   "getuid"  },


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20190405/01465a82/attachment.bin>


More information about the Strace-devel mailing list