Skip to content

Commit

Permalink
syscalls/sched_getattr02: use a fixed size for EINVAL test
Browse files Browse the repository at this point in the history
Test is using a 'size' based on sizeof(struct sched_attr), but
since c48700d ("sched_attr: Do not define for glibc >= 2.41")
that structure can now be defined by glibc which also defines additional
fields.

The kernel only checks if size is smaller than SCHED_ATTR_SIZE_VER0 (48 bytes).
Use a fixed size (SCHED_ATTR_SIZE_VER0 - 1) for the test.

Signed-off-by: Jan Stancek <[email protected]>
Reviewed-by: Li Wang <[email protected]>
Reviewed-by: Petr Vorel <[email protected]>
  • Loading branch information
jstancek committed Nov 4, 2024
1 parent 5746e25 commit 0e0c18e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/lapi/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ static inline int sched_getattr(pid_t pid, struct sched_attr *attr,
{
return syscall(__NR_sched_getattr, pid, attr, size, flags);
}

# define SCHED_ATTR_SIZE_VER0 48 /* sizeof first published struct */
#endif

#ifndef HAVE_CLONE3
Expand Down
2 changes: 1 addition & 1 deletion testcases/kernel/syscalls/sched_getattr/sched_getattr02.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static struct test_case {
} test_cases[] = {
{&unused_pid, &attr_copy, sizeof(struct sched_attr), 0, ESRCH},
{&pid, NULL, sizeof(struct sched_attr), 0, EINVAL},
{&pid, &attr_copy, sizeof(struct sched_attr) - 1, 0, EINVAL},
{&pid, &attr_copy, SCHED_ATTR_SIZE_VER0 - 1, 0, EINVAL},
{&pid, &attr_copy, sizeof(struct sched_attr), 1000, EINVAL}
};

Expand Down

0 comments on commit 0e0c18e

Please sign in to comment.