mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [PATCH] use __scc and unsigned long for socketcall
       [not found] <20220701150910.347715-1-alex_y_xu.ref@yahoo.ca>
@ 2022-07-01 15:09 ` Alex Xu (Hello71)
  2022-08-01 17:50   ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Xu (Hello71) @ 2022-07-01 15:09 UTC (permalink / raw)
  To: musl; +Cc: Alex Xu (Hello71)

otherwise, pointer arguments are sign-extended on x32, resulting in
EFAULT.
---
 src/internal/syscall.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/internal/syscall.h b/src/internal/syscall.h
index 4f41e1dc..7c74775c 100644
--- a/src/internal/syscall.h
+++ b/src/internal/syscall.h
@@ -58,22 +58,22 @@ hidden long __syscall_ret(unsigned long),
 #define __syscall_cp(...) __SYSCALL_DISP(__syscall_cp,__VA_ARGS__)
 #define syscall_cp(...) __syscall_ret(__syscall_cp(__VA_ARGS__))
 
-static inline long __alt_socketcall(int sys, int sock, int cp, long a, long b, long c, long d, long e, long f)
+static inline long __alt_socketcall(int sys, int sock, int cp, syscall_arg_t a, syscall_arg_t b, syscall_arg_t c, syscall_arg_t d, syscall_arg_t e, syscall_arg_t f)
 {
 	long r;
 	if (cp) r = __syscall_cp(sys, a, b, c, d, e, f);
 	else r = __syscall(sys, a, b, c, d, e, f);
 	if (r != -ENOSYS) return r;
 #ifdef SYS_socketcall
-	if (cp) r = __syscall_cp(SYS_socketcall, sock, ((long[6]){a, b, c, d, e, f}));
-	else r = __syscall(SYS_socketcall, sock, ((long[6]){a, b, c, d, e, f}));
+	if (cp) r = __syscall_cp(SYS_socketcall, sock, ((unsigned long[6]){a, b, c, d, e, f}));
+	else r = __syscall(SYS_socketcall, sock, ((unsigned long[6]){a, b, c, d, e, f}));
 #endif
 	return r;
 }
 #define __socketcall(nm, a, b, c, d, e, f) __alt_socketcall(SYS_##nm, __SC_##nm, 0, \
-	(long)(a), (long)(b), (long)(c), (long)(d), (long)(e), (long)(f))
+	__scc(a), __scc(b), __scc(c), __scc(d), __scc(e), __scc(f))
 #define __socketcall_cp(nm, a, b, c, d, e, f) __alt_socketcall(SYS_##nm, __SC_##nm, 1, \
-	(long)(a), (long)(b), (long)(c), (long)(d), (long)(e), (long)(f))
+	__scc(a), __scc(b), __scc(c), __scc(d), __scc(e), __scc(f))
 
 /* fixup legacy 16-bit junk */
 
-- 
2.36.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [musl] [PATCH] use __scc and unsigned long for socketcall
  2022-07-01 15:09 ` [musl] [PATCH] use __scc and unsigned long for socketcall Alex Xu (Hello71)
@ 2022-08-01 17:50   ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2022-08-01 17:50 UTC (permalink / raw)
  To: Alex Xu (Hello71); +Cc: musl

On Fri, Jul 01, 2022 at 11:09:10AM -0400, Alex Xu (Hello71) wrote:
> otherwise, pointer arguments are sign-extended on x32, resulting in
> EFAULT.
> ---
>  src/internal/syscall.h | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/src/internal/syscall.h b/src/internal/syscall.h
> index 4f41e1dc..7c74775c 100644
> --- a/src/internal/syscall.h
> +++ b/src/internal/syscall.h
> @@ -58,22 +58,22 @@ hidden long __syscall_ret(unsigned long),
>  #define __syscall_cp(...) __SYSCALL_DISP(__syscall_cp,__VA_ARGS__)
>  #define syscall_cp(...) __syscall_ret(__syscall_cp(__VA_ARGS__))
>  
> -static inline long __alt_socketcall(int sys, int sock, int cp, long a, long b, long c, long d, long e, long f)
> +static inline long __alt_socketcall(int sys, int sock, int cp, syscall_arg_t a, syscall_arg_t b, syscall_arg_t c, syscall_arg_t d, syscall_arg_t e, syscall_arg_t f)
>  {

OK.

>  	long r;
>  	if (cp) r = __syscall_cp(sys, a, b, c, d, e, f);
>  	else r = __syscall(sys, a, b, c, d, e, f);
>  	if (r != -ENOSYS) return r;
>  #ifdef SYS_socketcall
> -	if (cp) r = __syscall_cp(SYS_socketcall, sock, ((long[6]){a, b, c, d, e, f}));
> -	else r = __syscall(SYS_socketcall, sock, ((long[6]){a, b, c, d, e, f}));
> +	if (cp) r = __syscall_cp(SYS_socketcall, sock, ((unsigned long[6]){a, b, c, d, e, f}));
> +	else r = __syscall(SYS_socketcall, sock, ((unsigned long[6]){a, b, c, d, e, f}));
>  #endif
>  	return r;

Does this part have any functional change or purpose? I'm not seeing it.

>  }
>  #define __socketcall(nm, a, b, c, d, e, f) __alt_socketcall(SYS_##nm, __SC_##nm, 0, \
> -	(long)(a), (long)(b), (long)(c), (long)(d), (long)(e), (long)(f))
> +	__scc(a), __scc(b), __scc(c), __scc(d), __scc(e), __scc(f))
>  #define __socketcall_cp(nm, a, b, c, d, e, f) __alt_socketcall(SYS_##nm, __SC_##nm, 1, \
> -	(long)(a), (long)(b), (long)(c), (long)(d), (long)(e), (long)(f))
> +	__scc(a), __scc(b), __scc(c), __scc(d), __scc(e), __scc(f))
>  
>  /* fixup legacy 16-bit junk */

Looks good.

Rich

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-01 17:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20220701150910.347715-1-alex_y_xu.ref@yahoo.ca>
2022-07-01 15:09 ` [musl] [PATCH] use __scc and unsigned long for socketcall Alex Xu (Hello71)
2022-08-01 17:50   ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).