Bug 444781 - MIPS: wrong syscall numbers used
Summary: MIPS: wrong syscall numbers used
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-01 15:08 UTC by Hauke Mehrtens
Modified: 2024-06-24 11:13 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
[PATCH] mips: Fix new syscall numbers (5.50 KB, patch)
2021-11-01 15:08 UTC, Hauke Mehrtens
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hauke Mehrtens 2021-11-01 15:08:39 UTC
Created attachment 143104 [details]
[PATCH] mips: Fix new syscall numbers

MIPS uses special syscall numbers on Linux, we can not use the vki/vki-scnums-32bit-linux.h and vki/vki-scnums-shared-linux.h files on MIPS.
With valgrind 3.18.1 on MIPS 32 BE I am getting this error message with dropbear and musl 1.2.2
```
root@OpenWrt:/# valgrind ssh 192.168.10.3
==1910== Memcheck, a memory error detector
==1910== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1910== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==1910== Command: ssh 192.168.10.3
==1910== 
==1910== Conditional jump or move depends on uninitialised value(s)
==1910==    at 0x407E198: ??? (in /lib/libc.so)
==1910==    by 0x4091BCC: ??? (in /lib/libc.so)
==1910== 
==1910== Conditional jump or move depends on uninitialised value(s)
==1910==    at 0x407D77C: ??? (in /lib/libc.so)
==1910==    by 0x407DCA0: ??? (in /lib/libc.so)
==1910== 
--1910-- WARNING: unhandled mips32-linux syscall: 4403
--1910-- You may be able to write your own handler.
--1910-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--1910-- Nevertheless we consider this a bug.  Please report
--1910-- it at http://valgrind.org/support/bug_reports.html.
--1910-- WARNING: unhandled mips32-linux syscall: 4403
--1910-- You may be able to write your own handler.
--1910-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--1910-- Nevertheless we consider this a bug.  Please report
--1910-- it at http://valgrind.org/support/bug_reports.html.
==1910== Conditional jump or move depends on uninitialised value(s)
==1910==    at 0x407E198: ??? (in /lib/libc.so)
==1910==    by 0x4057F64: ??? (in /lib/libc.so)
==1910== 
--1910-- WARNING: unhandled mips32-linux syscall: 4403
--1910-- You may be able to write your own handler.
--1910-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--1910-- Nevertheless we consider this a bug.  Please report
--1910-- it at http://valgrind.org/support/bug_reports.html.
--1910-- WARNING: unhandled mips32-linux syscall: 4403
--1910-- You may be able to write your own handler.
--1910-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--1910-- Nevertheless we consider this a bug.  Please report
--1910-- it at http://valgrind.org/support/bug_reports.html.
--1910-- WARNING: unhandled mips32-linux syscall: 4403
--1910-- You may be able to write your own handler.
--1910-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--1910-- Nevertheless we consider this a bug.  Please report
--1910-- it at http://valgrind.org/support/bug_reports.html.
.....
```
I expect that it detects the syscall mumber 4403 as the valid syscall clock_gettime64.

OpenWrt master with musl 1.2.2 and Linux 5.10 with valgrind 3.18.1 on MIPS BE 32 bit on MIPS malta in qemu. 

The attached patch fixes the problem. I only really tested the clock_gettime64 syscall on MIPS 32 BE, but not the rest. My test application do not issue these syscalls.
Comment 1 Petar Jovanovic 2024-06-24 11:13:33 UTC
This issue has been fixed on the trunk.
Relevant commits:

  commit efaa17e53a750d5f0f4c138b507b1b104729ed67
  mips: skip using shared syscall numbers for mips64

  commit 54d6ad3348fb50f5b972fe9c05d0d8757bfe73ba
  mips: skip using shared syscall numbers for mips32

Please reopen the issue if you see any problems.
Thanks for reporting the problem and sending the patch.