Bug 369030

Summary: WARNING: unhandled amd64-linux syscall: 171 (setdomainname)
Product: [Developer tools] valgrind Reporter: Marcin Juszkiewicz <marcin>
Component: generalAssignee: mcermak
Status: RESOLVED FIXED    
Severity: normal CC: mark, sam, tom
Priority: NOR    
Version First Reported In: 3.11.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=368921
Latest Commit: Version Fixed In:
Sentry Crash Report:
Bug Depends on:    
Bug Blocks: 506971    
Attachments: proposed patch
updated patch

Description Marcin Juszkiewicz 2016-09-19 06:47:18 UTC
<<<test_start>>>
tag=setdomainname01_valgrind_memory_leak_check stime=1474195205
cmdline=" valgrind -q --leak-check=full --trace-children=yes setdomainname01"
contacts=""
analysis=exit
<<<test_output>>>
--24445-- WARNING: unhandled amd64-linux syscall: 171
--24445-- You may be able to write your own handler.
--24445-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--24445-- Nevertheless we consider this a bug.  Please report
--24445-- it at http://valgrind.org/support/bug_reports.html.
--24445-- WARNING: unhandled amd64-linux syscall: 171
--24445-- You may be able to write your own handler.
--24445-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--24445-- Nevertheless we consider this a bug.  Please report
--24445-- it at http://valgrind.org/support/bug_reports.html.
setdomainname01    1  TFAIL  :  setdomainname01.c:104: setdomainname() Failed, errno = 38 : Function not implemented
setdomainname01    0  TWARN  :  setdomainname01.c:146: setdomainname() failed while restoring domainname to "(none)"
<<<execution_status>>>
initiation_status="ok"
duration=0 termination_type=exited termination_id=5 corefile=no
cutime=60 cstime=1
<<<test_end>>>


Reproducible: Always
Comment 1 Marcin Juszkiewicz 2018-04-30 08:07:04 UTC
Can we close it? IIRC it was merged into valgrind.
Comment 2 Tom Hughes 2018-04-30 09:57:03 UTC
I see no sign that this has been added.
Comment 3 Tom Hughes 2018-04-30 09:57:11 UTC
I see no sign that this has been added.
Comment 4 Mark Wielaard 2021-10-04 09:19:17 UTC
This has only been implemented for MIPS (but it doesn't do any checks on the supplied name)
Comment 5 mcermak 2025-09-19 08:12:17 UTC
Created attachment 185069 [details]
proposed patch
Comment 6 Mark Wielaard 2025-09-19 10:48:19 UTC
Comment on attachment 185069 [details]
proposed patch

    The len argument specifies the number of bytes in name.
    (Thus, name does not require a terminating null byte.)

So don't you want to check the name here:

+PRE(sys_setdomainname)
+{
+   PRINT ("sys_setdomainname ( %#" FMT_REGWORD "x, %ld )", ARG1, SARG2);
+   PRE_REG_READ2 (long, "setdomainname", const void *, name, int, len);
+}

PRE_MEM_READ("setdomainname.name", ARG1, ARG2); ?
Comment 7 mcermak 2025-09-19 15:35:15 UTC
Created attachment 185102 [details]
updated patch

Oh, thanks for pointing that out.  Please check the updated patch.
Comment 8 Mark Wielaard 2025-09-19 16:41:30 UTC
Made this one small tweak:

-   PRE_MEM_READ("setdomainname.name", ARG1, ARG2);
+   PRE_MEM_READ("setdomainname(name)", ARG1, ARG2);

Was my fault/suggestion, but the variant with "syscall_name(param_name)" is more consistent with other code.

Pushed as:

commit 2604bb753a9ff461550e0d4d0c1ebd3ab6488d6d
Author: Martin Cermak <mcermak@redhat.com>
Date:   Fri Sep 19 09:31:39 2025 +0200

    Wrap the setdomainname syscall
    
    The setdomainname() call sets the domain name to the value given in the
    character array name.  The len argument specifies the number of bytes in
    name.  (Thus, name does not require a terminating null byte.)
    
    Declare a setdomainname wrapper in priv_syswrap-linux.h and hook it for
    {amd64,arm,arm64,mips64,ppc32,ppc64,riscv64,s390x,x86}-linux using
    LINX_ with PRE handler in syswrap-linux.c
    
    https://bugs.kde.org/show_bug.cgi?id=369030