From db8daf1fd5606658baaf9382696938293680e706 Mon Sep 17 00:00:00 2001 From: Cody Santing Date: Tue, 12 Jul 2016 15:50:03 -0400 Subject: [PATCH] PR19489: Update send syscalls to use buffer_quoted tapset/linux/nd_syscalls2.stp: send and sendto use new user_buffer_quoted function tapset/linnux/syscalls2.stp: send and sendto use new user_buffer_quoted function testsuite/systemtap.syscall/send.c: Update expected output of testcases testsuite/systemtap.syscall/sendto.c:Update expected output of test cases --- tapset/linux/nd_syscalls2.stp | 7 +++--- tapset/linux/syscalls2.stp | 7 +++--- testsuite/systemtap.syscall/send.c | 22 +++++++++++++----- testsuite/systemtap.syscall/sendto.c | 34 ++++++++++++++++++++-------- 4 files changed, 49 insertions(+), 21 deletions(-) diff --git a/tapset/linux/nd_syscalls2.stp b/tapset/linux/nd_syscalls2.stp index c46347ee6..60b457e13 100644 --- a/tapset/linux/nd_syscalls2.stp +++ b/tapset/linux/nd_syscalls2.stp @@ -2680,7 +2680,8 @@ probe nd_syscall.send = __nd_syscall.send ?, __nd_syscall.socketcall.send ?, { name = "send" flags_str = _msg_flags_str(flags) - argstr = sprintf("%d, %p, %u, %s", s, buf_uaddr, len, flags_str) + buf = user_buffer_quoted(buf_uaddr, len, syscall_string_trunc) + argstr = sprintf("%d, %s, %u, %s", s, buf, len, flags_str) } probe __nd_syscall.send = kprobe.function("sys_send") ? { @@ -2959,8 +2960,8 @@ probe nd_syscall.sendto = __nd_syscall.sendto ?, { name = "sendto" flags_str = _msg_flags_str(flags) - argstr = sprintf("%d, %p, %u, %s, %s, %u", s, buf_uaddr, - len, flags_str, + buf = user_buffer_quoted(buf_uaddr, len, syscall_string_trunc) + argstr = sprintf("%d, %s, %u, %s, %s, %u", s, buf, len, flags_str, _struct_sockaddr_u(to_uaddr, tolen), tolen) } probe __nd_syscall.sendto = kprobe.function("sys_sendto").call ? diff --git a/tapset/linux/syscalls2.stp b/tapset/linux/syscalls2.stp index 064647d37..32fdf0b6b 100644 --- a/tapset/linux/syscalls2.stp +++ b/tapset/linux/syscalls2.stp @@ -2585,7 +2585,8 @@ probe syscall.send = __syscall.send ?, __syscall.socketcall.send ?, { name = "send" flags_str = _msg_flags_str(flags) - argstr = sprintf("%d, %p, %u, %s", s, buf_uaddr, len, flags_str) + buf = user_buffer_quoted(buf_uaddr, len, syscall_string_trunc) + argstr = sprintf("%d, %s, %u, %s", s, buf, len, flags_str) } probe __syscall.send = kernel.function("sys_send").call ? { @@ -2842,8 +2843,8 @@ probe syscall.sendto = __syscall.sendto ?, __syscall.socketcall.sendto ?, { name = "sendto" flags_str = _msg_flags_str(flags) - argstr = sprintf("%d, %p, %u, %s, %s, %u", s, buf_uaddr, - len, flags_str, + buf = user_buffer_quoted(buf_uaddr, len, syscall_string_trunc) + argstr = sprintf("%d, %s, %u, %s, %s, %u", s, buf, len, flags_str, _struct_sockaddr_u(to_uaddr, tolen), tolen) } probe __syscall.sendto = kernel.function("sys_sendto").call ? diff --git a/testsuite/systemtap.syscall/send.c b/testsuite/systemtap.syscall/send.c index b414c0f60..12bcf12a2 100644 --- a/testsuite/systemtap.syscall/send.c +++ b/testsuite/systemtap.syscall/send.c @@ -110,11 +110,15 @@ int main() fd_null = open("/dev/null", O_WRONLY); + memset(buf, 'a', sizeof(buf)); + send(-1, buf, sizeof(buf), 0); - //staptest// send[[[[to]]]]? (-1, XXXX, 1024, 0x0[[[[, NULL, 0]]]]?) = -NNNN (EBADF) + //staptest// send[[[[to]]]]? (-1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"..., 1024, 0x0[[[[, NULL, 0]]]]?) = -NNNN (EBADF) + + memset(buf, 'b', sizeof(buf)); send(fd_null, buf, sizeof(buf), MSG_DONTWAIT); - //staptest// send[[[[to]]]]? (NNNN, XXXX, 1024, MSG_DONTWAIT[[[[, NULL, 0]]]]?) = -NNNN (ENOTSOCK) + //staptest// send[[[[to]]]]? (NNNN, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"..., 1024, MSG_DONTWAIT[[[[, NULL, 0]]]]?) = -NNNN (ENOTSOCK) s = socket(PF_INET, SOCK_DGRAM, 0); //staptest// socket (PF_INET, SOCK_DGRAM, IPPROTO_IP) = NNNN @@ -122,6 +126,8 @@ int main() connect(s, (struct sockaddr *)&sin1, sizeof(sin1)); //staptest// connect (NNNN, {AF_INET, 0.0.0.0, NNNN}, 16) = 0 + memset(buf, 'c', sizeof(buf)); + send(s, (void *)-1, sizeof(buf), 0); #ifdef __s390__ //staptest// send[[[[to]]]]? (NNNN, 0x[7]?[f]+, 1024, 0x0[[[[, NULL, 0]]]]?) = -NNNN (EFAULT) @@ -131,9 +137,9 @@ int main() send(s, (void *)buf, -1, 0); #if __WORDSIZE == 64 - //staptest// send[[[[to]]]]? (NNNN, XXXX, 18446744073709551615, 0x0[[[[, NULL, 0]]]]?) = -NNNN + //staptest// send[[[[to]]]]? (NNNN, "ccccccccccccccccccccccccccccccccccccccccccccc"..., 18446744073709551615, 0x0[[[[, NULL, 0]]]]?) = -NNNN #else - //staptest// send[[[[to]]]]? (NNNN, XXXX, 4294967295, 0x0[[[[, NULL, 0]]]]?) = -NNNN + //staptest// send[[[[to]]]]? (NNNN, "ccccccccccccccccccccccccccccccccccccccccccccc"..., 4294967295, 0x0[[[[, NULL, 0]]]]?) = -NNNN #endif close(s); @@ -145,12 +151,16 @@ int main() connect(s, (struct sockaddr *)&sin1, sizeof(sin1)); //staptest// connect (NNNN, {AF_INET, 0.0.0.0, NNNN}, 16) = 0 + memset(buf, 'd', sizeof(buf)); + send(s, buf, sizeof(buf), MSG_DONTWAIT); - //staptest// send[[[[to]]]]? (NNNN, XXXX, 1024, MSG_DONTWAIT[[[[, NULL, 0]]]]?) = 1024 + //staptest// send[[[[to]]]]? (NNNN, "ddddddddddddddddddddddddddddddddddddddddddddd"..., 1024, MSG_DONTWAIT[[[[, NULL, 0]]]]?) = 1024 + + memset(buf, 'e', sizeof(buf)); // Ignore the return value on this send() call. send(s, buf, sizeof(buf), -1); - //staptest// send[[[[to]]]]? (NNNN, XXXX, 1024, MSG_[^ ]+[[[[|XXXX, NULL, 0]]]]?) + //staptest// send[[[[to]]]]? (NNNN, "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"..., 1024, MSG_[^ ]+[[[[|XXXX, NULL, 0]]]]?) close(s); //staptest// close (NNNN) = 0 diff --git a/testsuite/systemtap.syscall/sendto.c b/testsuite/systemtap.syscall/sendto.c index 4adefec64..44a8a5c0a 100644 --- a/testsuite/systemtap.syscall/sendto.c +++ b/testsuite/systemtap.syscall/sendto.c @@ -106,11 +106,15 @@ int main() fd_null = open("/dev/null", O_WRONLY); + memset(buf, 'a', sizeof(buf)); + sendto(-1, buf, sizeof(buf), 0, NULL, 0); - //staptest// sendto (-1, XXXX, 1024, 0x0, NULL, 0) = -NNNN (EBADF) + //staptest// sendto (-1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"..., 1024, 0x0, NULL, 0) = -NNNN (EBADF) + + memset(buf, 'b', sizeof(buf)); sendto(fd_null, buf, sizeof(buf), MSG_DONTWAIT, NULL, 0); - //staptest// sendto (NNNN, XXXX, 1024, MSG_DONTWAIT, NULL, 0) = -NNNN (ENOTSOCK) + //staptest// sendto (NNNN, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"..., 1024, MSG_DONTWAIT, NULL, 0) = -NNNN (ENOTSOCK) s = socket(PF_INET, SOCK_DGRAM, 0); //staptest// socket (PF_INET, SOCK_DGRAM, IPPROTO_IP) = NNNN @@ -118,19 +122,23 @@ int main() connect(s, (struct sockaddr *)&sin1, sizeof(sin1)); //staptest// connect (NNNN, {AF_INET, 0.0.0.0, NNNN}, 16) = 0 + memset(buf, 'c', sizeof(buf)); + sendto(s, (void *)buf, sizeof(buf), MSG_OOB, (struct sockaddr *)&sin1, sizeof(sin1)); - //staptest// sendto (NNNN, XXXX, 1024, MSG_OOB, {AF_INET, 0.0.0.0, NNNN}, 16) = -NNNN (EOPNOTSUPP) + //staptest// sendto (NNNN, "ccccccccccccccccccccccccccccccccccccccccccccc"..., 1024, MSG_OOB, {AF_INET, 0.0.0.0, NNNN}, 16) = -NNNN (EOPNOTSUPP) sendto(s, (void *)-1, sizeof(buf), 0, (struct sockaddr *)&sin1, sizeof(sin1)); //staptest// sendto (NNNN, 0x[f]+, 1024, 0x0, {AF_INET, 0.0.0.0, NNNN}, 16) = -NNNN (EFAULT) + memset(buf, 'd', sizeof(buf)); + sendto(s, (void *)buf, -1, 0, (struct sockaddr *)&sin1, sizeof(sin1)); #if __WORDSIZE == 64 - //staptest// sendto (NNNN, XXXX, 18446744073709551615, 0x0, {AF_INET, 0.0.0.0, NNNN}, 16) = -NNNN + //staptest// sendto (NNNN, "ddddddddddddddddddddddddddddddddddddddddddddd"..., 18446744073709551615, 0x0, {AF_INET, 0.0.0.0, NNNN}, 16) = -NNNN #else - //staptest// sendto (NNNN, XXXX, 4294967295, 0x0, {AF_INET, 0.0.0.0, NNNN}, 16) = -NNNN + //staptest// sendto (NNNN, "ddddddddddddddddddddddddddddddddddddddddddddd"..., 4294967295, 0x0, {AF_INET, 0.0.0.0, NNNN}, 16) = -NNNN #endif close(s); @@ -142,14 +150,22 @@ int main() connect(s, (struct sockaddr *)&sin1, sizeof(sin1)); //staptest// connect (NNNN, {AF_INET, 0.0.0.0, NNNN}, 16) = 0 + memset(buf, 'e', sizeof(buf)); + sendto(s, buf, sizeof(buf), 0, (struct sockaddr *)&sin1, sizeof(sin1)); - //staptest// sendto (NNNN, XXXX, 1024, 0x0, {AF_INET, 0.0.0.0, NNNN}, 16) = 1024 + //staptest// sendto (NNNN, "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"..., 1024, 0x0, {AF_INET, 0.0.0.0, NNNN}, 16) = 1024 + + memset(buf, 'f', sizeof(buf)); sendto(s, buf, sizeof(buf), 0, (struct sockaddr *)&sin1, -1); - //staptest// sendto (NNNN, XXXX, 1024, 0x0, {unknown .+}, 4294967295) = -NNNN (EINVAL) + //staptest// sendto (NNNN, "fffffffffffffffffffffffffffffffffffffffffffff"..., 1024, 0x0, {unknown .+}, 4294967295) = -NNNN (EINVAL) + + memset(buf, 'g', sizeof(buf)); sendto(s, buf, sizeof(buf), 0, (struct sockaddr *)-1, sizeof(sin1)); - //staptest// sendto (NNNN, XXXX, 1024, 0x0, {\.\.\.}, 16) = -NNNN (EFAULT) + //staptest// sendto (NNNN, "ggggggggggggggggggggggggggggggggggggggggggggg"..., 1024, 0x0, {\.\.\.}, 16) = -NNNN (EFAULT) + + memset(buf, 'h', sizeof(buf)); // Ignore the return value on this sendto() call. Note that on a // 32-bit kernel (i686 for instance), MAXSTRINGLEN is only @@ -157,7 +173,7 @@ int main() // will cause argstr to get too big. So, we'll make the end of the // arguments optional. sendto(s, buf, sizeof(buf), -1, (struct sockaddr *)&sin1, sizeof(sin1)); - //staptest// sendto (NNNN, XXXX, 1024, MSG_[^ ]+[[[[|XXXX, {AF_INET, 0.0.0.0, NNNN}, 16]]]]?) = NNNN + //staptest// sendto (NNNN, "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"..., 1024, MSG_[^ ]+[[[[|XXXX, {AF_INET, 0.0.0.0, NNNN}, 16]]]]?) = NNNN close(s); //staptest// close (NNNN) = 0 -- 2.43.5