Skip to content

Glibc prctl unexpected errors and unimplemented functions in FilC vs. standard glibc #117

@johnsonjh

Description

@johnsonjh

First off —

value = prctl(PR_GET_AUXV);
value = prctl(PR_GET_MDWE);

These aren’t available but they should be under glibc.

A test program for prctl also has unexpected results:

#include <stdio.h>
#include <sys/prctl.h>
#include <linux/prctl.h>
#include <errno.h>

void print_prctl_status(const char *name, int value) {
    if (value == -1) {
        printf("%s: Error (errno: %d)\n", name, errno);
    } else {
        printf("%s: %d\n", name, value);
    }
}

int main() {
    int value;
    char name[17];
    value = prctl(PR_GET_NAME, name);
    if (value == -1) {
        perror("PR_GET_NAME");
    } else {
        printf("PR_GET_NAME: %s\n", name);
    }
    value = prctl(PR_GET_DUMPABLE);
    print_prctl_status("PR_GET_DUMPABLE", value);
    value = prctl(PR_GET_ENDIAN);
    print_prctl_status("PR_GET_ENDIAN", value);
    value = prctl(PR_GET_FPEXC);
    print_prctl_status("PR_GET_FPEXC", value);
    value = prctl(PR_GET_NO_NEW_PRIVS);
    print_prctl_status("PR_GET_NO_NEW_PRIVS", value);
    value = prctl(PR_GET_SECCOMP);
    print_prctl_status("PR_GET_SECCOMP", value);
    value = prctl(PR_GET_TIMERSLACK);
    print_prctl_status("PR_GET_TIMERSLACK", value);
    value = prctl(PR_GET_CHILD_SUBREAPER);
    print_prctl_status("PR_GET_CHILD_SUBREAPER", value);
    value = prctl(PR_GET_FP_MODE);
    print_prctl_status("PR_GET_FP_MODE", value);
    value = prctl(PR_GET_FPEMU);
    print_prctl_status("PR_GET_FPEMU", value);
    value = prctl(PR_GET_IO_FLUSHER);
    print_prctl_status("PR_GET_IO_FLUSHER", value);
    value = prctl(PR_GET_KEEPCAPS);
    print_prctl_status("PR_GET_KEEPCAPS", value);
    value = prctl(PR_GET_SECUREBITS);
    print_prctl_status("PR_GET_SECUREBITS", value);
    value = prctl(PR_GET_SPECULATION_CTRL);
    print_prctl_status("PR_GET_SPECULATION_CTRL", value);
    value = prctl(PR_SVE_GET_VL);
    print_prctl_status("PR_SVE_GET_VL", value);
    value = prctl(PR_GET_TAGGED_ADDR_CTRL);
    print_prctl_status("PR_GET_TAGGED_ADDR_CTRL", value);
    value = prctl(PR_GET_THP_DISABLE);
    print_prctl_status("PR_GET_THP_DISABLE", value);
    value = prctl(PR_GET_TID_ADDRESS);
    print_prctl_status("PR_GET_TID_ADDRESS", value);
    value = prctl(PR_GET_TIMING);
    print_prctl_status("PR_GET_TIMING", value);
    value = prctl(PR_GET_TSC);
    print_prctl_status("PR_GET_TSC", value);
    value = prctl(PR_GET_UNALIGN);
    print_prctl_status("PR_GET_UNALIGN", value);
    return 0;
}

Host system:

PR_GET_NAME: a.out
PR_GET_DUMPABLE: 1
PR_GET_ENDIAN: Error (errno: 22)
PR_GET_FPEXC: Error (errno: 22)
PR_GET_NO_NEW_PRIVS: Error (errno: 22)
PR_GET_SECCOMP: 0
PR_GET_TIMERSLACK: 50000
PR_GET_CHILD_SUBREAPER: Error (errno: 14)
PR_GET_FP_MODE: Error (errno: 22)
PR_GET_FPEMU: Error (errno: 22)
PR_GET_IO_FLUSHER: Error (errno: 1)
PR_GET_KEEPCAPS: 0
PR_GET_SECUREBITS: 0
PR_GET_SPECULATION_CTRL: Error (errno: 19)
PR_SVE_GET_VL: Error (errno: 22)
PR_GET_TAGGED_ADDR_CTRL: Error (errno: 22)
PR_GET_THP_DISABLE: Error (errno: 22)
PR_GET_TID_ADDRESS: Error (errno: 14)
PR_GET_TIMING: 0
PR_GET_TSC: Error (errno: 14)
PR_GET_UNALIGN: Error (errno: 22)

FilC:

PR_GET_NAME: Function not implemented
PR_GET_DUMPABLE: Error (errno: 38)
PR_GET_ENDIAN: Error (errno: 38)
PR_GET_FPEXC: Error (errno: 38)
PR_GET_NO_NEW_PRIVS: Error (errno: 38)
PR_GET_SECCOMP: Error (errno: 38)
PR_GET_TIMERSLACK: Error (errno: 38)
PR_GET_CHILD_SUBREAPER: Error (errno: 38)
PR_GET_FP_MODE: Error (errno: 38)
PR_GET_FPEMU: Error (errno: 38)
PR_GET_IO_FLUSHER: Error (errno: 38)
PR_GET_KEEPCAPS: Error (errno: 38)
PR_GET_SECUREBITS: Error (errno: 38)
PR_GET_SPECULATION_CTRL: Error (errno: 38)
PR_SVE_GET_VL: Error (errno: 38)
PR_GET_TAGGED_ADDR_CTRL: Error (errno: 38)
PR_GET_THP_DISABLE: Error (errno: 38)
PR_GET_TID_ADDRESS: Error (errno: 38)
PR_GET_TIMING: Error (errno: 38)
PR_GET_TSC: Error (errno: 38)
PR_GET_UNALIGN: Error (errno: 38)

I have real code that uses at least PR_GET_NAME, PR_GET_SECCOMP, and PR_GET_DUMPABLE.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions