Fix old_mmap output when mmap arguments are unfetchable

* mem.c (SYS_FUNC(old_mmap)): Use umove_or_printaddr instead of umoven
to fetch mmap arguments, return RVAL_DECODED when umove_or_printaddr
fails.
* tests/old_mmap.c (main): Check it.
This commit is contained in:
Дмитрий Левин 2016-04-22 23:41:36 +00:00
parent cf52778aba
commit 3db07f11c8
3 changed files with 13 additions and 10 deletions

16
mem.c
View File

@ -96,15 +96,15 @@ SYS_FUNC(old_mmap)
long u_arg[6];
# if defined AARCH64 || defined X86_64
/* We are here only in a 32-bit personality. */
int i;
unsigned narrow_arg[6];
if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), narrow_arg) == -1)
return 0;
for (i = 0; i < 6; ++i)
u_arg[i] = (unsigned long) narrow_arg[i];
unsigned int narrow_arg[6];
if (umove_or_printaddr(tcp, tcp->u_arg[0], &narrow_arg))
return RVAL_DECODED | RVAL_HEX;
unsigned int i;
for (i = 0; i < 6; i++)
u_arg[i] = narrow_arg[i];
# else
if (umoven(tcp, tcp->u_arg[0], sizeof(u_arg), u_arg) == -1)
return 0;
if (umove_or_printaddr(tcp, tcp->u_arg[0], &u_arg))
return RVAL_DECODED | RVAL_HEX;
# endif
print_mmap(tcp, u_arg, (unsigned long) u_arg[5]);

View File

@ -51,6 +51,9 @@
int
main(void)
{
long rc = syscall(__NR_mmap, 0);
printf("mmap(NULL) = %ld %s (%m)\n", rc, errno2name());
const unsigned int args1_c[6] = {
0xdeadbeef, /* addr */
0xfacefeed, /* len */
@ -70,7 +73,7 @@ main(void)
};
void *args = tail_memdup(args1_c, sizeof(args1_c));
long rc = syscall(__NR_mmap, args);
rc = syscall(__NR_mmap, args);
printf("mmap(%#x, %u, PROT_READ|PROT_EXEC, MAP_FILE|MAP_FIXED"
", %d, %#x) = %ld %s (%m)\n",
args1_c[0], args1_c[1], args1_c[4], args1_c[5],

View File

@ -3,4 +3,4 @@
# Check decoding of "old mmap" edition of mmap syscall.
. "${srcdir=.}/init.sh"
run_strace_match_diff -e trace=mmap
run_strace_match_diff -a11 -e trace=mmap