* [LTP] [PATCH v2 0/2] fcntl{34,36}: Fixes for Android arm64
@ 2023-04-27 17:43 Edward Liaw via ltp
2023-04-27 17:43 ` [LTP] [PATCH v2 1/2] fcntl{34, 36}: Only use fcntl64 with 32bit abi Edward Liaw via ltp
2023-04-27 17:43 ` [LTP] [PATCH v2 2/2] fcntl{34, 36}: Use arch dependent types for my_flock64 Edward Liaw via ltp
0 siblings, 2 replies; 6+ messages in thread
From: Edward Liaw via ltp @ 2023-04-27 17:43 UTC (permalink / raw)
To: ltp; +Cc: kernel-team, rpalethorpe
Fixes: 7643115aaacb ("fcntl{34,36}: Always use 64-bit flock struct to avoid EINVAL")
In Richard's commit I think that he had meant to write that the flock64
type (not fcntl64 type) had been removed from some libcs. I believe
that was the reason why he added the my_flock64 type.
On Android arm64, this test was breaking for two reasons:
1. The my_flock64 type definition did not match the expected type when
compiled for 64 bits.
2. The test was mixing fcntl and the flock64 struct when compiled for 32
bits.
Both seem to be ok on x86_64 but not on arm64. To fix it, I gated the
compat function on TST_ABI64 instead of tst_kernel_bits.
v1->v2:
Updated commit description and cleaned up error message.
Edward Liaw (2):
fcntl{34,36}: Only use fcntl64 with 32bit abi
fcntl{34,36}: Use arch dependent types for my_flock64
.../kernel/syscalls/fcntl/fcntl_common.h | 28 +++++++++++--------
1 file changed, 16 insertions(+), 12 deletions(-)
--
2.40.1.495.gc816e09b53d-goog
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH v2 1/2] fcntl{34, 36}: Only use fcntl64 with 32bit abi
2023-04-27 17:43 [LTP] [PATCH v2 0/2] fcntl{34,36}: Fixes for Android arm64 Edward Liaw via ltp
@ 2023-04-27 17:43 ` Edward Liaw via ltp
2023-04-27 17:49 ` Petr Vorel
2023-04-27 17:43 ` [LTP] [PATCH v2 2/2] fcntl{34, 36}: Use arch dependent types for my_flock64 Edward Liaw via ltp
1 sibling, 1 reply; 6+ messages in thread
From: Edward Liaw via ltp @ 2023-04-27 17:43 UTC (permalink / raw)
To: ltp; +Cc: kernel-team, rpalethorpe
Fixes: 7643115aaacb ("fcntl{34,36}: Always use 64-bit flock struct to avoid EINVAL")
On Android arm64, tst_kernel_bits returns 64, so when compiling with the
32bit abi, the test makes the fcntl syscall instead of fcntl64. The
fcntl syscall is not compatible with the flock64 struct being passed on
arm64 (x86_64 uses compat_sys_fcntl64 whereas arm64 uses sys_fcntl).
Before 7643115aaacb, compiling with FILE_OFFSET_BITS=64 and the 32bit
abi would also use fcntl instead of fcntl64.
This changes it to only use the fcntl64 compat syscall with the 32bit
abi.
Signed-off-by: Edward Liaw <edliaw@google.com>
---
testcases/kernel/syscalls/fcntl/fcntl_common.h | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/testcases/kernel/syscalls/fcntl/fcntl_common.h b/testcases/kernel/syscalls/fcntl/fcntl_common.h
index 5c130a784..56e871167 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl_common.h
+++ b/testcases/kernel/syscalls/fcntl/fcntl_common.h
@@ -10,6 +10,11 @@
#include "lapi/abisize.h"
#include "lapi/fcntl.h"
+#if defined(TST_ABI64)
+#define FCNTL_COMPAT(fd, cmd, flock) \
+ SAFE_FCNTL(fd, cmd, flock)
+
+#else
struct my_flock64 {
int16_t l_type;
int16_t l_whence;
@@ -26,8 +31,7 @@ struct my_flock64 {
* pass the flock sturct directly to the kernel even if it had 32-bit
* offsets.
*
- * Also, if and only if, we are on 32-bit kernel we need to use the
- * fcntl64 compat syscall.
+ * If we are on 32-bit abi we need to use the fcntl64 compat syscall.
*
* See:
* glibc: 06ab719d30 Fix Linux fcntl OFD locks for non-LFS architectures (BZ#20251)
@@ -43,8 +47,8 @@ static inline int fcntl_compat(const char *file, const int line, const char *cmd
.l_len = lck->l_len,
.l_pid = lck->l_pid,
};
- const int sysno = tst_kernel_bits() > 32 ? __NR_fcntl : __NR_fcntl64;
- const int ret = tst_syscall(sysno, fd, cmd, &l64);
+
+ const int ret = tst_syscall(__NR_fcntl64, fd, cmd, &l64);
lck->l_type = l64.l_type;
lck->l_whence = l64.l_whence;
@@ -56,8 +60,7 @@ static inline int fcntl_compat(const char *file, const int line, const char *cmd
return ret;
tst_brk_(file, line, TBROK | TERRNO,
- "%s(%d, %s, { %d, %d, %"PRId64", %"PRId64", %d })",
- tst_kernel_bits() > 32 ? "fcntl" : "fcntl64",
+ "fcntl64(%d, %s, { %d, %d, %"PRId64", %"PRId64", %d })",
fd,
cmd_name,
l64.l_type, l64.l_whence, l64.l_start, l64.l_len, l64.l_pid);
@@ -67,5 +70,6 @@ static inline int fcntl_compat(const char *file, const int line, const char *cmd
#define FCNTL_COMPAT(fd, cmd, flock) \
fcntl_compat(__FILE__, __LINE__, #cmd, fd, cmd, flock)
+#endif
#endif /* FCNTL_COMMON_H__ */
--
2.40.1.495.gc816e09b53d-goog
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [LTP] [PATCH v2 2/2] fcntl{34, 36}: Use arch dependent types for my_flock64
2023-04-27 17:43 [LTP] [PATCH v2 0/2] fcntl{34,36}: Fixes for Android arm64 Edward Liaw via ltp
2023-04-27 17:43 ` [LTP] [PATCH v2 1/2] fcntl{34, 36}: Only use fcntl64 with 32bit abi Edward Liaw via ltp
@ 2023-04-27 17:43 ` Edward Liaw via ltp
2023-04-27 18:36 ` Petr Vorel
2023-04-28 7:41 ` Petr Vorel
1 sibling, 2 replies; 6+ messages in thread
From: Edward Liaw via ltp @ 2023-04-27 17:43 UTC (permalink / raw)
To: ltp; +Cc: kernel-team, rpalethorpe
On Android arm64, fcntl is not accepting the my_flock64 struct being
passed (fails with EINVAL). This modifies the struct type to match the
flock64 definition in the kernel.
Signed-off-by: Edward Liaw <edliaw@google.com>
---
testcases/kernel/syscalls/fcntl/fcntl_common.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/testcases/kernel/syscalls/fcntl/fcntl_common.h b/testcases/kernel/syscalls/fcntl/fcntl_common.h
index 56e871167..86f2726af 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl_common.h
+++ b/testcases/kernel/syscalls/fcntl/fcntl_common.h
@@ -16,13 +16,13 @@
#else
struct my_flock64 {
- int16_t l_type;
- int16_t l_whence;
- int64_t l_start;
- int64_t l_len;
- int32_t l_pid;
+ short l_type;
+ short l_whence;
+ off64_t l_start;
+ off64_t l_len;
+ pid_t l_pid;
#if defined(__sparc__)
- int16_t padding;
+ short padding;
#endif
};
--
2.40.1.495.gc816e09b53d-goog
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v2 1/2] fcntl{34, 36}: Only use fcntl64 with 32bit abi
2023-04-27 17:43 ` [LTP] [PATCH v2 1/2] fcntl{34, 36}: Only use fcntl64 with 32bit abi Edward Liaw via ltp
@ 2023-04-27 17:49 ` Petr Vorel
0 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2023-04-27 17:49 UTC (permalink / raw)
To: Edward Liaw; +Cc: kernel-team, rpalethorpe, ltp
Hi Edward,
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Again, thanks for updating the commit message.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v2 2/2] fcntl{34, 36}: Use arch dependent types for my_flock64
2023-04-27 17:43 ` [LTP] [PATCH v2 2/2] fcntl{34, 36}: Use arch dependent types for my_flock64 Edward Liaw via ltp
@ 2023-04-27 18:36 ` Petr Vorel
2023-04-28 7:41 ` Petr Vorel
1 sibling, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2023-04-27 18:36 UTC (permalink / raw)
To: Edward Liaw; +Cc: kernel-team, rpalethorpe, ltp
Hi Edward,
> On Android arm64, fcntl is not accepting the my_flock64 struct being
> passed (fails with EINVAL). This modifies the struct type to match the
> flock64 definition in the kernel.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Tested-by: Petr Vorel <pvorel@suse.cz>
(only on x86_64 libc)
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v2 2/2] fcntl{34, 36}: Use arch dependent types for my_flock64
2023-04-27 17:43 ` [LTP] [PATCH v2 2/2] fcntl{34, 36}: Use arch dependent types for my_flock64 Edward Liaw via ltp
2023-04-27 18:36 ` Petr Vorel
@ 2023-04-28 7:41 ` Petr Vorel
1 sibling, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2023-04-28 7:41 UTC (permalink / raw)
To: Edward Liaw; +Cc: kernel-team, rpalethorpe, ltp
Hi all,
thanks, patchset merged.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-04-28 7:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-27 17:43 [LTP] [PATCH v2 0/2] fcntl{34,36}: Fixes for Android arm64 Edward Liaw via ltp
2023-04-27 17:43 ` [LTP] [PATCH v2 1/2] fcntl{34, 36}: Only use fcntl64 with 32bit abi Edward Liaw via ltp
2023-04-27 17:49 ` Petr Vorel
2023-04-27 17:43 ` [LTP] [PATCH v2 2/2] fcntl{34, 36}: Use arch dependent types for my_flock64 Edward Liaw via ltp
2023-04-27 18:36 ` Petr Vorel
2023-04-28 7:41 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox