]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add fd_allowed check to fstat (sys_newfstat)
authorMark Wielaard <mark@klomp.org>
Wed, 3 Sep 2025 17:20:24 +0000 (19:20 +0200)
committerMark Wielaard <mark@klomp.org>
Wed, 3 Sep 2025 17:20:28 +0000 (19:20 +0200)
Makes sure that with --track-fds fstat is also checked.

coregrind/m_syswrap/syswrap-generic.c

index c8c421c95f29d8f50797813f6d1fed461ca74abb..ce4c11c26c440153d4affb91bb09040885a02559 100644 (file)
@@ -3865,6 +3865,8 @@ PRE(sys_newfstat)
    PRINT("sys_newfstat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1, ARG2);
    PRE_REG_READ2(long, "fstat", unsigned int, fd, struct stat *, buf);
    PRE_MEM_WRITE( "fstat(buf)", ARG2, sizeof(struct vki_stat) );
+   if ( !ML_(fd_allowed)(ARG1, "fstat", tid, False) )
+      SET_STATUS_Failure( VKI_EBADF );
 }
 
 POST(sys_newfstat)