Improvements of qemu linux-user
v2 cover Improvements of qemu linux-user
v2: added 6 patches
This patch series contains implementation of support for two new system calls, and fixes for 5 existing system calls, and fix for a structure definition as well.
Lena Djokic (7):
linux-user: Add fanotify implementation
linux-user: Fix inotify_init1 support
linux-user: Fix flock definition for mips64
linux-user: Fix fcnt
linux-user: Fix readahead
linux-user: Fix syslog
linux-user: Fix mq_open
configure | 20 ++++++ linux-user/syscall.c | 166 ++++++++++++++++++++++++++++++++++++++++------ linux-user/syscall_defs.h | 2 +- 3 files changed, 168 insertions(+), 20 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/7 linux-user: Add fanotify implementation
This commit adds implementation of fanotify_init and fanotify_mark. Second argument for fanotify_init needs conversion because of flags which can be FAN_NONBLOCK and FAN_CLOEXEC which rely on O_NONBLOCK and O_CLOEXEC and those can have different values on different platforms. For fanotify_mark argument layout is different for 32-bit and 64-bit platforms and this implementation have support for that situation. Also, support for writing and reading of file descriptor opened by fanotify_init is added.
Configure file contains checks for excistence of fanotify support on given build system.
--- configure | 20 ++++++++ linux-user/syscall.c | 126 +++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 142 insertions(+), 4 deletions(-)
configure +20 -0
@@ -3537,6 +3537,23 @@ if compile_prog "" "" ; then inotify1=yes fi +# check if fanotify group of system calls is supported +fanotify=no +cat > $TMPC << EOF +#include <sys/fanotify.h> + +int +main(void) +{ + fanotify_init(0,0); + fanotify_mark(0,0,0,0,0); + return 0; +} +EOF +if compile_prog "" "" ; then + fanotify=yes +fi + # check if utimensat and futimens are supported utimens=no cat > $TMPC << EOF
@@ -5335,6 +5352,9 @@ fi if test "$inotify1" = "yes" ; then echo "CONFIG_INOTIFY1=y" >> $config_host_mak fi +if test "$fanotify" = "yes" ; then + echo "CONFIG_FANOTIFY=y" >> $config_host_mak +fi if test "$byteswap_h" = "yes" ; then echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak fi
linux-user/syscall.c +122 -4
171 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 1/7] linux-user: Add fanotify implementation
Quoted 11 lines · Lena Djokic
This commit adds implementation of
fanotify_initandfanotify_mark. Second argument forfanotify_initneeds conversion because of flags which can beFAN_NONBLOCKandFAN_CLOEXECwhich rely onO_NONBLOCKandO_CLOEXECand those can have different values on different platforms. Forfanotify_markargument layout is different for 32-bit and 64-bit platforms and this implementation have support for that situation. Also, support for writing and reading of file descriptor opened byfanotify_initis added.
Configure file contains checks for excistence of fanotify support on given build system.
Quoted 1 line
Signed-off-by Lena Djokic <[email protected]>
Thanks for this patch; it looks basically the right shape but I have some review comments below. (Also, sorry for taking so long to get to reviewing it.)
Quoted 20 lines
---
linux-user/syscall.c +3
-0@@ -76,6 +76,9 @@ int __clone2(int (*fn)(void *), void *child_stack_base,#ifdef CONFIG_SENDFILE #include <sys/sendfile.h> #endif +#ifdef CONFIG_FANOTIFY +#include <sys/fanotify.h> +#endif #define termios host_termios#define winsize host_winsize@@ -499,9 +502,13 @@ enum { QEMU___IFLA_INET6_MAX };
linux-user/syscall.c enum { · line 514
Quoted 10 lines
linux-user/syscall.c +4
-0+typedef abi_long (*TargetFdReadFunc )(void *,size_t ); +typedef abi_long (*TargetFdWriteFunc )(void *,size_t );typedef abi_long (*TargetFdDataFunc )(void *,size_t );typedef abi_long (*TargetFdAddrFunc )(void *,abi_ulong ,socklen_t ); typedef struct TargetFdTrans { + TargetFdReadFunc read_op; + TargetFdWriteFunc write_op; TargetFdDataFunc host_to_target_data; TargetFdDataFunc target_to_host_data; TargetFdAddrFunc target_to_host_addr;
What's the difference between read_op/write_op and the existing target_to_host_data/host_to_target_data hooks ? I feel like we should just use the existing hooks unless there's something specific that means they don't work. If we do need extra hooks we should add doc comments so it's clear which hooks get invoked in which contexts.
linux-user/syscall.c static target_timer_t get_timer_id(abi_long arg) · line 7557
Quoted 5 lines
linux-user/syscall.c +5
-0+#if defined(CONFIG_FANOTIFY ) +static inline abi_long fanotify_fd_read_op (void *buf,size_t len) +{ +struct fanotify_event_metadata *fem; +int num;
This should probably be a size_t, or you have problems with really large reads.
Quoted 92 lines
linux-user/syscall.c +68
-4+ +/* Read buffer for fanotify file descriptor contains one or more +* of fanotify_event_metadata structures. +*/ + fem = (struct fanotify_event_metadata *)buf; + num = len /sizeof (struct fanotify_event_metadata ); +for (int i =0 ; i < num; i++) { + (fem + i)->event_len =tswap32 ((fem + i)->event_len); +/* Fields (fem+i)->vers and (fem+i)->reserved are single byte, +* so swapping is not needed for them. +*/ + (fem + i)->metadata_len =tswap16 ((fem + i)->metadata_len); + (fem + i)->mask =tswap64 ((fem + i)->mask); + (fem + i)->fd =tswap32 ((fem + i)->fd); + (fem + i)->pid =tswap32 ((fem + i)->pid); + } + + return len; +} + +static inline abi_long fanotify_fd_write_op (void *buf,size_t len) +{ +struct fanotify_response *fr = (struct fanotify_response *)buf; + + fr->fd =tswap32 (fr->fd); + fr->response =tswap32 (fr->response); + +return len; +} + +static TargetFdTrans fanotify_trans = { + .read_op = fanotify_fd_read_op, + .write_op = fanotify_fd_write_op, +}; +#endif +/* do_syscall() should always have a single exit point at the end so that actions, such as logging of syscall results, can be performed. All errnos that do_syscall() returns must be -TARGET_<errcode>. */ @@ -7613,16 +7677,27 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,if (!(p =lock_user (VERIFY_WRITE , arg2, arg3,0 ))) goto efault; ret =get_errno (safe_read (arg1, p, arg3)); -if (ret >=0 && -fd_trans_host_to_target_data (arg1)) { - ret =fd_trans_host_to_target_data (arg1)(p, ret); - } +if (ret >=0 ) { +if (fd_trans_read_op (arg1)) { + ret =fd_trans_read_op (arg1)(p, ret); + } +if (fd_trans_host_to_target_data (arg1)) { + ret =fd_trans_host_to_target_data (arg1)(p, ret); + } + }unlock_user (p, arg2, ret); }break ;case TARGET_NR_write:if (!(p =lock_user (VERIFY_READ , arg2, arg3,1 ))) goto efault; +if (fd_trans_write_op (arg1)) { + ret =fd_trans_write_op (arg1)(p, arg3); +if (is_error (ret)) { +unlock_user (p, arg2,0 ); +break ; + } + } ret =get_errno (safe_write (arg1, p, arg3));unlock_user (p, arg2,0 );break ;@@ -11567,6 +11642,49 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,break ;#endif +#if defined(TARGET_NR_fanotify_init) && defined(CONFIG_FANOTIFY ) +case TARGET_NR_fanotify_init: + { + ret =get_errno (fanotify_init (arg1,target_to_host_bitmask (arg2, + fcntl_flags_tbl))); +if (ret >=0 ) { +fd_trans_register (ret, &fanotify_trans); + } + } +break ; +#endif +#if defined(TARGET_NR_fanotify_mark) && defined(CONFIG_FANOTIFY ) +case TARGET_NR_fanotify_mark: + { + p =NULL ; +#if (TARGET_ABI_BITS ==32 ) +if (arg6) {
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 11671
Quoted 10 lines
linux-user/syscall.c +10
-0+ p =lock_user_string (arg6); +if (!p) { + goto efault; + } + } + ret =get_errno (fanotify_mark (arg1, arg2, +target_offset64 (arg3, arg4), arg5 , p)); +if (arg6) { +unlock_user (p, arg6,0 ); + }
The logic in the two halves of this #if is basically the same; I think it would be clearer to write
uint64_t mask;
int dirfd;
abi_long pathname_arg;#if TARGET_ABI_BITS == 32
mask = target_offset64(arg3, arg4);
dirfd = arg5;
pathname_arg = arg6;
#else
mask = arg3;
dirfd = arg4;
pathname_arg = arg5;#endif
and then share the code that actually operates on them.
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 11682
Quoted 11 lines
linux-user/syscall.c +11
-0+#else +if (arg5) { + p =lock_user_string (arg5); +if (!p) { + goto efault; + } + } + ret =get_errno (fanotify_mark (arg1, arg2, arg3, arg4 , p)); +if (arg5) { +unlock_user (p, arg5,0 ); + }
You don't need the conditional, because unlock_user(NULL, ...) is a no-op.
Quoted 10 lines
linux-user/syscall.c +5
-1+#endif + } +break ; +#endif +#if defined(TARGET_NR_mq_open) && defined(__NR_mq_open)case TARGET_NR_mq_open: { --2.7.4
thanks
-- PMM
PATCH v2 2/7 linux-user: Fix inotify_init1 support
In reply to Lena DjokicThis commit adds necessary conversion of argument passed to inotify_init1. inotify_init1 flags can be IN_NONBLOCK and IN_CLOEXEC which rely on O_NONBLOCK and O_CLOEXEC and those can have different values on different platforms.
--- linux-user/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
linux-user/syscall.c +2 -1
@@ -11625,7 +11625,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,#ifdef CONFIG_INOTIFY1 #if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1)case TARGET_NR_inotify_init1: - ret =get_errno (sys_inotify_init1 (arg1)); + ret =get_errno (sys_inotify_init1 (target_to_host_bitmask (arg1, + fcntl_flags_tbl)));break ;#endif #endif
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 2/7] linux-user: Fix inotify_init1 support
Quoted 14 lines · Lena Djokic
This commit adds necessary conversion of argument passed to
inotify_init1.inotify_init1flags can beIN_NONBLOCKandIN_CLOEXECwhich rely onO_NONBLOCKandO_CLOEXECand those can have different values on different platforms.Signed-off-by Lena Djokic <[email protected]>--- linux-user/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)linux-user/syscall.c +0
-0
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 11632
Quoted 9 lines
linux-user/syscall.c +2
-1@@ -11625,7 +11625,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,#ifdef CONFIG_INOTIFY1 #if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1)case TARGET_NR_inotify_init1: - ret =get_errno (sys_inotify_init1 (arg1)); + ret =get_errno (sys_inotify_init1 (target_to_host_bitmask (arg1, + fcntl_flags_tbl)));break ;#endif #endif
thanks
-- PMM
Riku Voipio
AppliedRe: [Qemu-devel] [PATCH v2 2/7] linux-user: Fix inotify_init1 support
In reply to Lena DjokicQuoted 3 lines · Lena Djokic
This commit adds necessary conversion of argument passed to
inotify_init1.inotify_init1flags can beIN_NONBLOCKandIN_CLOEXECwhich rely onO_NONBLOCKandO_CLOEXECand those can have different values on different platforms.
Thanks, applied to linux-user
Quoted 22 lines
Signed-off-by Lena Djokic <[email protected]>--- linux-user/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)linux-user/syscall.c +2
-1@@ -11625,7 +11625,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,#ifdef CONFIG_INOTIFY1 #if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1)case TARGET_NR_inotify_init1: - ret =get_errno (sys_inotify_init1 (arg1)); + ret =get_errno (sys_inotify_init1 (target_to_host_bitmask (arg1, + fcntl_flags_tbl)));break ;#endif #endif Signature · 1 line
2.7.4
PATCH v2 3/7 linux-user: Fix flock definition for mips64
In reply to Lena DjokicMips64 uses generic flock structure.
See /arch/mips/include/uapi/asm/fcntl.h#L63 for reference.
--- linux-user/syscall_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/syscall_defs.h +1 -1
@@ -2363,7 +2363,7 @@ struct target_flock {short l_whence;abi_long l_start;abi_long l_len; -#if defined(TARGET_MIPS ) +#if defined(TARGET_MIPS ) && (TARGET_ABI_BITS ==32 )abi_long l_sysid;#endif int l_pid;
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 3/7] linux-user: Fix flock definition for mips64
Quoted 13 lines · Lena Djokic
Mips64 uses generic flock structure.
See /arch/mips/include/uapi/asm/fcntl.h#L63 for reference.Signed-off-by Lena Djokic <[email protected]>--- linux-user/syscall_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)linux-user/syscall_defs.h +0
-0
linux-user/syscall_defs.h struct target_flock { · line 2369
Quoted 8 lines
linux-user/syscall_defs.h +1
-1@@ -2363,7 +2363,7 @@ struct target_flock {short l_whence;abi_long l_start;abi_long l_len; -#if defined(TARGET_MIPS ) +#if defined(TARGET_MIPS ) && (TARGET_ABI_BITS ==32 )abi_long l_sysid;#endif int l_pid;
Does the #if around the 'pad' field of this struct need adjusting too ?
thanks
-- PMM
PATCH v2 4/7 linux-user: Fix fcnt
In reply to Lena DjokicF_GETSIG and F_SETSIG were implemented with default behaviour which simply passes given arguments to fcntl syscall, but since those arguments are signals used for communication between taget and host we need conversion which is done by using host_to_target_signal and taget_to_host_signal functions.
--- linux-user/syscall.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
linux-user/syscall.c +6 -2
@@ -6544,14 +6544,18 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg)case TARGET_F_SETOWN :case TARGET_F_GETOWN : -case TARGET_F_SETSIG : -case TARGET_F_GETSIG :case TARGET_F_SETLEASE :case TARGET_F_GETLEASE :case TARGET_F_SETPIPE_SZ :case TARGET_F_GETPIPE_SZ : ret =get_errno (safe_fcntl (fd, host_cmd, arg));break ; +case TARGET_F_GETSIG : + ret =host_to_target_signal (get_errno (fcntl (fd, host_cmd, arg))); +break ; +case TARGET_F_SETSIG : + ret =get_errno (fcntl (fd, host_cmd,target_to_host_signal (arg))); +break ;default : ret =get_errno (safe_fcntl (fd, cmd, arg));
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 4/7] linux-user: Fix fcnt
On 24 November 2016 at 16:08, Lena Djokic <[email protected]> wrote:
Making the subject line "linux-user: fix F_GETSIG and F_SETSIG fcntls" would be a bit more precise about what we're fixing here and I think that will be helpful for people looking back in the git log later.
Quoted 3 lines
F_GETSIGandF_SETSIGwere implemented with default behaviour which simply passes given arguments to fcntl syscall, but since those arguments are signals used for communication between taget and
typo: "target"
Quoted 2 lines
host we need conversion which is done by using
host_to_targetsignal andtaget_to_host_signalfunctions.
"target"
Quoted 18 lines
Signed-off-by Lena Djokic <[email protected]>--- linux-user/syscall.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)linux-user/syscall.c +0
-2@@ -6544,14 +6544,18 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg)case TARGET_F_SETOWN :case TARGET_F_GETOWN : -case TARGET_F_SETSIG : -case TARGET_F_GETSIG :case TARGET_F_SETLEASE :case TARGET_F_GETLEASE :
linux-user/syscall.c static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) · line 6558
Quoted 10 lines
linux-user/syscall.c +6
-0case TARGET_F_SETPIPE_SZ :case TARGET_F_GETPIPE_SZ : ret =get_errno (safe_fcntl (fd, host_cmd, arg));break ; +case TARGET_F_GETSIG : + ret =host_to_target_signal (get_errno (fcntl (fd, host_cmd, arg))); +break ; +case TARGET_F_SETSIG : + ret =get_errno (fcntl (fd, host_cmd,target_to_host_signal (arg))); +break ;
This is basically right, but I suggest some minor changes:
* put these special cases above the long list of 'just call fcntl' cases, not below it
* these should both call safe_fcntl(), not fcntl()
* don't call host_to_target_signal() unless we know the call succeeded (compare the code used for TARGET_F_GETLK, TARGET_F_GETFL, etc)
linux-user/syscall.c static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) · line 6561
Quoted 3 lines
linux-user/syscall.c +0
-0default : ret =get_errno (safe_fcntl (fd, cmd, arg));
thanks
-- PMM
PATCH v2 5/7 linux-user: Fix readahead
In reply to Lena DjokicCalculation of 64-bit offset was not correct for all cases.
--- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/syscall.c +1 -1
@@ -11296,7 +11296,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, arg3 = arg4; arg4 = arg5; } - ret =get_errno (readahead (arg1, ((off64_t )arg3 <<32 ) | arg2, arg4)); + ret =get_errno (readahead (arg1,target_offset64 (arg2, arg3) , arg4));#else ret =get_errno (readahead (arg1, arg2, arg3));#endif
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 5/7] linux-user: Fix readahead
Quoted 12 lines · Lena Djokic
Calculation of 64-bit offset was not correct for all cases.
Signed-off-by Lena Djokic <[email protected]>--- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)linux-user/syscall.c +0
-0
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 11302
Quoted 8 lines
linux-user/syscall.c +1
-1@@ -11296,7 +11296,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, arg3 = arg4; arg4 = arg5; } - ret =get_errno (readahead (arg1, ((off64_t )arg3 <<32 ) | arg2, arg4)); + ret =get_errno (readahead (arg1,target_offset64 (arg2, arg3) , arg4));#else ret =get_errno (readahead (arg1, arg2, arg3));#endif
thanks
-- PMM
Riku Voipio
AppliedRe: [Qemu-devel] [PATCH v2 5/7] linux-user: Fix readahead
In reply to Lena DjokicQuoted 1 line · Lena Djokic
Calculation of 64-bit offset was not correct for all cases.
Thanks, applied to linux-user
Quoted 21 lines
Signed-off-by Lena Djokic <[email protected]>--- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)linux-user/syscall.c +1
-1@@ -11296,7 +11296,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, arg3 = arg4; arg4 = arg5; } - ret =get_errno (readahead (arg1, ((off64_t )arg3 <<32 ) | arg2, arg4)); + ret =get_errno (readahead (arg1,target_offset64 (arg2, arg3) , arg4));#else ret =get_errno (readahead (arg1, arg2, arg3));#endif Signature · 1 line
2.7.4
PATCH v2 6/7 linux-user: Fix syslog
In reply to Lena DjokicThird argument represents lenght not second.
If second argument is NULL it should be passed without using lock_user function which would, in that case, return EFAULT, and system call supports passing NULL as second argument.
--- linux-user/syscall.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
linux-user/syscall.c +8 -8
@@ -9426,7 +9426,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,#if defined(TARGET_NR_syslog)case TARGET_NR_syslog: { -int len = arg2; +int len = arg3;switch (arg1) {case TARGET_SYSLOG_ACTION_CLOSE :/* Close log */
@@ -9450,13 +9450,13 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, goto fail; } ret =0 ; -if (len ==0 ) { -break ; - } - p =lock_user (VERIFY_WRITE , arg2, arg3,0 ); -if (!p) { - ret = -TARGET_EFAULT ; - goto fail; + p =NULL ; +if (arg2) { + p =lock_user (VERIFY_WRITE , arg2, arg3,0 ); +if (!p) { + ret = -TARGET_EFAULT ; + goto fail; + } } ret =get_errno (sys_syslog ((int )arg1, p, (int )arg3));unlock_user (p, arg2, arg3);
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 6/7] linux-user: Fix syslog
Quoted 1 line · Lena Djokic
Third argument represents lenght not second.
typo: "length"
Quoted 3 lines
If second argument is NULL it should be passed without using
lock_userfunction which would, in that case, return EFAULT, and system call supports passing NULL as second argument.
Looking at the kernel code, it doesn't support NULL as the second argument for the three actions here (READ, READ_CLEAR, READ_ALL) -- they all fail EINVAL. So what we're doing here is just returning a better errno. I think we can do this more simply by just changing the current
if (len < 0) {
goto fail;
}to "if (!arg2 || len < 0) {" (which is what the kernel code does).
(I think it would also be reasonable to consistently use "len" and never "arg3" (the existing code has an odd mix of both); if you want to do that cleanup you could add an extra patch for it, but you don't have to.)
Quoted 40 lines
Signed-off-by Lena Djokic <[email protected]>--- linux-user/syscall.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)linux-user/syscall.c +8
-9@@ -9426,7 +9426,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,#if defined(TARGET_NR_syslog)case TARGET_NR_syslog: { -int len = arg2; +int len = arg3;switch (arg1) {case TARGET_SYSLOG_ACTION_CLOSE :/* Close log */ @@ -9450,13 +9450,13 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, goto fail; } ret =0 ; -if (len ==0 ) { -break ; - } - p =lock_user (VERIFY_WRITE , arg2, arg3,0 ); -if (!p) { - ret = -TARGET_EFAULT ; - goto fail; + p =NULL ; +if (arg2) { + p =lock_user (VERIFY_WRITE , arg2, arg3,0 ); +if (!p) { + ret = -TARGET_EFAULT ; + goto fail; + } } ret =get_errno (sys_syslog ((int )arg1, p, (int )arg3));unlock_user (p, arg2, arg3); --
Quoted 1 line
2.7.4
thanks
-- PMM
PATCH v2 7/7 linux-user: Fix mq_open
In reply to Lena DjokicIf fourth argument is NULL it should be passed without using lock_user function which would, in that case, return EFAULT, and system call supports passing NULL as fourth argument.
--- linux-user/syscall.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
linux-user/syscall.c +8 -3
@@ -11694,17 +11694,22 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,case TARGET_NR_mq_open: {struct mq_attr posix_mq_attr; +struct mq_attr *pposix_mq_attr;int host_flags; host_flags =target_to_host_bitmask (arg2, fcntl_flags_tbl); -if (copy_from_user_mq_attr (&posix_mq_attr, arg4) !=0 ) { - goto efault; + pposix_mq_attr =NULL ; +if (arg4) { +if (copy_from_user_mq_attr (&posix_mq_attr, arg4) !=0 ) { + goto efault; + } + pposix_mq_attr = &posix_mq_attr; } p =lock_user_string (arg1 -1 );if (!p) { goto efault; } - ret =get_errno (mq_open (p, host_flags, arg3, &posix_mq_attr)); + ret =get_errno (mq_open (p, host_flags, arg3, pposix_mq_attr));unlock_user (p, arg1,0 ); }break ;
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 7/7] linux-user: Fix mq_open
Quoted 40 lines · Lena Djokic
If fourth argument is NULL it should be passed without using
lock_userfunction which would, in that case, return EFAULT, and system call supports passing NULL as fourth argument.Signed-off-by Lena Djokic <[email protected]>--- linux-user/syscall.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)linux-user/syscall.c +8
-4@@ -11694,17 +11694,22 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,case TARGET_NR_mq_open: {struct mq_attr posix_mq_attr; +struct mq_attr *pposix_mq_attr;int host_flags; host_flags =target_to_host_bitmask (arg2, fcntl_flags_tbl); -if (copy_from_user_mq_attr (&posix_mq_attr, arg4) !=0 ) { - goto efault; + pposix_mq_attr =NULL ; +if (arg4) { +if (copy_from_user_mq_attr (&posix_mq_attr, arg4) !=0 ) { + goto efault; + } + pposix_mq_attr = &posix_mq_attr; } p =lock_user_string (arg1 -1 );if (!p) { goto efault; } - ret =get_errno (mq_open (p, host_flags, arg3, &posix_mq_attr)); + ret =get_errno (mq_open (p, host_flags, arg3, pposix_mq_attr));unlock_user (p, arg1,0 ); }break ; --
Quoted 1 line
2.7.4
thanks
-- PMM
Riku Voipio
AppliedRe: [Qemu-devel] [PATCH v2 7/7] linux-user: Fix mq_open
In reply to Lena DjokicQuoted 3 lines · Lena Djokic
If fourth argument is NULL it should be passed without using
lock_userfunction which would, in that case, return EFAULT, and system call supports passing NULL as fourth argument.
Thanks, applied to linux-user
Quoted 38 lines
Signed-off-by Lena Djokic <[email protected]>--- linux-user/syscall.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)linux-user/syscall.c +8
-3@@ -11694,17 +11694,22 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,case TARGET_NR_mq_open: {struct mq_attr posix_mq_attr; +struct mq_attr *pposix_mq_attr;int host_flags; host_flags =target_to_host_bitmask (arg2, fcntl_flags_tbl); -if (copy_from_user_mq_attr (&posix_mq_attr, arg4) !=0 ) { - goto efault; + pposix_mq_attr =NULL ; +if (arg4) { +if (copy_from_user_mq_attr (&posix_mq_attr, arg4) !=0 ) { + goto efault; + } + pposix_mq_attr = &posix_mq_attr; } p =lock_user_string (arg1 -1 );if (!p) { goto efault; } - ret =get_errno (mq_open (p, host_flags, arg3, &posix_mq_attr)); + ret =get_errno (mq_open (p, host_flags, arg3, pposix_mq_attr));unlock_user (p, arg1,0 ); }break ;Signature · 1 line
2.7.4