Gsoc Introduction.

Eugene Syromyatnikov evgsyr at gmail.com
Fri Mar 17 17:35:09 UTC 2017


On Fri, Mar 17, 2017 at 08:12:02AM +0700, Nikolay Marchuk wrote:
> Thank you for review. I have rewritten my code, but I still have some
> problems with NS_GET_NSTYPE parsing without additional argument. And new
> tests are not fully tested, because I haven't build kernel yet.

Please send patches inline if possible, it makes easier to review and discuss
them.

git am fails with the following diagnostics:

.git/rebase-apply/patch:268: trailing whitespace.
	
fatal: 1 line adds whitespace errors.


> From 8789c3c73f1ad0b260195a1a3214ff965d6f42d5 Mon Sep 17 00:00:00 2001
> From: Marchuk Nikolay <n1kolasM at users.noreply.github.com>
> Date: Thu, 16 Mar 2017 17:49:25 +0700
> Subject: [PATCH 1/2] Add ioctl namespace entries from Linux 4.11
> 

Please provide a change summary in the GNU change log format. Please refer to
README-hacking and
https://www.gnu.org/prep/standards/html_node/Style-of-Change-Logs.html
for details.

> Signed-off-by: Marchuk Nikolay <n1kolasM at users.noreply.github.com>

"Signed-off-by" is not used in strace project usually.

