GSoC 2017 introduction

Eugene Syromyatnikov evgsyr at gmail.com
Mon Mar 13 05:59:12 UTC 2017


On Sat, Mar 11, 2017 at 02:51:35PM +0300, Victor Krapivensky wrote:
> Removed a trailing semicolon in a macro definition in tests/xstatx.c
> and changed copyright holders of new files to "The strace developers".
> 
> Please review this one.
> 
> I've also found a possile buffer overflow bug in unwind.c. Attaching a
> separate patch.
> 
> 
> On 03/10/2017 09:59 PM, Victor Krapivensky wrote:
> >I've also added a test, so please review.

> >From 39a1edf60cefa42d9b6e8c72ba95f684ab652c53 Mon Sep 17 00:00:00 2001
> From: Victor Krapivensky <krapivenskiy.va at phystech.edu>
> Date: Thu, 9 Mar 2017 20:26:14 +0300
> Subject: [PATCH v4] Add support for statx syscall
> 

Please add change log. Please refer to README-hacking and
https://www.gnu.org/prep/standards/html_node/Style-of-Change-Logs.html
for reference.

> ---
>  Makefile.am                 |   1 +
>  linux/i386/syscallent.h     |   1 +
>  linux/x32/syscallent.h      |   3 +-
>  linux/x86_64/syscallent.h   |   1 +
>  pathtrace.c                 |   1 +
>  statx.c                     | 147 ++++++++++++++++++++++++++++++++++++++++++++
>  tests/.gitignore            |   1 +
>  tests/Makefile.am           |   2 +
>  tests/statx.c               |  63 +++++++++++++++++++
>  tests/statx.test            |   5 ++
>  tests/xstatx.c              |  88 +++++++++++++++++++++-----
>  xlat/at_statx_sync_types.in |   3 +
>  xlat/statx_attrs.in         |   6 ++
>  xlat/statx_masks.in         |  12 ++++
>  14 files changed, 319 insertions(+), 15 deletions(-)
>  create mode 100644 statx.c
>  create mode 100644 tests/statx.c
>  create mode 100755 tests/statx.test
>  create mode 100644 xlat/at_statx_sync_types.in
>  create mode 100644 xlat/statx_attrs.in
>  create mode 100644 xlat/statx_masks.in
> 
> diff --git a/Makefile.am b/Makefile.am
> index 7e837b3..e350fd2 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -232,6 +232,7 @@ strace_SOURCES =	\
>  	stat64.c	\
>  	statfs.c	\
>  	statfs.h	\
> +	statx.c		\
>  	strace.c	\
>  	swapon.c	\
>  	syscall.c	\
> diff --git a/linux/i386/syscallent.h b/linux/i386/syscallent.h
> index 8ef1b1c..84c5bde 100644
> --- a/linux/i386/syscallent.h
> +++ b/linux/i386/syscallent.h
> @@ -408,6 +408,7 @@
>  [380] = { 4,	TM|SI,		SEN(pkey_mprotect),		"pkey_mprotect"		},
>  [381] = { 2,	0,		SEN(pkey_alloc),		"pkey_alloc"		},
>  [382] = { 1,	0,		SEN(pkey_free),			"pkey_free"		},
> +[383] = { 5,	TD|TF,		SEN(statx),			"statx"			},
>  
>  #define SYS_socket_subcall	400
>  #include "subcall.h"
> diff --git a/linux/x32/syscallent.h b/linux/x32/syscallent.h
> index 2699bc0..7f4e45b 100644
> --- a/linux/x32/syscallent.h
> +++ b/linux/x32/syscallent.h
> @@ -330,7 +330,8 @@
>  [329] = { 4,	TM|SI,		SEN(pkey_mprotect),		"pkey_mprotect"		},
>  [330] = { 2,	0,		SEN(pkey_alloc),		"pkey_alloc"		},
>  [331] = { 1,	0,		SEN(pkey_free),			"pkey_free"		},
> -[332 ... 511] = { },
> +[332] = { 5,	TD|TF,		SEN(statx),			"statx"			},
> +[333 ... 511] = { },
>  /*
>   * x32-specific system call numbers start at 512 to avoid cache impact
>   * for native 64-bit operation.
> diff --git a/linux/x86_64/syscallent.h b/linux/x86_64/syscallent.h
> index a1a268e..2624947 100644
> --- a/linux/x86_64/syscallent.h
> +++ b/linux/x86_64/syscallent.h
> @@ -330,3 +330,4 @@
>  [329] = { 4,	TM|SI,		SEN(pkey_mprotect),		"pkey_mprotect"		},
>  [330] = { 2,	0,		SEN(pkey_alloc),		"pkey_alloc"		},
>  [331] = { 1,	0,		SEN(pkey_free),			"pkey_free"		},
> +[332] = { 5,	TD|TF,		SEN(statx),			"statx"			},
> diff --git a/pathtrace.c b/pathtrace.c
> index d991aed..90974f4 100644
> --- a/pathtrace.c
> +++ b/pathtrace.c
> @@ -183,6 +183,7 @@ pathtrace_match(struct tcb *tcp)
>  	case SEN_newfstatat:
>  	case SEN_openat:
>  	case SEN_readlinkat:
> +	case SEN_statx:
>  	case SEN_unlinkat:
>  	case SEN_utimensat:
>  		/* fd, path */
> diff --git a/statx.c b/statx.c
> new file mode 100644
> index 0000000..f1e8549
> --- /dev/null
> +++ b/statx.c
> @@ -0,0 +1,147 @@
> +/*
> + * Copyright (c) 2017 The strace developers.
> + * 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"
> +
> +#include <sys/stat.h>
> +#include <linux/fcntl.h>
> +
> +#include "xlat/statx_masks.h"
> +#include "xlat/statx_attrs.h"
> +#include "xlat/at_statx_sync_types.h"
> +
> +typedef struct {
> +	int64_t sec;
> +	int32_t nsec;
> +	int32_t reserved;
> +} struct_statx_timestamp;
> +
> +typedef struct {
> +	uint32_t stx_mask; /* What results were written [uncond] */
> +	uint32_t stx_blksize; /* Preferred general I/O size [uncond] */
> +	uint64_t stx_attributes; /* Flags conveying information about the file
> +	                            [uncond] */
> +
> +	uint32_t stx_nlink; /* Number of hard links */
> +	uint32_t stx_uid; /* User ID of owner */
> +	uint32_t stx_gid; /* Group ID of owner */
> +	uint16_t stx_mode; /* File mode */
> +	uint16_t reserved0[1];
> +
> +	uint64_t stx_ino; /* Inode number */
> +	uint64_t stx_size; /* File size */
> +	uint64_t stx_blocks; /* Number of 512-byte blocks allocated */
> +	uint64_t reserved1[1];
> +
> +	struct_statx_timestamp stx_atime; /* Last access time */
> +	struct_statx_timestamp stx_btime; /* File creation time */
> +	struct_statx_timestamp stx_ctime; /* Last attribute change time */
> +	struct_statx_timestamp stx_mtime; /* Last data modification time */
> +
> +	uint32_t stx_rdev_major; /* Device ID of special file [if bdev/cdev] */
> +	uint32_t stx_rdev_minor;
> +	uint32_t stx_dev_major; /* ID of device containing file [uncond] */
> +	uint32_t stx_dev_minor;
> +
> +	uint64_t reserved2[16]; /* Spare space for future expansion */
Note that current implementation has an array of 14 elements, not 16.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/stat.h#n129

