"arch: add compat helpers specific to 64-bit" introduced the generic helper in_compat64_syscall() to check if the syscall was made in compat64 specifically. We have a number of equivalent helpers scattered across the tree, as well as open-coded checks. Replace them with calls to in_compat64_syscall().
Signed-off-by: Kevin Brodsky kevin.brodsky@arm.com --- drivers/mmc/core/block.c | 11 +++-------- io_uring/io_uring.c | 2 +- io_uring/uring_cmd.c | 2 +- kernel/futex/syscalls.c | 2 +- net/ipv4/tcp.c | 18 +++++++----------- 5 files changed, 13 insertions(+), 22 deletions(-)
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 0422137a3bdd..14297236a60e 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -101,11 +101,6 @@ struct mmc_blk_busy_data { u32 status; };
-static inline bool in_compat64(void) -{ - return IS_ENABLED(CONFIG_COMPAT64) && in_compat_syscall(); -} - struct compat_mmc_ioc_cmd { int write_flag; int is_acmd; @@ -463,7 +458,7 @@ static int get_mmc_ioc_cmd_from_compat64(struct mmc_ioc_cmd *native_cmd,
static int copy_mmc_ioc_cmd_from_user(struct mmc_ioc_cmd *to, void * __user src) { - if (in_compat64()) + if (in_compat64_syscall()) return get_mmc_ioc_cmd_from_compat64(to, src);
if (copy_from_user_with_ptr(to, src, sizeof(*to))) @@ -519,7 +514,7 @@ static int mmc_blk_ioctl_copy_to_user(struct mmc_ioc_cmd __user *ic_ptr, { struct mmc_ioc_cmd *ic = &idata->ic;
- __u32 __user *response_uptr = in_compat64() ? + __u32 __user *response_uptr = in_compat64_syscall() ? &((struct compat_mmc_ioc_cmd __user *)ic_ptr)->response[0] : &ic_ptr->response[0];
@@ -756,7 +751,7 @@ static inline struct mmc_ioc_cmd __user *get_ith_mmc_ioc_cmd_uptr( struct mmc_ioc_multi_cmd __user *user, unsigned int i) { - if (in_compat64()) + if (in_compat64_syscall()) return (struct mmc_ioc_cmd __user *)&((struct compat_mmc_ioc_multi_cmd __user *)user)->cmds[i]; return &(user->cmds[i]); } diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index e77a1460e55c..e1b12f8f7007 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -251,7 +251,7 @@ static int get_compat64_io_uring_params(struct io_uring_params *params, static int copy_io_uring_params_from_user(struct io_uring_params *params, const void __user *src) { - if (IS_ENABLED(CONFIG_COMPAT64) && in_compat_syscall()) + if (in_compat64_syscall()) return get_compat64_io_uring_params(params, src); if (copy_from_user_with_ptr(params, src, sizeof(*params))) return -EFAULT; diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c index db184905c20d..a471a0971c70 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -216,7 +216,7 @@ EXPORT_SYMBOL_GPL(io_uring_cmd_import_fixed);
static inline void __user *sqe_get_optval(const struct io_uring_sqe *sqe) { - if (IS_ENABLED(CONFIG_COMPAT64) && in_compat_syscall()) { + if (in_compat64_syscall()) { const __u64 *val = io_uring_sqe_cmd(sqe); return compat_ptr(READ_ONCE(*val)); } else { diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c index ea49ee054a74..4840d3195977 100644 --- a/kernel/futex/syscalls.c +++ b/kernel/futex/syscalls.c @@ -194,7 +194,7 @@ static int copy_futex_waitv_from_user(struct futex_waitv *aux, const struct futex_waitv __user *uwaitv, unsigned int i) { - if (IS_ENABLED(CONFIG_COMPAT64) && in_compat_syscall()) { + if (in_compat64_syscall()) { const struct compat_futex_waitv __user *compat_uwaitv = (const struct compat_futex_waitv __user *)uwaitv; struct compat_futex_waitv compat_aux; diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 4e001d8d4cd6..7b8870f86210 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -1818,11 +1818,6 @@ struct compat_tcp_zerocopy_receive { __u32 reserved; };
-static inline bool in_compat64(void) -{ - return IS_ENABLED(CONFIG_COMPAT64) && in_compat_syscall(); -} - static int get_compat64_tcp_zerocopy_receive(struct tcp_zerocopy_receive *zc, sockptr_t src, size_t size) { @@ -1849,7 +1844,7 @@ static int get_compat64_tcp_zerocopy_receive(struct tcp_zerocopy_receive *zc, static int copy_tcp_zerocopy_receive_from_sockptr(struct tcp_zerocopy_receive *zc, sockptr_t src, size_t size) { - if (in_compat64()) + if (in_compat64_syscall()) return get_compat64_tcp_zerocopy_receive(zc, src, size); if (copy_from_sockptr_with_ptr(zc, src, size)) return -EFAULT; @@ -1882,7 +1877,7 @@ static int copy_tcp_zerocopy_receive_to_sockptr(sockptr_t dst, struct tcp_zerocopy_receive *zc, size_t size) { - if (in_compat64()) + if (in_compat64_syscall()) return set_compat64_tcp_zerocopy_receive(dst, zc, size); if (copy_to_sockptr_with_ptr(dst, zc, size)) return -EFAULT; @@ -4341,14 +4336,15 @@ int do_tcp_getsockopt(struct sock *sk, int level, } #ifdef CONFIG_MMU #define offsetofend_tcp_zerocopy_receive(member) \ - (in_compat64() ? offsetofend(struct compat_tcp_zerocopy_receive, member) \ - : offsetofend(struct tcp_zerocopy_receive, member)) + (in_compat64_syscall() ? offsetofend(struct compat_tcp_zerocopy_receive, member) \ + : offsetofend(struct tcp_zerocopy_receive, member)) case TCP_ZEROCOPY_RECEIVE: { struct scm_timestamping_internal tss; struct tcp_zerocopy_receive zc = {}; int err; - size_t zc_size = in_compat64() ? sizeof(struct compat_tcp_zerocopy_receive) - : sizeof(struct tcp_zerocopy_receive); + size_t zc_size = in_compat64_syscall() ? + sizeof(struct compat_tcp_zerocopy_receive) : + sizeof(struct tcp_zerocopy_receive);
if (copy_from_sockptr(&len, optlen, sizeof(int))) return -EFAULT;