> ---
>  linux/32/ioctls_inc_align16.h | 2 ++
>  linux/32/ioctls_inc_align32.h | 2 ++
>  linux/32/ioctls_inc_align64.h | 2 ++
>  linux/64/ioctls_inc.h         | 2 ++
>  linux/x32/ioctls_inc0.h       | 2 ++
>  5 files changed, 10 insertions(+)
> 
> diff --git a/linux/32/ioctls_inc_align16.h b/linux/32/ioctls_inc_align16.h
> index 71c9d18..4e90801 100644
> --- a/linux/32/ioctls_inc_align16.h
> +++ b/linux/32/ioctls_inc_align16.h
> @@ -1455,6 +1455,8 @@
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_ALLOC_RANGE", _IOC_WRITE, 0x6e8c, 0x10 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_SUINFO", _IOC_WRITE, 0x6e8d, 0x18 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SYNC", _IOC_READ, 0x6e8a, 0x08 },
> +{ "linux/nsfs.h", "NS_GET_NSTYPE", _IOC_NONE, 0xb703, 0x00 },
> +{ "linux/nsfs.h", "NS_GET_OWNER_UID", _IOC_NONE, 0xb704, 0x00 },
>  { "linux/nsfs.h", "NS_GET_PARENT", _IOC_NONE, 0xb702, 0x00 },
>  { "linux/nsfs.h", "NS_GET_USERNS", _IOC_NONE, 0xb701, 0x00 },
>  { "linux/nvme_ioctl.h", "NVME_IOCTL_ADMIN_CMD", _IOC_READ|_IOC_WRITE, 0x4e41, 0x48 },
> diff --git a/linux/32/ioctls_inc_align32.h b/linux/32/ioctls_inc_align32.h
> index 699eb90..4fcada1 100644
> --- a/linux/32/ioctls_inc_align32.h
> +++ b/linux/32/ioctls_inc_align32.h
> @@ -1455,6 +1455,8 @@
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_ALLOC_RANGE", _IOC_WRITE, 0x6e8c, 0x10 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_SUINFO", _IOC_WRITE, 0x6e8d, 0x18 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SYNC", _IOC_READ, 0x6e8a, 0x08 },
> +{ "linux/nsfs.h", "NS_GET_NSTYPE", _IOC_NONE, 0xb703, 0x00 },
> +{ "linux/nsfs.h", "NS_GET_OWNER_UID", _IOC_NONE, 0xb704, 0x00 },
>  { "linux/nsfs.h", "NS_GET_PARENT", _IOC_NONE, 0xb702, 0x00 },
>  { "linux/nsfs.h", "NS_GET_USERNS", _IOC_NONE, 0xb701, 0x00 },
>  { "linux/nvme_ioctl.h", "NVME_IOCTL_ADMIN_CMD", _IOC_READ|_IOC_WRITE, 0x4e41, 0x48 },
> diff --git a/linux/32/ioctls_inc_align64.h b/linux/32/ioctls_inc_align64.h
> index fcd9d8c..3734082 100644
> --- a/linux/32/ioctls_inc_align64.h
> +++ b/linux/32/ioctls_inc_align64.h
> @@ -1455,6 +1455,8 @@
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_ALLOC_RANGE", _IOC_WRITE, 0x6e8c, 0x10 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_SUINFO", _IOC_WRITE, 0x6e8d, 0x18 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SYNC", _IOC_READ, 0x6e8a, 0x08 },
> +{ "linux/nsfs.h", "NS_GET_NSTYPE", _IOC_NONE, 0xb703, 0x00 },
> +{ "linux/nsfs.h", "NS_GET_OWNER_UID", _IOC_NONE, 0xb704, 0x00 },
>  { "linux/nsfs.h", "NS_GET_PARENT", _IOC_NONE, 0xb702, 0x00 },
>  { "linux/nsfs.h", "NS_GET_USERNS", _IOC_NONE, 0xb701, 0x00 },
>  { "linux/nvme_ioctl.h", "NVME_IOCTL_ADMIN_CMD", _IOC_READ|_IOC_WRITE, 0x4e41, 0x48 },
> diff --git a/linux/64/ioctls_inc.h b/linux/64/ioctls_inc.h
> index f59fe11..b75abec 100644
> --- a/linux/64/ioctls_inc.h
> +++ b/linux/64/ioctls_inc.h
> @@ -1455,6 +1455,8 @@
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_ALLOC_RANGE", _IOC_WRITE, 0x6e8c, 0x10 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_SUINFO", _IOC_WRITE, 0x6e8d, 0x18 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SYNC", _IOC_READ, 0x6e8a, 0x08 },
> +{ "linux/nsfs.h", "NS_GET_NSTYPE", _IOC_NONE, 0xb703, 0x00 },
> +{ "linux/nsfs.h", "NS_GET_OWNER_UID", _IOC_NONE, 0xb704, 0x00 },
>  { "linux/nsfs.h", "NS_GET_PARENT", _IOC_NONE, 0xb702, 0x00 },
>  { "linux/nsfs.h", "NS_GET_USERNS", _IOC_NONE, 0xb701, 0x00 },
>  { "linux/nvme_ioctl.h", "NVME_IOCTL_ADMIN_CMD", _IOC_READ|_IOC_WRITE, 0x4e41, 0x48 },
> diff --git a/linux/x32/ioctls_inc0.h b/linux/x32/ioctls_inc0.h
> index 46303d1..81dd21c 100644
> --- a/linux/x32/ioctls_inc0.h
> +++ b/linux/x32/ioctls_inc0.h
> @@ -1455,6 +1455,8 @@
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_ALLOC_RANGE", _IOC_WRITE, 0x6e8c, 0x10 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_SUINFO", _IOC_WRITE, 0x6e8d, 0x18 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SYNC", _IOC_READ, 0x6e8a, 0x08 },
> +{ "linux/nsfs.h", "NS_GET_NSTYPE", _IOC_NONE, 0xb703, 0x00 },
> +{ "linux/nsfs.h", "NS_GET_OWNER_UID", _IOC_NONE, 0xb704, 0x00 },
>  { "linux/nsfs.h", "NS_GET_PARENT", _IOC_NONE, 0xb702, 0x00 },
>  { "linux/nsfs.h", "NS_GET_USERNS", _IOC_NONE, 0xb701, 0x00 },
>  { "linux/nvme_ioctl.h", "NVME_IOCTL_ADMIN_CMD", _IOC_READ|_IOC_WRITE, 0x4e41, 0x48 },
> -- 
> 2.1.4
> 
> 
> From c07bcab35a1cfcf077a19e328dece81afeee4f6d Mon Sep 17 00:00:00 2001
> From: Marchuk Nikolay <n1kolasM at users.noreply.github.com>
> Date: Thu, 16 Mar 2017 17:52:21 +0700
> Subject: [PATCH 2/2] Implemented parser for NS_* ioctl commands.
> 
> Signed-off-by: Marchuk Nikolay <n1kolasM at users.noreply.github.com>
> ---
>  Makefile.am           |   1 +
>  configure.ac          |   1 +
>  defs.h                |   1 +
>  ioctl.c               |   4 ++
>  nsfs.c                |  85 +++++++++++++++++++++++++++++++++++++
>  tests/.gitignore      |   1 +
>  tests/Makefile.am     |   2 +
>  tests/ioctl_nsfs.c    | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/ioctl_nsfs.test |  13 ++++++
>  9 files changed, 222 insertions(+)
>  create mode 100644 nsfs.c
>  create mode 100644 tests/ioctl_nsfs.c
>  create mode 100644 tests/ioctl_nsfs.test
> 
> diff --git a/Makefile.am b/Makefile.am
> index c77f463..338fb62 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -172,6 +172,7 @@ strace_SOURCES =	\
>  	net.c		\
>  	netlink.c       \
>  	nsig.h		\
> +	nsfs.c		\
>  	numa.c		\
>  	oldstat.c	\
>  	open.c		\
> diff --git a/configure.ac b/configure.ac
> index 9e5087b..dc49fdc 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -366,6 +366,7 @@ AC_CHECK_HEADERS(m4_normalize([
>  	linux/ipc.h
>  	linux/mmtimer.h
>  	linux/msg.h
> +	linux/nsfs.h
>  	linux/perf_event.h
>  	linux/quota.h
>  	linux/seccomp.h
> diff --git a/defs.h b/defs.h
> index 793971e..0f3ec14 100644
> --- a/defs.h
> +++ b/defs.h
> @@ -640,6 +640,7 @@ name ## _ioctl(struct tcb *, unsigned int request, kernel_ulong_t arg)
>  DECL_IOCTL(dm);
>  DECL_IOCTL(file);
>  DECL_IOCTL(fs_x);
> +DECL_IOCTL(nsfs);
>  DECL_IOCTL(ptp);
>  DECL_IOCTL(scsi);
>  DECL_IOCTL(term);
> diff --git a/ioctl.c b/ioctl.c
> index aa1880f..d972c38 100644
> --- a/ioctl.c
> +++ b/ioctl.c
> @@ -280,6 +280,10 @@ ioctl_decode(struct tcb *tcp)
>  	case 0x94:
>  		return btrfs_ioctl(tcp, code, arg);
>  #endif
> +#ifdef HAVE_LINUX_NSFS_H
> +	case 0xb7:
> +		return nsfs_ioctl(tcp, code, arg);
> +#endif
>  #ifdef HAVE_LINUX_DM_IOCTL_H
>  	case 0xfd:
>  		return dm_ioctl(tcp, code, arg);
> diff --git a/nsfs.c b/nsfs.c
> new file mode 100644
> index 0000000..68c8e46
> --- /dev/null
> +++ b/nsfs.c
> @@ -0,0 +1,85 @@
> +/*
> + * Support for decoding of NS_* ioctl commands.
> + *
> + * Copyright (c) 2017 Nikolay Marchuk <marchuk.nikolay.a at gmail.com>
> + * All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + *    notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *    notice, this list of conditions and the following disclaimer in the
> + *    documentation and/or other materials provided with the distribution.
> + * 3. The name of the author may not be used to endorse or promote products
> + *    derived from this software without specific prior written permission.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
> + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
> + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
> + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + */
> +
> +#include "defs.h"
> +
> +#ifdef HAVE_LINUX_NSFS_H
> +
> +# include "xlat/setns_types.h"
> +# include <linux/ioctl.h>
> +# include <linux/nsfs.h>
> +# include <sys/types.h>
Please sort include statements and provide local ones after system ones.

The exception is inclusion of "defs.h", and "tests.h" in tests, which should be
provided first.

> +
> +/* Definitions for command which have been added later */
> +# ifndef NS_GET_NSTYPE
> +#  define NS_GET_NSTYPE		_IO(NSIO, 0x3)
> +# endif
> +# ifndef NS_GET_OWNER_UID
> +#  define NS_GET_OWNER_UID	_IO(NSIO, 0x4)
> +# endif
> +
> +int
> +nsfs_ioctl(struct tcb * tcp, unsigned int code, kernel_ulong_t arg){
Please format function declaration as following:

int
nsfs_ioctl(struct tcb *tcp, unsigned int code, kernel_ulong_t arg) {

> +	char *outstr;
> +	uid_t uid;
> +	if(entering(tcp)) {
> +		switch(code) {
Please add spaces after operator keywords, they are not function calls,
after all.

> +			case NS_GET_USERNS:
> +			case NS_GET_PARENT:
In strace project, case labels are not indented related to switch
statement (at least, in newer code).

> +				return RVAL_DECODED | (1 + RVAL_FD);
> +			case NS_GET_OWNER_UID:
> +				if (!umove(tcp, arg, &uid)) {
> +					tprintf(", ");
> +					printaddr(&uid);
> +					return RVAL_DECODED | 1;
I thought it's supposed to decode this value on exiting.

> +				}
> +			default:
> +				return 0;
> +		}
> +	} else {
> +		switch(code) {
Space after "switch".

> +			case NS_GET_NSTYPE:
Excess indentation of case statement.

> +				if (!syserror(tcp)) {
> +					outstr = xlookup(setns_types, tcp->u_rval);
> +					if (outstr) {
> +						tcp->auxstr = outstr;
> +						return RVAL_STR;
Default processing probably could be skipped here as command argument is ignored.

> +					}
> +				}
> +				return 0;
> +			case NS_GET_OWNER_UID:
> +				if (!syserror(tcp) && !umove(tcp, arg, &uid)) {
> +					printuid(", uid = ", uid);
This leads to output of both address and value at it, which doesn't correspond
to ioctl() calling convention. If you want to show that this is an indirect value,
please use square brackets, ", [val]". So, it is usually handled like this:

	if (!umove_or_printaddr(tcp, arg, &uid)) {
		printuid(", [", uid);
		tprints("]");
	}

And skipping output for this command on entering at all.

> +				}
> +			default:
> +				return 0;
> +		}
> +	}
> +}
> +#endif /* HAVE_LINUX_NSFS_H */
> diff --git a/tests/.gitignore b/tests/.gitignore
> index a7754b6..060a391 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -121,6 +121,7 @@ ioctl_loop
>  ioctl_loop-nv
>  ioctl_loop-v
>  ioctl_mtd
> +ioctl_nsfs
>  ioctl_rtc
>  ioctl_rtc-v
>  ioctl_scsi
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index c5c124c..bc0c621 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -184,6 +184,7 @@ check_PROGRAMS = \
>  	ioctl_loop-nv \
>  	ioctl_loop-v \
>  	ioctl_mtd \
> +	ioctl_nsfs \
>  	ioctl_rtc \
>  	ioctl_rtc-v \
>  	ioctl_scsi \
> @@ -593,6 +594,7 @@ DECODER_TESTS = \
>  	ioctl_loop-v.test \
>  	ioctl_loop.test \
>  	ioctl_mtd.test \
> +	ioctl_nsfs.test \
>  	ioctl_rtc-v.test \
>  	ioctl_rtc.test \
>  	ioctl_scsi.test \
> diff --git a/tests/ioctl_nsfs.c b/tests/ioctl_nsfs.c
> new file mode 100644
> index 0000000..41fe56f
> --- /dev/null
> +++ b/tests/ioctl_nsfs.c
> @@ -0,0 +1,114 @@
> +/*
> + * Check decoding of NS_* commands of ioctl syscall.
> + *
> + * Copyright (c) 2017 Nikolay Marchuk <marchuk.nikolay.a at gmail.com>
> + * All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + *    notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *    notice, this list of conditions and the following disclaimer in the
> + *    documentation and/or other materials provided with the distribution.
> + * 3. The name of the author may not be used to endorse or promote products
> + *    derived from this software without specific prior written permission.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
> + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
> + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
> + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + */
> +
> +#include "tests.h"
> +
> +#ifdef HAVE_LINUX_NSFS_H
> +
> +# include <fcntl.h>
> +# include <linux/ioctl.h>
> +# include <linux/nsfs.h>
> +# include <sched.h>
> +# include <stdio.h>
> +# include <stdlib.h>
> +# include <sys/ioctl.h>
> +# include <sys/types.h>
> +# include <sys/wait.h>
> +# include <unistd.h>
Please sort include statements.

> +
> +/* Definitions for command which have been added later */
> +# ifndef NS_GET_NSTYPE
> +#  define NS_GET_NSTYPE		_IO(NSIO, 0x3)
> +# endif
> +# ifndef NS_GET_OWNER_UID
> +#  define NS_GET_OWNER_UID	_IO(NSIO, 0x4)
> +# endif
> +
> +static void
> +test_no_namespace(void)
> +{
> +	ioctl(-1, NS_GET_USERNS);
> +	printf("ioctl(-1, NS_GET_USERNS) = -1 EBADF (%m)\n");
> +	ioctl(-1, NS_GET_PARENT);
> +	printf("ioctl(-1, NS_GET_PARENT) = -1 EBADF (%m)\n");
> +	ioctl(-1, NS_GET_NSTYPE, NULL);
> +	printf("ioctl(-1, NS_GET_NSTYPE, 0) = -1 EBADF (%m)\n");
> +	ioctl(-1, NS_GET_OWNER_UID, NULL);
> +	printf("ioctl(-1, NS_GET_OWNER_UID, NULL) = -1 EBADF (%m)\n");
> +}
> +
> +static void
> +test_user_namespace(void)
> +{
> +	int ns_fd, userns_fd, parent_ns_fd, nstype, rc;
> +	uid_t uid;
> +	unshare(CLONE_NEWUSER);
> +	ns_fd = open("/proc/self/ns/user");
This probably should be checked for success. Please look at
perror_msg_and_fail()/perror_msg_and_skip() for reporting test errors.

> +	
Trailing whitespace.

> +	userns_fd = ioctl(ns_fd, NS_GET_USERNS);
> +	printf("ioctl(%d, NS_GET_USERNS) = %s\n", ns_fd, sprintrc(userns_fd));
> +
> +	parent_ns_fd = ioctl(userns_fd, NS_GET_PARENT);
> +	printf("ioctl(%d, NS_GET_PARENT) = %s\n", userns_fd, sprintrc(parent_ns_fd));
Overly long line.

> +
> +	nstype = ioctl(userns_fd, NS_GET_NSTYPE);
> +	if (nstype == CLONE_NEWUSER) {
> +		printf("ioctl(%d, NS_GET_NSTYPE, 0) = CLONE_NEWUSER\n", userns_fd);
Overly long line.

> +	} else {
> +		printf("ioctl(%d, NS_GET_NSTYPE, 0) = %s\n", userns_fd, sprintrc(nstype));
Overly long line.

> +	}
> +
> +	rc = ioctl(userns_fd, NS_GET_OWNER_UID, &uid);
> +	if (rc == -1) {
> +		printf("ioctl(%d, NS_GET_OWNER_UID, %p) = %s\n", userns_fd, &uid, sprintrc(rc));
Overly long line.

> +	} else {
> +		printf("ioctl(%d, NS_GET_OWNER_UID, %p, uid = ", userns_fd, &uid);
Overly long line.

> +		if ((uid_t) -1U == (uid_t) uid)
> +			printf("-1) = %s\n", sprintrc(rc));
> +		else
> +			printf("%u) = %s\n", uid, sprintrc(rc));
Note that errno is clobbered here by previous printf call. Current idiom
for handling this is like the following:

	const char *errstr;

	<syscall>
	errstr = sprintrc();
	<interim code>
	printf(errstr);

> +	}
> +
> +	return 0;
> +}
> +
> +int
> +main(void)
> +{
> +	test_no_namespace();
> +	test_user_namespace();
> +	puts("+++ exited with 0 +++");
> +	return 0;
> +}
> +
> +#else /* !HAVE_LINUX_DM_IOCTL_H */
> +
> +SKIP_MAIN_UNDEFINED("HAVE_LINUX_NSFS_H")
> +
> +#endif /* HAVE_LINUX_DM_IOCTL_H */
> diff --git a/tests/ioctl_nsfs.test b/tests/ioctl_nsfs.test
> new file mode 100644
Test file access permissions should be 0755, otherwise test fails to
run:

FAIL: ioctl_nsfs
================

timeout: failed to run command `./ioctl_nsfs.test': Permission denied

> index 0000000..8fe8da5
> --- /dev/null
> +++ b/tests/ioctl_nsfs.test
> @@ -0,0 +1,13 @@
> +#!/bin/sh
> +
> +# Check decoding of NS_* ioctls.
> +
> +. "${srcdir=.}/init.sh"
> +
> +run_prog > /dev/null
> +run_strace -a16 -eioctl $args > "$EXP"
> +check_prog grep
> +grep -v '^ioctl([012],' < "$LOG" > "$OUT"
> +match_diff "$OUT" "$EXP"
> +
> +rm -f "$EXP" "$OUT"
> -- 
> 2.1.4
> 

I'm not sure how you tested it, but current upstream kernel doesn't
install nsfs.h, so most distributions miss it. In this regard, it
probably make sense to support (and test) it regardless header file
availability.

When I've tried to compile it (with nsfs.h in place), make check failed
with the following diagnostics:

ioctl_nsfs.c: In function ‘test_user_namespace’:
ioctl_nsfs.c:72:10: error: too few arguments to function ‘open’
  ns_fd = open("/proc/self/ns/user");
          ^~~~
In file included from ioctl_nsfs.c:34:0:
/usr/include/fcntl.h:181:12: note: declared here
 extern int open (const char *__file, int __oflag, ...) __nonnull ((1));
            ^~~~
ioctl_nsfs.c:98:9: warning: ‘return’ with a value, in function returning void
  return 0;
         ^
ioctl_nsfs.c:67:1: note: declared here
 test_user_namespace(void)
 ^~~~~~~~~~~~~~~~~~~
Makefile:4929: recipe for target 'ioctl_nsfs.o' failed

After fixing this compilation error, test fails with the following diagnostics:

FAIL: ioctl_nsfs
================

4c4
< ioctl(-1, NS_GET_OWNER_UID, NULL) = -1 EBADF (Bad file descriptor)
---
> ioctl(-1, NS_GET_OWNER_UID, 0) = -1 EBADF (Bad file descriptor)
7,8c7,8
< ioctl(-1, NS_GET_NSTYPE, 0) = -1 EBADF (Bad file descriptor)
< ioctl(-1, NS_GET_OWNER_UID, 0x7ffee59e122c) = -1 EBADF (Bad file descriptor)
---
> ioctl(-1, NS_GET_NSTYPE, 0x7f54473b9740) = -1 EBADF (Bad file descriptor)
> ioctl(-1, NS_GET_OWNER_UID, 0x7fff053ac08c) = -1 EBADF (Bad file descriptor)
ioctl_nsfs.test: failed test: ../strace -a16 -eioctl ./ioctl_nsfs output mismatch
FAIL ioctl_nsfs.test (exit status: 1)


> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot

> _______________________________________________
> Strace-devel mailing list
> Strace-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/strace-devel





More information about the Strace-devel mailing list