(btw, corner cases for this should also be tested)

> +} struct_statx;
> +
> +SYS_FUNC(statx)
> +{
> +	if (entering(tcp)) {
> +		print_dirfd(tcp, tcp->u_arg[0]);
> +		printpath(tcp, tcp->u_arg[1]);
> +		tprints(", ");
> +		if (printflags(at_flags, tcp->u_arg[2] & ~AT_STATX_SYNC_TYPE,
statx.c:79:45: error: ‘AT_STATX_SYNC_TYPE’ undeclared (first use in this function)
statx.c:79:45: note: each undeclared identifier is reported only once for each function it appears in

> +		               NULL))
> +		{
> +			tprints("|");
> +		}
> +		printxvals(tcp->u_arg[2] & AT_STATX_SYNC_TYPE, "AT_STATX_???",
> +		           at_statx_sync_types, NULL);
> +		tprints(", ");
> +		printflags(statx_masks, tcp->u_arg[3], "STATX_???");
Btw, as a quirk of current implementation of printflags, one can put
STATX_ALL/STATX_BASIC_STATS in front of other values, thus allowing
printing of these values in case they were provided. Not sure whether it
should be exploited, though.

> +		tprints(", ");
> +	} else {
> +#define PRINT_FIELD_U(field) \
> +	tprintf(", %s=%llu", #field, (unsigned long long) stx.field)
> +
> +#define PRINT_FIELD_TIME(field)						\
> +	do {								\
> +		tprints(", " #field "=");				\
> +		tprints(sprinttime(stx.field.sec));			\
> +		if (stx.field.nsec)					\
> +			tprintf(".%09" PRId32, stx.field.nsec);		\
> +	} while (0)
> +
> +		struct_statx stx;
> +		if (umove_or_printaddr(tcp, tcp->u_arg[4], &stx)) {
> +			return 0;
> +		}
> +
> +		tprints("{stx_mask=");
> +		printflags(statx_masks, stx.stx_mask, "STATX_???");
> +
> +		if (!abbrev(tcp)) {
> +			PRINT_FIELD_U(stx_blksize);
> +		}
> +
> +		tprints(", stx_attributes=");
> +		printflags(statx_attrs, stx.stx_attributes, "STATX_ATTR_???");
> +
> +		if (!abbrev(tcp)) {
> +			PRINT_FIELD_U(stx_nlink);
> +			PRINT_FIELD_U(stx_uid);
It's probably better to use printuid helper.

> +			PRINT_FIELD_U(stx_gid);
Same.

> +		}
> +
> +		tprints(", stx_mode=");
> +		print_symbolic_mode_t(stx.stx_mode);
> +
> +		if (!abbrev(tcp)) {
> +			PRINT_FIELD_U(stx_ino);
> +		}
> +
> +		PRINT_FIELD_U(stx_size);
> +
> +		if (!abbrev(tcp)) {
> +			PRINT_FIELD_U(stx_blocks);
> +			PRINT_FIELD_TIME(stx_atime);
> +			PRINT_FIELD_TIME(stx_btime);
> +			PRINT_FIELD_TIME(stx_ctime);
> +			PRINT_FIELD_TIME(stx_mtime);
> +			PRINT_FIELD_U(stx_rdev_major);
> +			PRINT_FIELD_U(stx_rdev_minor);
> +			PRINT_FIELD_U(stx_dev_major);
> +			PRINT_FIELD_U(stx_dev_minor);
> +		} else {
> +			tprints(", ...");
> +		}
> +		tprints("}");
> +	}
> +	return 0;
> +}
> diff --git a/tests/.gitignore b/tests/.gitignore
> index 6e44e5c..e2b68bf 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -329,6 +329,7 @@ stat
>  stat64
>  statfs
>  statfs64
> +statx
>  swap
>  symlink
>  symlinkat
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 5a7a45f..85f96df 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -389,6 +389,7 @@ check_PROGRAMS = \
>  	stat64 \
>  	statfs \
>  	statfs64 \
> +	statx \
>  	swap \
>  	symlink \
>  	symlinkat \
> @@ -779,6 +780,7 @@ DECODER_TESTS = \
>  	socketcall.test \
>  	splice.test \
>  	stat.test \
> +	statx.test \
Please avoid breaking alphabetical order here.

>  	stat64.test \
>  	statfs.test \
>  	statfs64.test \
> diff --git a/tests/statx.c b/tests/statx.c
> new file mode 100644
> index 0000000..c59f733
> --- /dev/null
> +++ b/tests/statx.c
> @@ -0,0 +1,63 @@
> +/*
> + * Copyright (c) 2017 The strace developers.
> + * 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"
> +#include <asm/unistd.h>
> +#include <linux/stat.h>
> +#include "xlat.h"
> +#include "xlat/statx_masks.h"
> +#include "xlat/statx_attrs.h"
> +
> +#ifdef __NR_statx
> +
> +# define IS_STATX 1
> +# define TEST_SYSCALL_STR "statx"
> +# define STRUCT_STAT struct statx
> +# define STRUCT_STAT_STR "struct statx"
> +# define STRUCT_STAT_IS_STAT64 0
> +# define TEST_SYSCALL_INVOKE(sample, pst) \
> +	syscall(__NR_statx, AT_FDCWD, sample, 0, STATX_ALL, pst)
> +# define PRINT_SYSCALL_HEADER(sample) \
> +	do { \
> +		int saved_errno = errno; \
> +		printf("%s(AT_FDCWD, \"%s\", AT_STATX_SYNC_AS_STAT, ", \
> +		       TEST_SYSCALL_STR, sample); \
> +		printflags(statx_masks, STATX_ALL, "STATX_???"); \
> +		printf(", ");
> +# define PRINT_SYSCALL_FOOTER(rc) \
> +		errno = saved_errno; \
> +		printf(") = %s\n", sprintrc(rc)); \
> +	} while (0)
> +
> +# include "xstatx.c"
> +
> +#else
> +
> +SKIP_MAIN_UNDEFINED("__NR_statx")
> +
> +#endif
> +
> diff --git a/tests/statx.test b/tests/statx.test
> new file mode 100755
> index 0000000..a571241
> --- /dev/null
> +++ b/tests/statx.test
> @@ -0,0 +1,5 @@
> +#!/bin/sh
> +
> +# Check statx syscall decoding.
> +
> +. "${srcdir=.}/statx.sh"
> diff --git a/tests/xstatx.c b/tests/xstatx.c
> index 874f309..12d0246 100644
> --- a/tests/xstatx.c
> +++ b/tests/xstatx.c
> @@ -109,6 +109,10 @@ typedef off_t libc_off_t;
>  #  define OLD_STAT 0
>  # endif
>  
> +# ifndef IS_STATX
> +#  define IS_STATX 0
> +# endif
> +
>  static void
>  print_ftype(const unsigned int mode)
>  {
> @@ -130,6 +134,8 @@ print_perms(const unsigned int mode)
>  	printf("%#o", mode & ~S_IFMT);
>  }
>  
> +# if !IS_STATX
> +
>  static void
>  print_stat(const STRUCT_STAT *st)
>  {
> @@ -144,12 +150,12 @@ print_stat(const STRUCT_STAT *st)
>  	printf(", st_nlink=%llu", zero_extend_signed_to_ull(st->st_nlink));
>  	printf(", st_uid=%llu", zero_extend_signed_to_ull(st->st_uid));
>  	printf(", st_gid=%llu", zero_extend_signed_to_ull(st->st_gid));
> -# if OLD_STAT
> +#  if OLD_STAT
>  	printf(", st_blksize=0, st_blocks=0");
> -# else /* !OLD_STAT */
> +#  else /* !OLD_STAT */
>  	printf(", st_blksize=%llu", zero_extend_signed_to_ull(st->st_blksize));
>  	printf(", st_blocks=%llu", zero_extend_signed_to_ull(st->st_blocks));
> -# endif /* OLD_STAT */
> +#  endif /* OLD_STAT */
>  
>  	switch (st->st_mode & S_IFMT) {
>  	case S_IFCHR: case S_IFBLK:
> @@ -161,13 +167,13 @@ print_stat(const STRUCT_STAT *st)
>  		printf(", st_size=%llu", zero_extend_signed_to_ull(st->st_size));
>  	}
>  
> -# if defined(HAVE_STRUCT_STAT_ST_MTIME_NSEC) && !OLD_STAT
> -#  define TIME_NSEC(val)	zero_extend_signed_to_ull(val)
> -# else
> -#  define TIME_NSEC(val)	0
> -# endif
> +#  if defined(HAVE_STRUCT_STAT_ST_MTIME_NSEC) && !OLD_STAT
> +#   define TIME_NSEC(val)	zero_extend_signed_to_ull(val)
> +#  else
> +#   define TIME_NSEC(val)	0
> +#  endif
>  
> -# define PRINT_ST_TIME(field)						\
> +#  define PRINT_ST_TIME(field)						\
>  	printf(", st_" #field "=");					\
>  	print_time_t_nsec(sign_extend_unsigned_to_ll(st->st_ ## field),	\
>  			  TIME_NSEC(st->st_ ## field ## _nsec))
> @@ -178,6 +184,51 @@ print_stat(const STRUCT_STAT *st)
>  	printf("}");
>  }
>  
> +# else /* !IS_STATX */
> +
> +static void
> +print_stat(const STRUCT_STAT *st)
> +{
> +#  define PRINT_FIELD_U(field) \
> +	printf(", %s=%llu", #field, (unsigned long long) st->field)
> +
> +#  define PRINT_FIELD_TIME(field)				\
> +	printf(", %s=", #field);				\
> +	print_time_t_nsec(st->field.tv_sec, st->field.tv_nsec)
> +
> +	printf("{stx_mask=");
> +	printflags(statx_masks, st->stx_mask, "STATX_???");
> +
> +	PRINT_FIELD_U(stx_blksize);
> +
> +	printf(", stx_attributes=");
> +	printflags(statx_attrs, st->stx_attributes, "STATX_ATTR_???");
> +
> +	PRINT_FIELD_U(stx_nlink);
> +	PRINT_FIELD_U(stx_uid);
> +	PRINT_FIELD_U(stx_gid);
> +
> +	printf(", stx_mode=");
> +	print_ftype(st->stx_mode);
> +	printf("|");
> +	print_perms(st->stx_mode);
> +
> +	PRINT_FIELD_U(stx_ino);
> +	PRINT_FIELD_U(stx_size);
> +	PRINT_FIELD_U(stx_blocks);
> +	PRINT_FIELD_TIME(stx_atime);
> +	PRINT_FIELD_TIME(stx_btime);
> +	PRINT_FIELD_TIME(stx_ctime);
> +	PRINT_FIELD_TIME(stx_mtime);
> +	PRINT_FIELD_U(stx_rdev_major);
> +	PRINT_FIELD_U(stx_rdev_minor);
> +	PRINT_FIELD_U(stx_dev_major);
> +	PRINT_FIELD_U(stx_dev_minor);
> +	printf("}");
> +}
> +
> +# endif /* !IS_STATX */
> +
>  static int
>  create_sample(const char *fname, const libc_off_t size)
>  {
> @@ -247,18 +298,25 @@ main(void)
>  		}
>  	}
>  	(void) unlink(sample);
> +# if IS_STATX
> +#  define ST_SIZE_FIELD stx_size
> +# else
> +#  define ST_SIZE_FIELD st_size
> +# endif
>  	if (!rc && zero_extend_signed_to_ull(SAMPLE_SIZE) !=
> -	    zero_extend_signed_to_ull(st[0].st_size)) {
> +	    zero_extend_signed_to_ull(st[0].ST_SIZE_FIELD)) {
>  		fprintf(stderr, "Size mismatch: "
>  				"requested size(%llu) != st_size(%llu)\n",
>  			zero_extend_signed_to_ull(SAMPLE_SIZE),
> -			zero_extend_signed_to_ull(st[0].st_size));
> +			zero_extend_signed_to_ull(st[0].ST_SIZE_FIELD));
>  		fprintf(stderr, "The most likely reason for this is incorrect"
>  				" definition of %s.\n"
>  				"Here is some diagnostics that might help:\n",
>  			STRUCT_STAT_STR);
>  
> -#define LOG_STAT_OFFSETOF_SIZEOF(object, member)			\
> +# if !IS_STATX
> +
> +#  define LOG_STAT_OFFSETOF_SIZEOF(object, member)			\
>  		fprintf(stderr, "offsetof(%s, %s) = %zu"		\
>  				", sizeof(%s) = %zu\n",			\
>  				STRUCT_STAT_STR, #member,		\
> @@ -273,10 +331,12 @@ main(void)
>  		LOG_STAT_OFFSETOF_SIZEOF(st[0], st_gid);
>  		LOG_STAT_OFFSETOF_SIZEOF(st[0], st_rdev);
>  		LOG_STAT_OFFSETOF_SIZEOF(st[0], st_size);
> -# if !OLD_STAT
> +#  if !OLD_STAT
>  		LOG_STAT_OFFSETOF_SIZEOF(st[0], st_blksize);
>  		LOG_STAT_OFFSETOF_SIZEOF(st[0], st_blocks);
> -# endif /* !OLD_STAT */
> +#  endif /* !OLD_STAT */
> +
> +# endif /* !IS_STATX */
>  
>  		return 1;
>  	}

In case of statx, it is also important to check that flags and mask are
formatted correctly.

> diff --git a/xlat/at_statx_sync_types.in b/xlat/at_statx_sync_types.in
> new file mode 100644
> index 0000000..bc966b3
> --- /dev/null
> +++ b/xlat/at_statx_sync_types.in
> @@ -0,0 +1,3 @@
> +AT_STATX_SYNC_AS_STAT	0x0000
> +AT_STATX_FORCE_SYNC	0x2000
> +AT_STATX_DONT_SYNC	0x4000
> diff --git a/xlat/statx_attrs.in b/xlat/statx_attrs.in
> new file mode 100644
> index 0000000..f6e4078
> --- /dev/null
> +++ b/xlat/statx_attrs.in
> @@ -0,0 +1,6 @@
> +STATX_ATTR_COMPRESSED	0x00000004
> +STATX_ATTR_IMMUTABLE	0x00000010
> +STATX_ATTR_APPEND	0x00000020
> +STATX_ATTR_NODUMP	0x00000040
> +STATX_ATTR_ENCRYPTED	0x00000800
> +STATX_ATTR_AUTOMOUNT	0x00001000
> diff --git a/xlat/statx_masks.in b/xlat/statx_masks.in
> new file mode 100644
> index 0000000..0986bce
> --- /dev/null
> +++ b/xlat/statx_masks.in
> @@ -0,0 +1,12 @@
> +STATX_TYPE	0x00000001U
> +STATX_MODE	0x00000002U
> +STATX_NLINK	0x00000004U
> +STATX_UID	0x00000008U
> +STATX_GID	0x00000010U
> +STATX_ATIME	0x00000020U
> +STATX_MTIME	0x00000040U
> +STATX_CTIME	0x00000080U
> +STATX_INO	0x00000100U
> +STATX_SIZE	0x00000200U
> +STATX_BLOCKS	0x00000400U
> +STATX_BTIME	0x00000800U
> -- 
> 2.10.2
> 

> >From 6162fa2ed19bf1eb5c5a821a1453e57f3f565224 Mon Sep 17 00:00:00 2001
> From: Victor Krapivensky <krapivenskiy.va at phystech.edu>
> Date: Sat, 11 Mar 2017 14:27:33 +0300
> Subject: [PATCH v1] unwind.c: fix a possible buffer overflow
> 
> Linux does not prevent a user from creating a lot of nested directories
> with length of the absolute path of the deepest one exceeding PATH_MAX,
> then chdir'ing into it, creating a file there and mmap'ing it. Since the
> length of the prefix preceding the pathname in /proc/[pid]/maps is not
> necessary 80 (it's 73 on my machine), an overflow is possible.
> 
> * unwind.c: Fix a possible buffer overflow.
> ---
>  unwind.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/unwind.c b/unwind.c
> index 326d184..6a7f342 100644
> --- a/unwind.c
> +++ b/unwind.c
> @@ -159,7 +159,7 @@ build_mmap_cache(struct tcb* tcp)
>  		struct mmap_cache_t *entry;
>  		unsigned long start_addr, end_addr, mmap_offset;
>  		char exec_bit;
> -		char binary_path[PATH_MAX];
> +		char binary_path[sizeof(buffer)];
>  
>  		if (sscanf(buffer, "%lx-%lx %*c%*c%c%*c %lx %*x:%*x %*d %[^\n]",
>  			   &start_addr, &end_addr, &exec_bit,
> -- 
> 2.10.2
> 

> ------------------------------------------------------------------------------
> Announcing the Oxford Dictionaries API! The API offers world-renowned
> dictionary content that is easy and intuitive to access. Sign up for an
> account today to start using our lexical data to power your apps and
> projects. Get started today and enter our developer competition.
> http://sdm.link/oxford

> _______________________________________________
> 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