]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
mount syscall param filesystemtype may be NULL
authorMark Wielaard <mark@klomp.org>
Thu, 8 May 2025 22:21:25 +0000 (00:21 +0200)
committerMark Wielaard <mark@klomp.org>
Thu, 8 May 2025 23:01:22 +0000 (01:01 +0200)
On Linux the mount syscall, depending on flags provided, the source,
type and data my be ignored.  We already don't check data and allow
source to be NULL.  Normally when type is ignored an application will
provide an empty string "".  But sometimes NULL is passed (like for
source).  So we now also allow type to be NULL to prevent false
positives.

Adjust the linux/scalar.c tests so the type param is still
unaddressable.

https://bugs.kde.org/show_bug.cgi?id=503914

NEWS
coregrind/m_syswrap/syswrap-linux.c
memcheck/tests/arm64-linux/scalar.c
memcheck/tests/x86-linux/scalar.c

diff --git a/NEWS b/NEWS
index 7c66ec08bb2af5179c7adf57dd6d327e55a2bc9a..1ced90caef2fb8303099a773438fdf929a3d038e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 503641  close_range syscalls started failing with 3.25.0
 503677  duplicated-cond compiler warning in dis_RV64M
 503817  s390x: fix 'ordered comparison of pointer with integer zero' compiler warnings
+503914  mount syscall param filesystemtype may be NULL
 
 To see details of a given bug, visit
   https://bugs.kde.org/show_bug.cgi?id=XXXXXX
index 6f3917830fa4771a6688fe8da11f448da66cdcf3..afd4a618b12f7f76a84a5044f7432e44592d1e77 100644 (file)
@@ -1000,7 +1000,8 @@ PRE(sys_mount)
 {
    // Nb: depending on 'flags', the 'type' and 'data' args may be ignored.
    // We are conservative and check everything, except the memory pointed to
-   // by 'data'.
+   // by 'data'. And since both 'source' and 'type' may be ignored, we allow
+   // them to be NULL.
    *flags |= SfMayBlock;
    PRINT("sys_mount( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x(%s), %#"
          FMT_REGWORD "x(%s), %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",
@@ -1012,7 +1013,8 @@ PRE(sys_mount)
    if (ARG1)
       PRE_MEM_RASCIIZ( "mount(source)", ARG1);
    PRE_MEM_RASCIIZ( "mount(target)", ARG2);
-   PRE_MEM_RASCIIZ( "mount(type)", ARG3);
+   if (ARG3)
+      PRE_MEM_RASCIIZ( "mount(type)", ARG3);
 }
 
 PRE(sys_oldumount)
index 622ea1c47cc9ccf128a16bebba4aa6075fbe427f..49e0ca6a701f344bf64436a047f76e3b2a21e6d0 100644 (file)
@@ -128,7 +128,7 @@ int main(void)
 
    // __NR_mount 21
    GO(__NR_mount, "5s 3m");
-   SY(__NR_mount, x0, x0, x0, x0, x0); FAIL;
+   SY(__NR_mount, x0, x0, x0-1, x0, x0); FAIL;
    
    // __NR_umount arm64 only has umount2
    //GO(__NR_umount, "1s 1m");
index 83ed38c4d994a9d3bbc51c16df86144f9f59a460..fe36a47ef0f58d8f824983cafe90a8f6ed366347 100644 (file)
@@ -137,7 +137,7 @@ int main(void)
 
    // __NR_mount 21
    GO(__NR_mount, "5s 3m");
-   SY(__NR_mount, x0, x0, x0, x0, x0); FAIL;
+   SY(__NR_mount, x0, x0, x0-1, x0, x0); FAIL;
    
    // __NR_umount 22
    GO(__NR_umount, "1s 1m");