Android-specific prctl

Dmitry V. Levin ldv at altlinux.org
Sat Jul 25 10:13:08 UTC 2015


On Fri, Jul 24, 2015 at 09:17:59PM -0700, enh wrote:
> Android kernels have an extra prctl that lets us set a name for an
> anonymous VMA, which is useful for debugging. at the moment strace
> shows it like this:
> 
> prctl(0x53564d41 /* PR_??? */, 0, 0x7f7ab0e000, 0x2000, 0x7f7aaf76d0) = 0
> prctl(0x53564d41 /* PR_??? */, 0, 0x7f7ab0d000, 0x1000, 0x7f7aaf76e8) = 0
> 
> with this patch:
> 
> diff --git a/prctl.c b/prctl.c
> index 4a6bd25..e43569c 100644
> --- a/prctl.c
> +++ b/prctl.c
> @@ -94,6 +94,22 @@ prctl_enter(struct tcb *tcp)
>  		printstr(tcp, tcp->u_arg[1], TASK_COMM_LEN);
>  		break;
> 
> +#define PR_SET_VMA   0x53564d41
> +#define PR_SET_VMA_ANON_NAME    0

If there is a chance of these constants being defined in system headers
some day, please wrap these definitions in ifdefs.

> +	case PR_SET_VMA:
> +		if (tcp->u_arg[1] == PR_SET_VMA_ANON_NAME) {
> +			tprintf(", %lu", tcp->u_arg[1]);
> +			tprintf(", %#lx", tcp->u_arg[2]);
> +			tprintf(", %lu, ", tcp->u_arg[3]);
> +			printstr(tcp, tcp->u_arg[4], -1);
> +		} else {
> +			// There are no other sub-options now, but there
> +			// might be in future...
> +			for (i = 1; i < tcp->s_ent->nargs; i++)
> +				tprintf(", %#lx", tcp->u_arg[i]);

Starting with commit v4.10-259-g3691562, this loop should be replaced with

			print_prctl_args(tcp, 1);

> +		}
> +		break;
> +
>  	case PR_SET_MM:
>  		tprints(", ");
>  		printxval(pr_set_mm, tcp->u_arg[1], "PR_SET_MM_???");
> 
> we get this instead:
> 
> prctl(0x53564d41 /* PR_??? */, 0, 0x7f7ffe0000, 8192, "thread signal stack") = 0
> prctl(0x53564d41 /* PR_??? */, 0, 0x7f7ffdf000, 4096, "thread signal
> stack guard page") = 0
> 
> obviously i could change the xlat prctl_options.in file to add
> PR_SET_VMA, but this isn't in upstream kernels so that seems wrong.

Agreed.

> i can easily keep the patch above and/or the one that touches the xlat
> file in our tree, but i thought i'd ask what -- if anything -- of this
> you'd be interested in having in upstream strace.

I think this change would be OK for upstream strace.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20150725/856ced4e/attachment.bin>


More information about the Strace-devel mailing list