Skip to contentSkip to conversation

FIOQSIZE followup fixes

PATCH In review Ondrej Mosnacek 1 participant 4 messages Apr 21, 2022 – Apr 22, 2022 SELinux security module

lore
Share & tools
lore
#0 lore raw

cover FIOQSIZE followup fixes

Two small fixes for the recently merged switch to FIOQSIZE. One was found when the testsuite was run on ppc64le and s390x arches, the other one when looking at the code.

Ondrej Mosnacek (2):
policy/test_ioctl_xperms.te: add ioctl numbers for other arches tests/ioctl: adjust size of variable passed to ioctl(2)

 policy/test_ioctl_xperms.te | 3 ++-
 tests/ioctl/test_ioctl.c    | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
2.35.1
#1 lore raw

PATCH 1/2 policy/test_ioctl_xperms.te: add ioctl numbers for other arches

The FIOQSIZE ioctl numbers differ across arches. Add missing numbers to cover all arches currently supported by the Linux kernel.

Fixes b11701a55614 ("tests/ioctl: switch to FIOQSIZE")
---
 policy/test_ioctl_xperms.te | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
policy/test_ioctl_xperms.te +2 -1
index 5f570c3..1071bb9 100644
@@ -1,4 +1,5 @@
-define(`FIOQSIZE', `{ 0x00005460 }')
+# include FIOQSIZE ioctl numbers through all arches
+define(`FIOQSIZE', `{ 0x545E 0x5460 0x667f 0x6680 }')
 
 # Domain for process that is allowed the required ioctl xperms.
 type test_ioctl_xperm_t;
Signature · 1 line
2.35.1
#2 lore raw

PATCH 2/2 tests/ioctl: adjust size of variable passed to ioctl(2)

In reply to Ondrej Mosnacek

FIOQSIZE returns a result of type loff_t, which maps to long long int, so make sure that the variable is large enough to not cause stack corruption.

Fixes b11701a55614 ("tests/ioctl: switch to FIOQSIZE")
---
 tests/ioctl/test_ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/ioctl/test_ioctl.c +1 -1
index 6fff2d0..9bf732d 100644
@@ -18,7 +18,7 @@ int main(int argc, char **argv)
 
 	int fd;
 	int rc;
-	int val = 0;
+	long long int val = 0;
 
 	fd = open(argv[1], O_RDONLY, 0);
 
Signature · 1 line
2.35.1
#3 lore raw
In reply to Ondrej Mosnacek
Quoted 8 lines · Ondrej Mosnacek

Two small fixes for the recently merged switch to FIOQSIZE. One was found when the testsuite was run on ppc64le and s390x arches, the other one when looking at the code.

Ondrej Mosnacek (2):
policy/test_ioctl_xperms.te: add ioctl numbers for other arches tests/ioctl: adjust size of variable passed to ioctl(2)

Quoted 6 lines
 policy/test_ioctl_xperms.te | 3 ++-
 tests/ioctl/test_ioctl.c    | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

--
2.35.1

Both patches merged (the first one with a minor uppercase vs. lowercase consistency correction).

Signature · 3 lines
Ondrej Mosnacek
Software Engineer, Linux Security - SELinux kernel
Red Hat, Inc.