Projectname large_stringclasses 15
values | Filepath large_stringlengths 4 106 ⌀ | Function large_stringlengths 11 3.45k | Label list |
|---|---|---|---|
Linux Kernel | tools/testing/selftests/kvm/x86_64/ucna_injection_test.c |
static struct kvm_vcpu *create_vcpu_with_mce_cap(struct kvm_vm *vm,
uint32_t vcpuid,
bool enable_cmci_p,
void *guest_code) {
struct kvm_vcpu *vcpu = vm_vcpu_add(vm, vcpui... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/ucna_injection_test.c |
int main(int argc, char *argv[]) {
struct thread_params params;
struct kvm_vm *vm;
struct kvm_vcpu *ucna_vcpu;
struct kvm_vcpu *cmcidis_vcpu;
struct kvm_vcpu *cmci_vcpu;
kvm_check_cap(KVM_CAP_MCE);
vm = __vm_create(VM_MODE_DEFAULT, 3, 0);
kvm_ioctl(vm->kvm_fd, KVM_X86_GET_MCE_CAP_SUPPORTED, &support... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/userspace_io_test.c | int main(int argc, char *argv[]) {
struct kvm_vcpu *vcpu;
struct kvm_regs regs;
struct kvm_run *run;
struct kvm_vm *vm;
struct ucall uc;
setbuf(stdout, NULL);
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
run = vcpu->run;
memset(®s, 0, sizeof(regs));
while (1) {
vcpu_run(vcpu);
TE... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c |
static void prepare_bitmaps(void) {
memset(bitmap_00000000, 0xff, sizeof(bitmap_00000000));
memset(bitmap_00000000_write, 0xff, sizeof(bitmap_00000000_write));
memset(bitmap_40000000, 0xff, sizeof(bitmap_40000000));
memset(bitmap_c0000000, 0xff, sizeof(bitmap_c0000000));
memset(bitmap_c0000000_read, 0xff, si... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c | static noinline void test_wrmsr(uint32_t msr, uint64_t value) {
uint32_t a = value;
uint32_t d = value >> 32;
guest_exception_count = 0;
__asm__ __volatile__("wrmsr_start: wrmsr; wrmsr_end:" ::"a"(a), "d"(d),
"c"(msr)
: "memory");
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c | static void guest_code_filter_deny(void) {
guest_msr_calls(true);
GUEST_SYNC(0);
guest_msr_calls(false);
GUEST_DONE();
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c |
static void __guest_gp_handler(struct ex_regs *regs, char *r_start, char *r_end,
char *w_start, char *w_end) {
if (regs->rip == (uintptr_t)r_start) {
regs->rip = (uintptr_t)r_end;
regs->rax = 0;
regs->rdx = 0;
} else if (regs->rip == (uintptr_t)w_start) {
regs->rip = ... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c |
static void guest_fep_gp_handler(struct ex_regs *regs) {
__guest_gp_handler(regs, &em_rdmsr_start, &em_rdmsr_end, &em_wrmsr_start,
&em_wrmsr_end);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c |
static void check_for_guest_assert(struct kvm_vcpu *vcpu) {
struct ucall uc;
if (vcpu->run->exit_reason == KVM_EXIT_IO &&
get_ucall(vcpu, &uc) == UCALL_ABORT) {
REPORT_GUEST_ASSERT(uc);
}
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c |
static uint64_t process_ucall(struct kvm_vcpu *vcpu) {
struct kvm_run *run = vcpu->run;
struct ucall uc = {};
check_for_guest_assert(vcpu);
TEST_ASSERT(run->exit_reason == KVM_EXIT_IO,
"Unexpected exit reason: %u (%s)", run->exit_reason,
exit_reason_str(run->exit_reason));
swit... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c |
static void run_guest_then_process_ucall_done(struct kvm_vcpu *vcpu) {
vcpu_run(vcpu);
process_ucall_done(vcpu);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c |
static int handle_ucall(struct kvm_vcpu *vcpu) {
struct ucall uc;
switch (get_ucall(vcpu, &uc)) {
case UCALL_ABORT:
REPORT_GUEST_ASSERT(uc);
break;
case UCALL_SYNC:
vm_ioctl(vcpu->vm, KVM_X86_SET_MSR_FILTER, &no_filter_deny);
break;
case UCALL_DONE:
return 1;
default:
TEST_FAIL("Un... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/vmx_close_while_nested_test.c | int main(int argc, char *argv[]) {
vm_vaddr_t vmx_pages_gva;
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_VMX));
vm = vm_create_with_one_vcpu(&vcpu, l1_guest_code);
vcpu_alloc_vmx(vm, &vmx_pages_gva);
vcpu_args_set(vcpu, 1, vmx_pages_gva);
for (;;) {
volatile st... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/vmx_exception_with_invalid_guest_state.c | static void guest_ud_handler(struct ex_regs *regs) {} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/vmx_exception_with_invalid_guest_state.c |
static void guest_code(void) { asm volatile("ud2"); } | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/vmx_invalid_nested_guest_state.c | static void l2_guest_code(void) {
asm volatile("inb %%dx, %%al" : : [port] "d"(ARBITRARY_IO_PORT) : "rax");
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/vmx_msrs_test.c |
static void vmx_fixed0_msr_test(struct kvm_vcpu *vcpu, uint32_t msr_index,
uint64_t mask) {
uint64_t val = vcpu_get_msr(vcpu, msr_index);
uint64_t bit;
mask = ~mask | val;
for_each_clear_bit(bit, &mask, 64) {
vcpu_set_msr(vcpu, msr_index, val | BIT_ULL(bit));
vcpu_set_... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/vmx_nested_tsc_scaling_test.c | static void compare_tsc_freq(uint64_t actual, uint64_t expected) {
uint64_t tolerance, thresh_low, thresh_high;
tolerance = expected / 100;
thresh_low = expected - tolerance;
thresh_high = expected + tolerance;
TEST_ASSERT(thresh_low < actual,
"TSC freq is expected to be between %" PRIu64 " an... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/vmx_nested_tsc_scaling_test.c | static void check_tsc_freq(int level) {
uint64_t tsc_start, tsc_end, tsc_freq;
tsc_start = rdmsr(MSR_IA32_TSC);
GUEST_SLEEP(1);
tsc_end = rdmsr(MSR_IA32_TSC);
tsc_freq = tsc_end - tsc_start;
GUEST_CHECK(level, tsc_freq);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/vmx_set_nested_state_test.c | void set_revision_id_for_vmcs12(struct kvm_nested_state *state,
u32 vmcs12_revision) {
memcpy(&state->data, &vmcs12_revision, sizeof(u32));
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c | static void l2_guest_code(void) {
uint64_t l1_tsc = rdtsc() - TSC_OFFSET_VALUE;
wrmsr(MSR_IA32_TSC, l1_tsc - TSC_ADJUST_VALUE);
check_ia32_tsc_adjust(-2 * TSC_ADJUST_VALUE);
__asm__ __volatile__("vmcall");
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/xapic_ipi_test.c |
void verify_apic_base_addr(void) {
uint64_t msr = rdmsr(MSR_IA32_APICBASE);
uint64_t base = GET_APIC_BASE(msr);
GUEST_ASSERT(base == APIC_DEFAULT_GPA);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/xapic_ipi_test.c |
void get_cmdline_args(int argc, char *argv[], int *run_secs, bool *migrate,
int *delay_usecs) {
for (;;) {
int opt = getopt(argc, argv, "s:d:m");
if (opt == -1)
break;
switch (opt) {
case 's':
*run_secs = parse_size(optarg);
break;
case 'm':
*migrate... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/xapic_state_test.c |
static void xapic_guest_code(void) {
asm volatile("cli");
xapic_enable();
while (1) {
uint64_t val = (u64)xapic_read_reg(APIC_IRR) |
(u64)xapic_read_reg(APIC_IRR + 0x10) << 32;
xapic_write_reg(APIC_ICR2, val >> 32);
xapic_write_reg(APIC_ICR, val);
GUEST_SYNC(val);
}
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/xapic_state_test.c | static void __test_icr(struct xapic_vcpu *x, uint64_t val) {
if (x->is_x2apic) {
val &= ~X2APIC_RSVED_BITS_MASK;
}
____test_icr(x, val | APIC_ICR_BUSY);
____test_icr(x, val & ~(u64)APIC_ICR_BUSY);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/xapic_state_test.c | int main(int argc, char *argv[]) {
struct xapic_vcpu x = {
.vcpu = NULL,
.is_x2apic = true,
};
struct kvm_vm *vm;
vm = vm_create_with_one_vcpu(&x.vcpu, x2apic_guest_code);
test_icr(&x);
kvm_vm_free(vm);
vm = vm_create_with_one_vcpu(&x.vcpu, xapic_guest_code);
x.is_x2apic = false;
vcpu_c... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c |
static void handle_alrm(int sig) {
if (vinfo)
printf("evtchn_upcall_pending 0x%x\n", vinfo->evtchn_upcall_pending);
vcpu_dump(stdout, vcpu, 0);
TEST_FAIL("IRQ delivery timed out");
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c |
static void *juggle_shinfo_state(void *arg) {
struct kvm_vm *vm = (struct kvm_vm *)arg;
struct kvm_xen_hvm_attr cache_init = {.type = KVM_XEN_ATTR_TYPE_SHARED_INFO,
.u.shared_info.gfn =
SHINFO_REGION_GPA / PAGE_SIZE};
struct kv... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/landlock/common.h | static inline int
landlock_create_ruleset(const struct landlock_ruleset_attr *const attr,
const size_t size, const __u32 flags) {
return syscall(__NR_landlock_create_ruleset, attr, size, flags);
}
#endif | [
0,
0
] |
Linux Kernel | tools/testing/selftests/landlock/common.h | static void __maybe_unused
disable_caps(struct __test_metadata *const _metadata) {
_init_caps(_metadata, false);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/landlock/common.h |
static void __maybe_unused set_cap(struct __test_metadata *const _metadata,
const cap_value_t caps) {
_effective_cap(_metadata, caps, CAP_SET);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/landlock/common.h |
static void __maybe_unused clear_cap(struct __test_metadata *const _metadata,
const cap_value_t caps) {
_effective_cap(_metadata, caps, CAP_CLEAR);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/landlock/common.h | static int __maybe_unused send_fd(int usock, int fd_tx) {
union {
char buf[CMSG_SPACE(sizeof(fd_tx))];
struct cmsghdr _align;
} cmsg_tx = {};
char data_tx = '.';
struct iovec io = {
.iov_base = &data_tx,
.iov_len = sizeof(data_tx),
};
struct msghdr msg = {
.msg_iov = &io,
.m... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/landlock/fs_test.c |
static int remove_path(const char *const path) {
char *walker;
int i, ret, err = 0;
walker = strdup(path);
if (!walker) {
err = ENOMEM;
goto out;
}
if (unlink(path) && rmdir(path)) {
if (errno != ENOENT && errno != ENOTDIR)
err = errno;
goto out;
}
for (i = strlen(walker); i > 0;... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/landlock/fs_test.c | static int create_ruleset(struct __test_metadata *const _metadata,
const __u64 handled_access_fs,
const struct rule rules[]) {
int ruleset_fd, i;
struct landlock_ruleset_attr ruleset_attr = {
.handled_access_fs = handled_access_fs,
};
ASSERT_NE(NULL, ru... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/landlock/fs_test.c |
static void enforce_ruleset(struct __test_metadata *const _metadata,
const int ruleset_fd) {
ASSERT_EQ(0, prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0));
ASSERT_EQ(0, landlock_restrict_self(ruleset_fd, 0)) {
TH_LOG("Failed to enforce ruleset: %s", strerror(errno));
}
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/landlock/fs_test.c |
static int test_rename(const char *const oldpath, const char *const newpath) {
if (rename(oldpath, newpath))
return errno;
return 0;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/landlock/fs_test.c |
static int test_exchange(const char *const oldpath, const char *const newpath) {
if (renameat2(AT_FDCWD, oldpath, AT_FDCWD, newpath, RENAME_EXCHANGE))
return errno;
return 0;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/landlock/fs_test.c | static int test_creat(const char *const path) {
int fd = creat(path, 0600);
if (fd < 0)
return errno;
if (close(fd) < 0)
return errno;
return 0;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/landlock/fs_test.c | static int test_ftruncate(int fd) {
if (ftruncate(fd, 10) < 0)
return errno;
return 0;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/landlock/ptrace_test.c | static int test_ptrace_read(const pid_t pid) {
static const char path_template[] = "/proc/%d/environ";
char procenv_path[sizeof(path_template) + 10];
int procenv_path_size, fd;
procenv_path_size =
snprintf(procenv_path, sizeof(procenv_path), path_template, pid);
if (procenv_path_size >= sizeof(procenv_... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/membarrier/membarrier_test_impl.h |
static int test_membarrier_flags_fail(void) {
int cmd = MEMBARRIER_CMD_QUERY, flags = 1;
const char *test_name = "sys membarrier MEMBARRIER_CMD_QUERY invalid flags";
if (sys_membarrier(cmd, flags) != -1) {
ksft_exit_fail_msg("%s test: flags = %d. Should fail, but passed\n",
test_name,... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/membarrier/membarrier_test_impl.h |
static int test_membarrier_private_expedited_fail(void) {
int cmd = MEMBARRIER_CMD_PRIVATE_EXPEDITED, flags = 0;
const char *test_name =
"sys membarrier MEMBARRIER_CMD_PRIVATE_EXPEDITED not registered failure";
if (sys_membarrier(cmd, flags) != -1) {
ksft_exit_fail_msg("%s test: flags = %d. Should fai... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/membarrier/membarrier_test_impl.h |
static int test_membarrier_private_expedited_sync_core_fail(void) {
int cmd = MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE, flags = 0;
const char *test_name =
"sys membarrier MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE not "
"registered failure";
if (sys_membarrier(cmd, flags) != -1) {
ksft_exit_fa... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/membarrier/membarrier_test_impl.h |
static int test_membarrier_fail(void) {
int status;
status = test_membarrier_cmd_fail();
if (status)
return status;
status = test_membarrier_flags_fail();
if (status)
return status;
status = test_membarrier_private_expedited_fail();
if (status)
return status;
status = sys_membarrier(MEMBAR... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/membarrier/membarrier_test_single_thread.c |
int main(int argc, char **argv) {
ksft_print_header();
ksft_set_plan(13);
test_membarrier_query();
test_membarrier_fail();
test_membarrier_success();
return ksft_exit_pass();
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/memfd/fuse_mnt.c |
static int memfd_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi) {
if (strcmp(path, "/"))
return -ENOENT;
filler(buf, ".", NULL, 0);
filler(buf, "..", NULL, 0);
filler(buf, memfd_path + 1, NULL, 0);
return 0;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/memfd/fuse_test.c |
static void mfd_assert_has_seals(int fd, __u64 seals) {
__u64 s;
s = mfd_assert_get_seals(fd);
if (s != seals) {
printf("%llu != %llu = GET_SEALS(%d)\n", (unsigned long long)seals,
(unsigned long long)s, fd);
abort();
}
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/memfd/fuse_test.c |
static void mfd_assert_add_seals(int fd, __u64 seals) {
long r;
__u64 s;
s = mfd_assert_get_seals(fd);
r = fcntl(fd, F_ADD_SEALS, seals);
if (r < 0) {
printf("ADD_SEALS(%d, %llu -> %llu) failed: %m\n", fd,
(unsigned long long)s, (unsigned long long)seals);
abort();
}
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/memfd/fuse_test.c |
static void *mfd_assert_mmap_shared(int fd) {
void *p;
p = mmap(NULL, mfd_def_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (p == MAP_FAILED) {
printf("mmap() failed: %m\n");
abort();
}
return p;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/memfd/memfd_test.c |
static void mfd_fail_new(const char *name, unsigned int flags) {
int r;
r = sys_memfd_create(name, flags);
if (r >= 0) {
printf("memfd_create(\"%s\", %u) succeeded, but failure expected\n", name,
flags);
close(r);
abort();
}
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/memfd/memfd_test.c |
static int mfd_assert_open(int fd, int flags, mode_t mode) {
char buf[512];
int r;
sprintf(buf, "/proc/self/fd/%d", fd);
r = open(buf, flags, mode);
if (r < 0) {
printf("open(%s) failed: %m\n", buf);
abort();
}
return r;
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/memfd/memfd_test.c | static void mfd_assert_read(int fd) {
char buf[16];
void *p;
ssize_t l;
l = read(fd, buf, sizeof(buf));
if (l != sizeof(buf)) {
printf("read() failed: %m\n");
abort();
}
p = mmap(NULL, mfd_def_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (p == MAP_FAILED) {
printf("mmap() failed: %m\n");
a... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/memfd/memfd_test.c | static void mfd_assert_write(int fd) {
ssize_t l;
void *p;
int r;
if (!hugetlbfs_test) {
/* verify write() succeeds */
l = write(fd, "\0\0\0\0", 4);
if (l != 4) {
printf("write() failed: %m\n");
abort();
}
}
/* verify PROT_READ | PROT_WRITE is allowed */
p = mmap(NULL, mfd_de... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/memfd/memfd_test.c | static void mfd_fail_write(int fd) {
ssize_t l;
void *p;
int r;
l = write(fd, "data", 4);
if (l != -EPERM) {
printf("expected EPERM on write(), but got %d: %m\n", (int)l);
abort();
}
/* verify PROT_READ | PROT_WRITE is not allowed */
p = mmap(NULL, mfd_def_size, PROT_READ | PROT_WRITE, MAP_SHA... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/memfd/memfd_test.c |
static void mfd_fail_shrink(int fd) {
int r;
r = ftruncate(fd, mfd_def_size / 2);
if (r >= 0) {
printf("ftruncate(SHRINK) didn't fail as expected\n");
abort();
}
mfd_fail_open(fd, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/memfd/memfd_test.c |
static void mfd_assert_grow(int fd) {
int r;
r = ftruncate(fd, mfd_def_size * 2);
if (r < 0) {
printf("ftruncate(GROW) failed: %m\n");
abort();
}
mfd_assert_size(fd, mfd_def_size * 2);
r = fallocate(fd, 0, 0, mfd_def_size * 4);
if (r < 0) {
printf("fallocate(ALLOC) failed: %m\n");
abor... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/memfd/memfd_test.c | static void test_create(void) {
char buf[2048];
int fd;
printf("%s CREATE\n", memfd_str);
mfd_fail_new(NULL, 0);
/* test over-long name (not zero-terminated) */
memset(buf, 0xff, sizeof(buf));
mfd_fail_new(buf, 0);
/* test over-long zero-terminated name */
memset(buf, 0xff, sizeof(buf));
buf[siz... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/memfd/memfd_test.c | static void test_seal_shrink(void) {
int fd;
printf("%s SEAL-SHRINK\n", memfd_str);
fd = mfd_assert_new("kern_memfd_seal_shrink", mfd_def_size,
MFD_CLOEXEC | MFD_ALLOW_SEALING);
mfd_assert_has_seals(fd, 0);
mfd_assert_add_seals(fd, F_SEAL_SHRINK);
mfd_assert_has_seals(fd, F_SEAL_SHRI... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/memfd/memfd_test.c | static void test_seal_grow(void) {
int fd;
printf("%s SEAL-GROW\n", memfd_str);
fd = mfd_assert_new("kern_memfd_seal_grow", mfd_def_size,
MFD_CLOEXEC | MFD_ALLOW_SEALING);
mfd_assert_has_seals(fd, 0);
mfd_assert_add_seals(fd, F_SEAL_GROW);
mfd_assert_has_seals(fd, F_SEAL_GROW);
mf... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/memfd/memfd_test.c | static void test_seal_resize(void) {
int fd;
printf("%s SEAL-RESIZE\n", memfd_str);
fd = mfd_assert_new("kern_memfd_seal_resize", mfd_def_size,
MFD_CLOEXEC | MFD_ALLOW_SEALING);
mfd_assert_has_seals(fd, 0);
mfd_assert_add_seals(fd, F_SEAL_SHRINK | F_SEAL_GROW);
mfd_assert_has_seals(f... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/mount/nosymfollow-test.c |
static void die(char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
exit(EXIT_FAILURE);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/mount/nosymfollow-test.c |
static void vmaybe_write_file(bool enoent_ok, char *filename, char *fmt,
va_list ap) {
ssize_t written;
char buf[4096];
int buf_len;
int fd;
buf_len = vsnprintf(buf, sizeof(buf), fmt, ap);
if (buf_len < 0)
die("vsnprintf failed: %s\n", strerror(errno));
if (buf_len >= ... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/mount/nosymfollow-test.c |
static void create_and_enter_ns(void) {
uid_t uid = getuid();
gid_t gid = getgid();
if (unshare(CLONE_NEWUSER) != 0)
die("unshare(CLONE_NEWUSER) failed: %s\n", strerror(errno));
maybe_write_file("/proc/self/setgroups", "deny");
write_file("/proc/self/uid_map", "0 %d 1", uid);
write_file("/proc/self/g... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/mount/unprivileged-remount-test.c |
static int read_mnt_flags(const char *path) {
int ret;
struct statvfs stat;
int mnt_flags;
ret = statvfs(path, &stat);
if (ret != 0) {
die("statvfs of %s failed: %s\n", path, strerror(errno));
}
if (stat.f_flag &
~(ST_RDONLY | ST_NOSUID | ST_NODEV | ST_NOEXEC | ST_NOATIME |
ST_NODIRATI... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/mount/unprivileged-remount-test.c |
static void create_and_enter_userns(void) {
uid_t uid;
gid_t gid;
uid = getuid();
gid = getgid();
if (unshare(CLONE_NEWUSER) != 0) {
die("unshare(CLONE_NEWUSER) failed: %s\n", strerror(errno));
}
maybe_write_file("/proc/self/setgroups", "deny");
write_file("/proc/self/uid_map", "0 %d 1", uid);
... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/mount/unprivileged-remount-test.c |
static bool test_unpriv_remount_atime(int mount_flags, int invalid_flags) {
return test_unpriv_remount("ramfs", NULL, mount_flags, mount_flags,
invalid_flags);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/mount_setattr/mount_setattr_test.c |
static inline int sys_mount_setattr(int dfd, const char *path,
unsigned int flags, struct mount_attr *attr,
size_t size) {
return syscall(__NR_mount_setattr, dfd, path, flags, attr, size);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/mount_setattr/mount_setattr_test.c |
static ssize_t write_nointr(int fd, const void *buf, size_t count) {
ssize_t ret;
do {
ret = write(fd, buf, count);
} while (ret < 0 && errno == EINTR);
return ret;
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/mount_setattr/mount_setattr_test.c |
static char *get_field(char *src, int nfields) {
int i;
char *p = src;
for (i = 0; i < nfields; i++) {
while (*p && *p != ' ' && *p != '\t')
p++;
if (!*p)
break;
p++;
}
return p;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/mount_setattr/mount_setattr_test.c |
static bool mount_setattr_supported(void) {
int ret;
ret = sys_mount_setattr(-EBADF, "", AT_EMPTY_PATH, NULL, 0);
if (ret < 0 && errno == ENOSYS)
return false;
return true;
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/mount_setattr/mount_setattr_test.c |
static int map_ids(pid_t pid, unsigned long nsid, unsigned long hostid,
unsigned long range) {
char map[100], procfile[256];
snprintf(procfile, sizeof(procfile), "/proc/%d/uid_map", pid);
snprintf(map, sizeof(map), "%lu %lu %lu", nsid, hostid, range);
if (write_file(procfile, map, strlen(ma... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/mount_setattr/mount_setattr_test.c |
static int get_userns_fd_cb(void *data) { return kill(getpid(), SIGSTOP); } | [
0,
0
] |
Linux Kernel | tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c |
static ssize_t write_nointr(int fd, const void *buf, size_t count) {
ssize_t ret;
do {
ret = write(fd, buf, count);
} while (ret < 0 && errno == EINTR);
return ret;
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c |
static int write_file(const char *path, const void *buf, size_t count) {
int fd;
ssize_t ret;
fd = open(path, O_WRONLY | O_CLOEXEC | O_NOCTTY | O_NOFOLLOW);
if (fd < 0)
return -1;
ret = write_nointr(fd, buf, count);
close(fd);
if (ret < 0 || (size_t)ret != count)
return -1;
return 0;
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c |
static int prepare_unpriv_mountns(void) {
if (create_and_enter_userns())
return -1;
if (unshare(CLONE_NEWNS))
return -1;
if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0))
return -1;
return 0;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c | static bool is_shared_mount(const char *path) {
size_t len = 0;
char *line = NULL;
FILE *f = NULL;
f = fopen("/proc/self/mountinfo", "re");
if (!f)
return false;
while (getline(&line, &len, f) != -1) {
char *opts, *target;
target = get_field(line, 4);
if (!target)
continue;
opt... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c |
static bool move_mount_set_group_supported(void) {
int ret;
if (mount("testing", "/tmp", "tmpfs", MS_NOATIME | MS_NODEV,
"size=100000,mode=700"))
return -1;
if (mount(NULL, "/tmp", NULL, MS_PRIVATE, 0))
return -1;
if (mkdir(SET_GROUP_FROM, 0777))
return -1;
if (mkdir(SET_GROUP_TO,... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/mqueue/mq_open_tests.c |
static inline int get(FILE *stream) {
int value;
rewind(stream);
if (fscanf(stream, "%d", &value) != 1)
shutdown(4, "Error reading /proc entry", __LINE__ - 1);
return value;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/mqueue/mq_open_tests.c |
static inline void setr(int type, struct rlimit *rlim) {
if (setrlimit(type, rlim))
shutdown(7, "setrlimit()", __LINE__ - 1);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/mqueue/mq_open_tests.c |
void validate_current_settings() {
int rlim_needed;
if (cur_limits.rlim_cur < 4096) {
printf("Current rlimit value for POSIX message queue bytes is "
"unreasonably low,\nincreasing.\n\n");
cur_limits.rlim_cur = 8192;
cur_limits.rlim_max = 16384;
setr(RLIMIT_MSGQUEUE, &cur_limits);
}
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/mqueue/mq_perf_tests.c |
void sig_action(int signum, siginfo_t *info, void *context) {
if (pthread_self() != main_thread)
pthread_kill(main_thread, signum);
else {
fprintf(stderr, "Caught signal %d, exiting\n", signum);
shutdown(0, "", 0);
fprintf(stderr, "\n\nReturned from shutdown?!?!\n\n");
exit(0);
}
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/mqueue/mq_perf_tests.c |
static inline void set(FILE *stream, int value) {
int new_value;
rewind(stream);
if (fprintf(stream, "%d", value) < 0)
return shutdown(5, "Failed writing to /proc file", __LINE__);
new_value = get(stream);
if (new_value != value)
return shutdown(5, "We didn't get what we wrote to /proc back", __LINE... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/mqueue/mq_perf_tests.c |
static inline void setr(int type, struct rlimit *rlim) {
if (setrlimit(type, rlim))
shutdown(7, "setrlimit()", __LINE__);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/mqueue/mq_perf_tests.c |
void *cont_thread(void *arg) {
char buff[MSG_SIZE];
int i, priority;
for (i = 0; i < num_cpus_to_pin; i++)
if (cpu_threads[i] == pthread_self())
break;
printf("\tStarted continuous mode thread %d on CPU %d\n", i, cpus_to_pin[i]);
while (1) {
while (mq_send(queue, buff, sizeof(buff), 0) == 0)
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/mqueue/mq_perf_tests.c |
void dec_prio(int *prio) {
if (--*prio < 0)
*prio = mq_prio_max - 1;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/mqueue/mq_perf_tests.c |
void random_prio(int *prio) { *prio = random() % mq_prio_max; } | [
0,
0
] |
Linux Kernel | tools/testing/selftests/mqueue/mq_perf_tests.c |
void increase_limits(void) {
cur_limits.rlim_cur = RLIM_INFINITY;
cur_limits.rlim_max = RLIM_INFINITY;
setr(RLIMIT_MSGQUEUE, &cur_limits);
while (try_set(max_msgs, cur_max_msgs += 10))
;
cur_max_msgs = get(max_msgs);
while (try_set(max_msgsize, cur_max_msgsize += 1024))
;
cur_max_msgsize = get(ma... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/nci/nci_dev.c |
static __u8 get_dev_enable_state(struct msgtemplate *msg) {
struct nlattr *na;
int resp_len;
int len;
resp_len = GENLMSG_PAYLOAD(&msg->n);
na = (struct nlattr *)GENLMSG_DATA(msg);
len = 0;
while (len < resp_len) {
len += NLA_ALIGN(na->nla_len);
if (na->nla_type == NFC_ATTR_DEVICE_POWERED)
... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/nci/nci_dev.c |
static void *virtual_deinit(void *data) {
char buf[258];
int dev_fd;
int len;
dev_fd = *(int *)data;
len = read(dev_fd, buf, 258);
if (len <= 0)
goto error;
if (len != sizeof(nci_reset_cmd))
goto error;
if (memcmp(nci_reset_cmd, buf, len))
goto error;
write(dev_fd, nci_reset_rsp, sizeof... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/nci/nci_dev.c |
static void *virtual_deinit_v2(void *data) {
char buf[258];
int dev_fd;
int len;
dev_fd = *(int *)data;
len = read(dev_fd, buf, 258);
if (len <= 0)
goto error;
if (len != sizeof(nci_reset_cmd))
goto error;
if (memcmp(nci_reset_cmd, buf, len))
goto error;
write(dev_fd, nci_reset_rsp_v2, ... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/nci/nci_dev.c |
static void *virtual_poll_stop(void *data) {
char buf[258];
int dev_fd;
int len;
dev_fd = *(int *)data;
len = read(dev_fd, buf, 258);
if (len <= 0)
goto error;
if (len != sizeof(nci_rf_deact_cmd))
goto error;
if (memcmp(nci_rf_deact_cmd, buf, len))
goto error;
write(dev_fd, nci_rf_deact... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/nci/nci_dev.c |
int stop_polling(int dev_idx, int virtual_fd, int sd, int fid, int pid) {
pthread_t thread_t;
int status;
int rc;
rc = pthread_create(&thread_t, NULL, virtual_poll_stop, (void *)&virtual_fd);
if (rc < 0)
return rc;
rc = send_cmd_with_idx(sd, fid, pid, NFC_CMD_STOP_POLL, dev_idx);
if (rc != 0)
r... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/nci/nci_dev.c |
int connect_tag(int dev_idx, int virtual_fd, int sd, int fid, int pid) {
struct genlmsghdr *genlhdr;
struct nlattr *na;
char evt_data[255];
int target_idx;
int resp_len;
int evt_dev;
write(virtual_fd, nci_rf_activate_ntf, sizeof(nci_rf_activate_ntf));
resp_len = recv(sd, evt_data, sizeof(evt_data), 0)... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/nci/nci_dev.c |
int disconnect_tag(int nfc_sock, int virtual_fd) {
pthread_t thread_t;
char buf[256];
int status;
int len;
send(nfc_sock, &nci_t4t_select_cmd3[3], sizeof(nci_t4t_select_cmd3) - 3, 0);
len = read(virtual_fd, buf, sizeof(nci_t4t_select_cmd3));
if (len < 0 || memcmp(buf, nci_t4t_select_cmd3, sizeof(nci_t4t... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/net/af_unix/test_unix_oob.c |
static void sig_hand(int sn, siginfo_t *si, void *p) { signal_recvd = sn; } | [
0,
0
] |
Linux Kernel | tools/testing/selftests/net/af_unix/test_unix_oob.c |
static void signal_producer(int fd) {
char cmd;
cmd = 'S';
write(fd, &cmd, sizeof(cmd));
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/net/af_unix/test_unix_oob.c |
static void wait_for_signal(int fd) {
char buf[5];
read(fd, buf, 5);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/net/csum.c |
static uint32_t checksum_nofold(char *data, size_t len, uint32_t sum) {
uint16_t *words = (uint16_t *)data;
int i;
for (i = 0; i < len / 2; i++)
sum += words[i];
if (len & 1)
sum += ((unsigned char *)data)[len - 1];
return sum;
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/net/csum.c | static uint16_t checksum(void *th, uint16_t proto, size_t len) {
uint32_t sum;
int alen;
alen = cfg_family == PF_INET6 ? 32 : 8;
sum = checksum_nofold(iph_addr_p, alen, 0);
sum += htons(proto);
sum += htons(len);
if (cfg_do_tx && cfg_send_pfpacket)
return ~checksum_fold(NULL, 0, sum);
else
re... | [
0,
0
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.