]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 498317 - FdBadUse is not a valid CoreError type in a suppression even though...
authorPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 7 Jan 2025 07:05:20 +0000 (08:05 +0100)
committerMark Wielaard <mark@klomp.org>
Sun, 12 Jan 2025 22:43:14 +0000 (23:43 +0100)
https://bugs.kde.org/show_bug.cgi?id=498317

(cherry picked from commit 47bdc4a6f3de8e2071561d349fdd5f830388c489)

.gitignore
NEWS
coregrind/m_errormgr.c
coregrind/m_syswrap/syswrap-freebsd.c
none/tests/freebsd/Makefile.am
none/tests/freebsd/bug498317.c [new file with mode: 0644]
none/tests/freebsd/bug498317.stderr.exp [new file with mode: 0644]
none/tests/freebsd/bug498317.supp [new file with mode: 0644]
none/tests/freebsd/bug498317.vgtest [new file with mode: 0644]

index 1b6e2d002b798d50ae4566b6a3e1df1e606856df..06825166217213706ef38fff010bea39b102a5a5 100644 (file)
 /none/tests/freebsd/Makefile
 /none/tests/freebsd/Makefile.in
 /none/tests/freebsd/auxv
+/none/tests/freebsd/bug498317
 /none/tests/freebsd/osrel
 /none/tests/freebsd/swapcontext
 /none/tests/freebsd/fexecve
diff --git a/NEWS b/NEWS
index a25f9b663098650173c2c00d683982e8ded4db5c..2fb8ce5c724b1759d44cc5d1fceb05dfcabaee92 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@ The following bugs have been fixed or resolved on this branch.
 489913  WARNING: unhandled amd64-linux syscall: 444 (landlock_create_ruleset)
 494246  syscall fsopen not wrapped
 497130  Recognize new DWARF5 DW_LANG constants
+498317  FdBadUse is not a valid CoreError type in a suppression
+        even though it's generated by --gen-suppressions=yes
 
 To see details of a given bug, visit
   https://bugs.kde.org/show_bug.cgi?id=XXXXXX
index 4bbcea02474cca4656a61cba92d3ddc2132adca8..2ce919482f771b89bfce9e6c9cae8455374349ba 100644 (file)
@@ -206,7 +206,8 @@ typedef
       // example should new core errors ever be added.
       ThreadSupp = -1,    /* Matches ThreadErr */
       FdBadCloseSupp = -2,
-      FdNotClosedSupp = -3
+      FdNotClosedSupp = -3,
+      FdBadUseSupp = -4
    }
    CoreSuppKind;
 
@@ -1033,7 +1034,7 @@ static Bool core_error_matches_suppression(const Error* err, const Supp* su)
       return err->ekind == FdBadClose;
    case FdNotClosedSupp:
       return err->ekind == FdNotClosed;
-   case FdBadUse:
+   case FdBadUseSupp:
       return err->ekind == FdBadUse;
    default:
       VG_(umsg)("FATAL: unknown core suppression kind: %d\n", su->skind );
@@ -1522,6 +1523,8 @@ static void load_one_suppressions_file ( Int clo_suppressions_i )
             supp->skind = FdBadCloseSupp;
          else if (VG_STREQ(supp_name, "FdNotClosed"))
             supp->skind = FdNotClosedSupp;
+         else if (VG_STREQ(supp_name, "FdBadUse"))
+            supp->skind = FdBadUseSupp;
          else
             BOMB("unknown core suppression type");
       }
index 685eb6be076c5e610575bce0d32e1770f9ed554f..a2b79545594e052cc950680395ea5fa40ff415d4 100644 (file)
@@ -1400,6 +1400,10 @@ PRE(sys_fcntl)
       PRINT("sys_fcntl[UNKNOWN] ( %lu, %lu, %lu )", ARG1,ARG2,ARG3);
       I_die_here;
    }
+
+   if (!ML_(fd_allowed)(ARG1, "fcntl", tid, False)) {
+     SET_STATUS_Failure (VKI_EBADF);
+   }
 }
 
 POST(sys_fcntl)
index fe4f8db69824430f4c3d8cbf64a448c7ccf91174..1ccfefb57fe2e3902c4bafbac8b58e44df0cf444 100644 (file)
@@ -11,6 +11,8 @@ EXTRA_DIST = \
        auxv.stderr.exp-freebsd131 \
        auxv.stderr.exp-freebsd14 \
        auxv.stderr.exp-arm64 \
+       bug498317.vgtest bug498317.stderr.exp \
+       bug498317.supp \
        cp.vgtest \
        cp.stderr.exp \
        osrel.vgtest \
@@ -61,7 +63,7 @@ EXTRA_DIST = \
        usrstack.stdout.exp
 
 check_PROGRAMS = \
-       auxv osrel swapcontext hello_world fexecve 452275 usrstack \
+       auxv bug498317 osrel swapcontext hello_world fexecve 452275 usrstack \
        proc_pid_file sanity_level_thread umtx_shm_creat
 
 AM_CFLAGS   += $(AM_FLAG_M3264_PRI)
diff --git a/none/tests/freebsd/bug498317.c b/none/tests/freebsd/bug498317.c
new file mode 100644 (file)
index 0000000..36a1a5a
--- /dev/null
@@ -0,0 +1,7 @@
+#include <fcntl.h>
+
+int main(void) {
+        fcntl(-1, F_GETFD);
+        return 0;
+}
+
diff --git a/none/tests/freebsd/bug498317.stderr.exp b/none/tests/freebsd/bug498317.stderr.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/none/tests/freebsd/bug498317.supp b/none/tests/freebsd/bug498317.supp
new file mode 100644 (file)
index 0000000..b3a9944
--- /dev/null
@@ -0,0 +1,8 @@
+{
+   test suppression of FdBadUse
+   CoreError:FdBadUse
+   fun:_fcntl
+   fun:fcntl
+   fun:main
+}
+
diff --git a/none/tests/freebsd/bug498317.vgtest b/none/tests/freebsd/bug498317.vgtest
new file mode 100644 (file)
index 0000000..6579ebc
--- /dev/null
@@ -0,0 +1,2 @@
+prog: bug498317
+vgopts: -q