You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(122) |
Nov
(152) |
Dec
(69) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(6) |
Feb
(25) |
Mar
(73) |
Apr
(82) |
May
(24) |
Jun
(25) |
Jul
(10) |
Aug
(11) |
Sep
(10) |
Oct
(54) |
Nov
(203) |
Dec
(182) |
| 2004 |
Jan
(307) |
Feb
(305) |
Mar
(430) |
Apr
(312) |
May
(187) |
Jun
(342) |
Jul
(487) |
Aug
(637) |
Sep
(336) |
Oct
(373) |
Nov
(441) |
Dec
(210) |
| 2005 |
Jan
(385) |
Feb
(480) |
Mar
(636) |
Apr
(544) |
May
(679) |
Jun
(625) |
Jul
(810) |
Aug
(838) |
Sep
(634) |
Oct
(521) |
Nov
(965) |
Dec
(543) |
| 2006 |
Jan
(494) |
Feb
(431) |
Mar
(546) |
Apr
(411) |
May
(406) |
Jun
(322) |
Jul
(256) |
Aug
(401) |
Sep
(345) |
Oct
(542) |
Nov
(308) |
Dec
(481) |
| 2007 |
Jan
(427) |
Feb
(326) |
Mar
(367) |
Apr
(255) |
May
(244) |
Jun
(204) |
Jul
(223) |
Aug
(231) |
Sep
(354) |
Oct
(374) |
Nov
(497) |
Dec
(362) |
| 2008 |
Jan
(322) |
Feb
(482) |
Mar
(658) |
Apr
(422) |
May
(476) |
Jun
(396) |
Jul
(455) |
Aug
(267) |
Sep
(280) |
Oct
(253) |
Nov
(232) |
Dec
(304) |
| 2009 |
Jan
(486) |
Feb
(470) |
Mar
(458) |
Apr
(423) |
May
(696) |
Jun
(461) |
Jul
(551) |
Aug
(575) |
Sep
(134) |
Oct
(110) |
Nov
(157) |
Dec
(102) |
| 2010 |
Jan
(226) |
Feb
(86) |
Mar
(147) |
Apr
(117) |
May
(107) |
Jun
(203) |
Jul
(193) |
Aug
(238) |
Sep
(300) |
Oct
(246) |
Nov
(23) |
Dec
(75) |
| 2011 |
Jan
(133) |
Feb
(195) |
Mar
(315) |
Apr
(200) |
May
(267) |
Jun
(293) |
Jul
(353) |
Aug
(237) |
Sep
(278) |
Oct
(611) |
Nov
(274) |
Dec
(260) |
| 2012 |
Jan
(303) |
Feb
(391) |
Mar
(417) |
Apr
(441) |
May
(488) |
Jun
(655) |
Jul
(590) |
Aug
(610) |
Sep
(526) |
Oct
(478) |
Nov
(359) |
Dec
(372) |
| 2013 |
Jan
(467) |
Feb
(226) |
Mar
(391) |
Apr
(281) |
May
(299) |
Jun
(252) |
Jul
(311) |
Aug
(352) |
Sep
(481) |
Oct
(571) |
Nov
(222) |
Dec
(231) |
| 2014 |
Jan
(185) |
Feb
(329) |
Mar
(245) |
Apr
(238) |
May
(281) |
Jun
(399) |
Jul
(382) |
Aug
(500) |
Sep
(579) |
Oct
(435) |
Nov
(487) |
Dec
(256) |
| 2015 |
Jan
(338) |
Feb
(357) |
Mar
(330) |
Apr
(294) |
May
(191) |
Jun
(108) |
Jul
(142) |
Aug
(261) |
Sep
(190) |
Oct
(54) |
Nov
(83) |
Dec
(22) |
| 2016 |
Jan
(49) |
Feb
(89) |
Mar
(33) |
Apr
(50) |
May
(27) |
Jun
(34) |
Jul
(53) |
Aug
(53) |
Sep
(98) |
Oct
(206) |
Nov
(93) |
Dec
(53) |
| 2017 |
Jan
(65) |
Feb
(82) |
Mar
(102) |
Apr
(86) |
May
(187) |
Jun
(67) |
Jul
(23) |
Aug
(93) |
Sep
(65) |
Oct
(45) |
Nov
(35) |
Dec
(17) |
| 2018 |
Jan
(26) |
Feb
(35) |
Mar
(38) |
Apr
(32) |
May
(8) |
Jun
(43) |
Jul
(27) |
Aug
(30) |
Sep
(43) |
Oct
(42) |
Nov
(38) |
Dec
(67) |
| 2019 |
Jan
(32) |
Feb
(37) |
Mar
(53) |
Apr
(64) |
May
(49) |
Jun
(18) |
Jul
(14) |
Aug
(53) |
Sep
(25) |
Oct
(30) |
Nov
(49) |
Dec
(31) |
| 2020 |
Jan
(87) |
Feb
(45) |
Mar
(37) |
Apr
(51) |
May
(99) |
Jun
(36) |
Jul
(11) |
Aug
(14) |
Sep
(20) |
Oct
(24) |
Nov
(40) |
Dec
(23) |
| 2021 |
Jan
(14) |
Feb
(53) |
Mar
(85) |
Apr
(15) |
May
(19) |
Jun
(3) |
Jul
(14) |
Aug
(1) |
Sep
(57) |
Oct
(73) |
Nov
(56) |
Dec
(22) |
| 2022 |
Jan
(3) |
Feb
(22) |
Mar
(6) |
Apr
(55) |
May
(46) |
Jun
(39) |
Jul
(15) |
Aug
(9) |
Sep
(11) |
Oct
(34) |
Nov
(20) |
Dec
(36) |
| 2023 |
Jan
(79) |
Feb
(41) |
Mar
(99) |
Apr
(169) |
May
(48) |
Jun
(16) |
Jul
(16) |
Aug
(57) |
Sep
(19) |
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
1
|
|
2
(2) |
3
|
4
(1) |
5
|
6
(2) |
7
|
8
|
|
9
|
10
|
11
|
12
(4) |
13
(1) |
14
(3) |
15
|
|
16
|
17
|
18
|
19
|
20
|
21
|
22
|
|
23
|
24
|
25
(1) |
26
|
27
(3) |
28
(1) |
29
|
|
30
|
|
|
|
|
|
|
|
From: Mark W. <ma...@so...> - 2019-06-06 16:20:06
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=e00335bd38c32439bb17b937ab374ca96b53a1f3 commit e00335bd38c32439bb17b937ab374ca96b53a1f3 Author: Mark Wielaard <ma...@kl...> Date: Thu May 30 00:29:58 2019 +0200 linux x86 and amd64 memory protection key syscalls. This implements minimal support for the pkey_alloc, pkey_free and pkey_mprotect syscalls. pkey_alloc will simply indicate that pkeys are not supported. pkey_free always fails. pkey_mprotect works just like mprotect if the special pkey -1 is provided. https://bugs.kde.org/show_bug.cgi?id=408091 Diff: --- NEWS | 1 + coregrind/m_syswrap/priv_syswrap-generic.h | 4 ++ coregrind/m_syswrap/priv_syswrap-linux.h | 5 +++ coregrind/m_syswrap/syswrap-amd64-linux.c | 4 ++ coregrind/m_syswrap/syswrap-generic.c | 36 ++++++++++----- coregrind/m_syswrap/syswrap-linux.c | 70 ++++++++++++++++++++++++++++++ coregrind/m_syswrap/syswrap-x86-linux.c | 3 ++ 7 files changed, 113 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index 004e677..905a868 100644 --- a/NEWS +++ b/NEWS @@ -53,6 +53,7 @@ where XXXXXX is the bug number as listed below. 407307 Intercept stpcpy also in ld.so for arm64 407764 drd cond_post_wait gets wrong (?) condition on s390x z13 system 408009 Expose rdrand and f16c even on avx if host cpu supports them +408091 Missing pkey syscalls n-i-bz Fix minor one time leaks in dhat. n-i-bz Add --run-cxx-freeres=no in outer args to avoid inner crashes. diff --git a/coregrind/m_syswrap/priv_syswrap-generic.h b/coregrind/m_syswrap/priv_syswrap-generic.h index 88530f0..3e1c8b6 100644 --- a/coregrind/m_syswrap/priv_syswrap-generic.h +++ b/coregrind/m_syswrap/priv_syswrap-generic.h @@ -106,6 +106,10 @@ extern Bool ML_(handle_auxv_open)(SyscallStatus *status, const HChar *filename, int flags); +/* Helper function for generic mprotect and linux pkey_mprotect. */ +extern void handle_sys_mprotect (ThreadId tid, SyscallStatus *status, + Addr *addr, SizeT *len, Int *prot); + DECL_TEMPLATE(generic, sys_ni_syscall); // * P -- unimplemented DECL_TEMPLATE(generic, sys_exit); DECL_TEMPLATE(generic, sys_fork); diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h index 5cf5407..2471524 100644 --- a/coregrind/m_syswrap/priv_syswrap-linux.h +++ b/coregrind/m_syswrap/priv_syswrap-linux.h @@ -299,6 +299,11 @@ DECL_TEMPLATE(linux, sys_bpf); // Linux-specific (new in Linux 4.11) DECL_TEMPLATE(linux, sys_statx); +// Linux-specific memory protection key syscalls (since Linux 4.9) +DECL_TEMPLATE(linux, sys_pkey_alloc); +DECL_TEMPLATE(linux, sys_pkey_free); +DECL_TEMPLATE(linux, sys_pkey_mprotect); + /* --------------------------------------------------------------------- Wrappers for sockets and ipc-ery. These are split into standalone procedures because x86-linux hides them inside multiplexors diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c index d4fe413..2d6b95f 100644 --- a/coregrind/m_syswrap/syswrap-amd64-linux.c +++ b/coregrind/m_syswrap/syswrap-amd64-linux.c @@ -863,6 +863,10 @@ static SyscallTableEntry syscall_table[] = { LINX_(__NR_membarrier, sys_membarrier), // 324 LINX_(__NR_copy_file_range, sys_copy_file_range), // 326 + + LINXY(__NR_pkey_mprotect, sys_pkey_mprotect), // 329 + LINX_(__NR_pkey_alloc, sys_pkey_alloc), // 330 + LINX_(__NR_pkey_free, sys_pkey_free), // 331 }; SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index 0b64919..01191f6 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -3842,12 +3842,28 @@ PRE(sys_mprotect) PRE_REG_READ3(long, "mprotect", unsigned long, addr, vki_size_t, len, unsigned long, prot); - if (!ML_(valid_client_addr)(ARG1, ARG2, tid, "mprotect")) { + Addr addr = ARG1; + SizeT len = ARG2; + Int prot = ARG3; + + handle_sys_mprotect (tid, status, &addr, &len, &prot); + + ARG1 = addr; + ARG2 = len; + ARG3 = prot; +} +/* This will be called from the generic mprotect, or the linux specific + pkey_mprotect. Pass pointers to ARG1, ARG2 and ARG3 as addr, len and prot, + they might be adjusted and have to assigned back to ARG1, ARG2 and ARG3. */ +void handle_sys_mprotect(ThreadId tid, SyscallStatus* status, + Addr *addr, SizeT *len, Int *prot) +{ + if (!ML_(valid_client_addr)(*addr, *len, tid, "mprotect")) { SET_STATUS_Failure( VKI_ENOMEM ); } #if defined(VKI_PROT_GROWSDOWN) else - if (ARG3 & (VKI_PROT_GROWSDOWN|VKI_PROT_GROWSUP)) { + if (*prot & (VKI_PROT_GROWSDOWN|VKI_PROT_GROWSUP)) { /* Deal with mprotects on growable stack areas. The critical files to understand all this are mm/mprotect.c @@ -3862,8 +3878,8 @@ PRE(sys_mprotect) The sanity check provided by the kernel is that the vma must have the VM_GROWSDOWN/VM_GROWSUP flag set as appropriate. */ - UInt grows = ARG3 & (VKI_PROT_GROWSDOWN|VKI_PROT_GROWSUP); - NSegment const *aseg = VG_(am_find_nsegment)(ARG1); + UInt grows = *prot & (VKI_PROT_GROWSDOWN|VKI_PROT_GROWSUP); + NSegment const *aseg = VG_(am_find_nsegment)(*addr); NSegment const *rseg; vg_assert(aseg); @@ -3874,10 +3890,10 @@ PRE(sys_mprotect) && rseg->kind == SkResvn && rseg->smode == SmUpper && rseg->end+1 == aseg->start) { - Addr end = ARG1 + ARG2; - ARG1 = aseg->start; - ARG2 = end - aseg->start; - ARG3 &= ~VKI_PROT_GROWSDOWN; + Addr end = *addr + *len; + *addr = aseg->start; + *len = end - aseg->start; + *prot &= ~VKI_PROT_GROWSDOWN; } else { SET_STATUS_Failure( VKI_EINVAL ); } @@ -3887,8 +3903,8 @@ PRE(sys_mprotect) && rseg->kind == SkResvn && rseg->smode == SmLower && aseg->end+1 == rseg->start) { - ARG2 = aseg->end - ARG1 + 1; - ARG3 &= ~VKI_PROT_GROWSUP; + *len = aseg->end - *addr + 1; + *prot &= ~VKI_PROT_GROWSUP; } else { SET_STATUS_Failure( VKI_EINVAL ); } diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 810ca24..5452b8d 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -12120,6 +12120,76 @@ PRE(sys_copy_file_range) } } +PRE(sys_pkey_alloc) +{ + PRINT("pkey_alloc (%lu, %lu)", ARG1, ARG2); + + PRE_REG_READ2(long, "pkey_alloc", + unsigned long, "flags", + unsigned long, "access_rights"); + + /* The kernel says: pkey_alloc() is always safe to call regardless of + whether or not the operating system supports protection keys. It can be + used in lieu of any other mechanism for detecting pkey support and will + simply fail with the error ENOSPC if the operating system has no pkey + support. + + So we simply always return ENOSPC to signal memory protection keys are + not supported under valgrind, unless there are unknown flags, then we + return EINVAL. */ + unsigned long pkey_flags = ARG1; + if (pkey_flags != 0) + SET_STATUS_Failure( VKI_EINVAL ); + else + SET_STATUS_Failure( VKI_ENOSPC ); +} + +PRE(sys_pkey_free) +{ + PRINT("pkey_free (%" FMT_REGWORD "u )", ARG1); + + PRE_REG_READ1(long, "pkey_free", + unsigned long, "pkey"); + + /* Since pkey_alloc () can never succeed, see above, freeing any pkey is + always an error. */ + SET_STATUS_Failure( VKI_EINVAL ); +} + +PRE(sys_pkey_mprotect) +{ + PRINT("sys_pkey_mprotect ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" + FMT_REGWORD "u %" FMT_REGWORD "u )", ARG1, ARG2, ARG3, ARG4); + PRE_REG_READ4(long, "pkey_mprotect", + unsigned long, addr, vki_size_t, len, unsigned long, prot, + unsigned long, pkey); + + Addr addr = ARG1; + SizeT len = ARG2; + Int prot = ARG3; + Int pkey = ARG4; + + /* Since pkey_alloc () can never succeed, see above, any pkey is + invalid. Except for -1, then pkey_mprotect acts just like mprotect. */ + if (pkey != -1) + SET_STATUS_Failure( VKI_EINVAL ); + else + handle_sys_mprotect (tid, status, &addr, &len, &prot); + + ARG1 = addr; + ARG2 = len; + ARG3 = prot; +} + +POST(sys_pkey_mprotect) +{ + Addr addr = ARG1; + SizeT len = ARG2; + Int prot = ARG3; + + ML_(notify_core_and_tool_of_mprotect)(addr, len, prot); +} + #undef PRE #undef POST diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c index ad54cf6..3829fa4 100644 --- a/coregrind/m_syswrap/syswrap-x86-linux.c +++ b/coregrind/m_syswrap/syswrap-x86-linux.c @@ -1608,6 +1608,9 @@ static SyscallTableEntry syscall_table[] = { LINX_(__NR_copy_file_range, sys_copy_file_range), // 377 + LINXY(__NR_pkey_mprotect, sys_pkey_mprotect), // 380 + LINX_(__NR_pkey_alloc, sys_pkey_alloc), // 381 + LINX_(__NR_pkey_free, sys_pkey_free), // 382 LINXY(__NR_statx, sys_statx), // 383 /* Explicitly not supported on i386 yet. */ |
|
From: Pawel V. <paw...@gm...> - 2019-06-06 13:05:04
|
Hello! One of the ways that I'm using valgrind is in automated test suite, if any errors were reported by valgrind, the test is marked as failed. I recently added --track-fds to the set of options, to track unclosed files. I obviously had to make the test application close 0/1/2 at exit, so they are not reported. However, I also found that there was a file descriptor 3, which pointed to the valgrind log file, as was specified with the --log-file option. I had to make the application close pretty much all file descriptors with ID>2 in the beginning to have a proper test. I think that at the minimum, it'd be great if whatever file descriptors valgrind opened, were opened with O_CLOEXEC/FD_CLOEXEC, I think it can also be reasonable to not flag a situation as an error, if the descriptors that were left unclosed, were inherited. Since the application is not necessarily aware of such descriptors, and should not be held responsible for closing them. Thank you, Pawel. |