• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

seccomp / libseccomp / 243
93%
main: 89%

Build:
Build:
LAST BUILD BRANCH: alpha-support
DEFAULT BRANCH: main
Ran 19 Oct 2019 01:28AM UTC
Jobs 1
Files 59
Run time 4s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
243

Pull #175

travis-ci

web-flow
Circumvent bug in uClibc-ng syscall() on x86_64 systems

On uClibc up to v1.0.31, syscall() for x86_64 is defined in
libc/sysdeps/linux/x86_64/syscall.S as

syscall:
        movq %rdi, %rax         /* Syscall number -> rax.  */
        movq %rsi, %rdi         /* shift arg1 - arg5.  */
        movq %rdx, %rsi
        movq %rcx, %rdx
        movq %r8, %r10
        movq %r9, %r8
        movq 8(%rsp),%r9        /* arg6 is on the stack.  */
        syscall                 /* Do the system call.  */
        cmpq $-4095, %rax       /* Check %rax for error.  */
        jae __syscall_error     /* Branch forward if it failed.  */
        ret                     /* Return to caller.  */

And __syscall_error is defined in
libc/sysdeps/linux/x86_64/__syscall_error.c as

int __syscall_error(void) attribute_hidden;
int __syscall_error(void)
{
	register int err_no __asm__ ("%rcx");
	__asm__ ("mov %rax, %rcx\n\t"
	         "neg %rcx");
	__set_errno(err_no);
	return -1;
}

Notice that __syscall_error returns -1 as a 32-bit int in %rax, a 64-bit
register i.e. 0x00000000ffffffff (decimal 4294967295). When this value
is compared to -1 in _sys_chk_seccomp_flag_kernel() the result is false,
leading the function to always return 0.

Prevent the error by coercing the return value of syscall() to int in a
temporary variable before comparing it to -1. We could use just an (int)
cast but the variable makes the code more readable and the machine code
generated by the compiler is the same in both cases.

All other syscall() invocations were inspected and they either already
coerce the result to int or do not compare it to -1.

The same problem probably occurs on other 64-bit systems but so far only
x86_64 was tested.

A bug report is being submitted to uClibc.

Signed-off-by: Carlos Santos <casantos@redhat.com>
Pull Request #175: Circumvent bug in uClibc-ng syscall() on x86_64 systems

3 of 3 new or added lines in 1 file covered. (100.0%)

2349 of 2616 relevant lines covered (89.79%)

3002783.04 hits per line

Jobs
ID Job ID Ran Files Coverage
1 243.1 19 Oct 2019 01:28AM UTC 0
89.79
Travis Job 243.1
Source Files on build 243
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #243
  • Pull Request #175
  • PR Base - master (#241)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc