ioctl10: fix the sscanf() call to handle 64-bit inode on 32-bit arch
PATCH v2 1/1 ioctl10: fix the sscanf() call to handle 64-bit inode on 32-bit arch
This test started failing recently on arm32, when we switched the kernel to displaying the full 64-bit inode number in the maps file. Change the testcase to allow for a full 64-bit inode number on all arches. The value it's compared to is already 64-bits, so widening this field is all that is necessary.
---
Changes in v2:
- Use SCNu64 instead of %llu in the sscanf() format string
- Link to v1: https://lore.kernel.org/r/[email protected]
--- testcases/kernel/syscalls/ioctl/ioctl10.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/ioctl/ioctl10.c +3 -2
@@ -17,6 +17,7 @@#include "config.h" #include <stdlib.h> +#include <inttypes.h> #include <sys/ioctl.h> #include <errno.h> #include <fnmatch.h>
@@ -35,7 +36,7 @@ struct map_entry {unsigned long vm_pgoff;unsigned int vm_major;unsigned int vm_minor; -unsigned long vm_inode; +uint64_t vm_inode;char vm_name[256 ];unsigned int vm_flags; };
@@ -68,7 +69,7 @@ static void parse_maps_file(const char *filename, const char *keyword, struct mawhile (fgets (line,sizeof (line), fp) !=NULL ) {if (fnmatch (keyword, line,0 ) ==0 ) { -if (sscanf (line,"%lx-%lx %s %lx %x:%x %lu %s" , +if (sscanf (line,"%lx-%lx %s %lx %x:%x %" SCNu64" %s" , &entry->vm_start, &entry->vm_end, entry->vm_flags_str, &entry->vm_pgoff, &entry->vm_major, &entry->vm_minor, &entry->vm_inode, entry->vm_name) <7 )
---
base-commit: 534222c4f3908e9642f913399e37a66fdd266bbe
change-id: 20260626-master-55d29494ba06
Best regards,
Signature · 5 lines
Jeff Layton <[email protected]> -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Jeff,
Quoted 1 line · Jeff Layton
ioctl10: fix the
sscanf()call to handle 64-bit inode on 32-bit arch
Verdict - Reviewed
Pre-existing issue (not introduced by this patch):
Quoted 1 line
SAFE_CLOSE(fd);
SAFE_CLOSE(fd) inside verify_ioctl() closes the fd opened in setup() and sets it to -1. When run with -i N (multiple iterations), subsequent iterations pass fd=-1 to ioctl(), causing EBADF. The fd should only be closed in cleanup().
---
Note:
The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 8 lines · Jeff Layton via ltp
This test started failing recently on arm32, when we switched the kernel to displaying the full 64-bit inode number in the maps file. Change the testcase to allow for a full 64-bit inode number on all arches. The value it's compared to is already 64-bits, so widening this field is all that is necessary.
Reported-by Mark Brown <[email protected]>Signed-off-by Jeff Layton <[email protected]>
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi all,
Quoted 11 lines · Jeff Layton via ltp
Quoted 8 lines
This test started failing recently on arm32, when we switched the kernel to displaying the full 64-bit inode number in the maps file. Change the testcase to allow for a full 64-bit inode number on all arches. The value it's compared to is already 64-bits, so widening this field is all that is necessary.
Reported-by Mark Brown <[email protected]>Signed-off-by Jeff Layton <[email protected]>Reviewed-by Li Wang <[email protected]>
Merged, thank you!
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp