All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/3] linux-user: Implement missing *xattr calls
@ 2011-12-14 15:37 Peter Maydell
  2011-12-14 15:37 ` [Qemu-devel] [PATCH 1/3] linux-user: Allow NULL value pointer in setxattr and getxattr Peter Maydell
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Peter Maydell @ 2011-12-14 15:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio, patches

These patches implement the missing *xattr syscalls:
 listxattr
 fsetattr, fgetattr, fremovexattr, flistxattr
 lsetattr, lgetattr, lremovexattr, llistxattr

They also fix a bug in the existing code where we weren't allowing a
NULL value pointer.

Tested with the testcases in crackerjack. (There are some cases where
we don't behave exactly like the native kernel:
 * we check for bad pointers earlier, so tend to return EFAULT when the
   kernel might return EINVAL in a "caller did two wrong things" case
 * we insist on the whole of the caller's buffer being writable whereas
   the kernel only cares about being able to write the data it actually
   needs, so we will fail EFAULT some bad callers that the kernel doesn't
I don't think these are important.)

Peter Maydell (3):
  linux-user: Allow NULL value pointer in setxattr and getxattr
  linux-user/syscall.c: Implement f and l versions of
    set/get/removexattr
  linux-user: Implement *listxattr syscalls

 linux-user/syscall.c |  139 ++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 123 insertions(+), 16 deletions(-)

-- 
1.7.5.4

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

* [Qemu-devel] [PATCH 1/3] linux-user: Allow NULL value pointer in setxattr and getxattr
  2011-12-14 15:37 [Qemu-devel] [PATCH 0/3] linux-user: Implement missing *xattr calls Peter Maydell
@ 2011-12-14 15:37 ` Peter Maydell
  2011-12-14 15:37 ` [Qemu-devel] [PATCH 2/3] linux-user/syscall.c: Implement f and l versions of set/get/removexattr Peter Maydell
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2011-12-14 15:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio, patches

It's valid to pass a NULL value pointer to setxattr, so don't
fail this case EFAULT.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 linux-user/syscall.c |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index f227097..ca4503d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7655,11 +7655,17 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
         break;
     case TARGET_NR_setxattr:
         {
-            void *p, *n, *v;
+            void *p, *n, *v = 0;
+            if (arg3) {
+                v = lock_user(VERIFY_READ, arg3, arg4, 1);
+                if (!v) {
+                    ret = -TARGET_EFAULT;
+                    break;
+                }
+            }
             p = lock_user_string(arg1);
             n = lock_user_string(arg2);
-            v = lock_user(VERIFY_READ, arg3, arg4, 1);
-            if (p && n && v) {
+            if (p && n) {
                 ret = get_errno(setxattr(p, n, v, arg4, arg5));
             } else {
                 ret = -TARGET_EFAULT;
@@ -7671,11 +7677,17 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
         break;
     case TARGET_NR_getxattr:
         {
-            void *p, *n, *v;
+            void *p, *n, *v = 0;
+            if (arg3) {
+                v = lock_user(VERIFY_WRITE, arg3, arg4, 0);
+                if (!v) {
+                    ret = -TARGET_EFAULT;
+                    break;
+                }
+            }
             p = lock_user_string(arg1);
             n = lock_user_string(arg2);
-            v = lock_user(VERIFY_WRITE, arg3, arg4, 0);
-            if (p && n && v) {
+            if (p && n) {
                 ret = get_errno(getxattr(p, n, v, arg4));
             } else {
                 ret = -TARGET_EFAULT;
-- 
1.7.5.4

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

* [Qemu-devel] [PATCH 2/3] linux-user/syscall.c: Implement f and l versions of set/get/removexattr
  2011-12-14 15:37 [Qemu-devel] [PATCH 0/3] linux-user: Implement missing *xattr calls Peter Maydell
  2011-12-14 15:37 ` [Qemu-devel] [PATCH 1/3] linux-user: Allow NULL value pointer in setxattr and getxattr Peter Maydell
@ 2011-12-14 15:37 ` Peter Maydell
  2011-12-14 15:37 ` [Qemu-devel] [PATCH 3/3] linux-user: Implement *listxattr syscalls Peter Maydell
  2012-01-04 11:39 ` [Qemu-devel] [PATCH 0/3] linux-user: Implement missing *xattr calls Peter Maydell
  3 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2011-12-14 15:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio, patches

Implement the f and l versions (operate on fd, don't follow links)
of the setxattr, getxattr and removexattr syscalls.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 linux-user/syscall.c |   79 ++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 70 insertions(+), 9 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index ca4503d..a4596c0 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7642,18 +7642,13 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
 #endif
 #ifdef CONFIG_ATTR
 #ifdef TARGET_NR_setxattr
-    case TARGET_NR_lsetxattr:
-    case TARGET_NR_fsetxattr:
-    case TARGET_NR_lgetxattr:
-    case TARGET_NR_fgetxattr:
     case TARGET_NR_listxattr:
     case TARGET_NR_llistxattr:
     case TARGET_NR_flistxattr:
-    case TARGET_NR_lremovexattr:
-    case TARGET_NR_fremovexattr:
         ret = -TARGET_EOPNOTSUPP;
         break;
     case TARGET_NR_setxattr:
+    case TARGET_NR_lsetxattr:
         {
             void *p, *n, *v = 0;
             if (arg3) {
@@ -7666,7 +7661,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             p = lock_user_string(arg1);
             n = lock_user_string(arg2);
             if (p && n) {
-                ret = get_errno(setxattr(p, n, v, arg4, arg5));
+                if (num == TARGET_NR_setxattr) {
+                    ret = get_errno(setxattr(p, n, v, arg4, arg5));
+                } else {
+                    ret = get_errno(lsetxattr(p, n, v, arg4, arg5));
+                }
             } else {
                 ret = -TARGET_EFAULT;
             }
@@ -7675,7 +7674,28 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             unlock_user(v, arg3, 0);
         }
         break;
+    case TARGET_NR_fsetxattr:
+        {
+            void *n, *v = 0;
+            if (arg3) {
+                v = lock_user(VERIFY_READ, arg3, arg4, 1);
+                if (!v) {
+                    ret = -TARGET_EFAULT;
+                    break;
+                }
+            }
+            n = lock_user_string(arg2);
+            if (n) {
+                ret = get_errno(fsetxattr(arg1, n, v, arg4, arg5));
+            } else {
+                ret = -TARGET_EFAULT;
+            }
+            unlock_user(n, arg2, 0);
+            unlock_user(v, arg3, 0);
+        }
+        break;
     case TARGET_NR_getxattr:
+    case TARGET_NR_lgetxattr:
         {
             void *p, *n, *v = 0;
             if (arg3) {
@@ -7688,7 +7708,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             p = lock_user_string(arg1);
             n = lock_user_string(arg2);
             if (p && n) {
-                ret = get_errno(getxattr(p, n, v, arg4));
+                if (num == TARGET_NR_getxattr) {
+                    ret = get_errno(getxattr(p, n, v, arg4));
+                } else {
+                    ret = get_errno(lgetxattr(p, n, v, arg4));
+                }
             } else {
                 ret = -TARGET_EFAULT;
             }
@@ -7697,13 +7721,38 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             unlock_user(v, arg3, arg4);
         }
         break;
+    case TARGET_NR_fgetxattr:
+        {
+            void *n, *v = 0;
+            if (arg3) {
+                v = lock_user(VERIFY_WRITE, arg3, arg4, 0);
+                if (!v) {
+                    ret = -TARGET_EFAULT;
+                    break;
+                }
+            }
+            n = lock_user_string(arg2);
+            if (n) {
+                ret = get_errno(fgetxattr(arg1, n, v, arg4));
+            } else {
+                ret = -TARGET_EFAULT;
+            }
+            unlock_user(n, arg2, 0);
+            unlock_user(v, arg3, arg4);
+        }
+        break;
     case TARGET_NR_removexattr:
+    case TARGET_NR_lremovexattr:
         {
             void *p, *n;
             p = lock_user_string(arg1);
             n = lock_user_string(arg2);
             if (p && n) {
-                ret = get_errno(removexattr(p, n));
+                if (num == TARGET_NR_removexattr) {
+                    ret = get_errno(removexattr(p, n));
+                } else {
+                    ret = get_errno(lremovexattr(p, n));
+                }
             } else {
                 ret = -TARGET_EFAULT;
             }
@@ -7711,6 +7760,18 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             unlock_user(n, arg2, 0);
         }
         break;
+    case TARGET_NR_fremovexattr:
+        {
+            void *n;
+            n = lock_user_string(arg2);
+            if (n) {
+                ret = get_errno(fremovexattr(arg1, n));
+            } else {
+                ret = -TARGET_EFAULT;
+            }
+            unlock_user(n, arg2, 0);
+        }
+        break;
 #endif
 #endif /* CONFIG_ATTR */
 #ifdef TARGET_NR_set_thread_area
-- 
1.7.5.4

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

* [Qemu-devel] [PATCH 3/3] linux-user: Implement *listxattr syscalls
  2011-12-14 15:37 [Qemu-devel] [PATCH 0/3] linux-user: Implement missing *xattr calls Peter Maydell
  2011-12-14 15:37 ` [Qemu-devel] [PATCH 1/3] linux-user: Allow NULL value pointer in setxattr and getxattr Peter Maydell
  2011-12-14 15:37 ` [Qemu-devel] [PATCH 2/3] linux-user/syscall.c: Implement f and l versions of set/get/removexattr Peter Maydell
@ 2011-12-14 15:37 ` Peter Maydell
  2012-01-04 11:39 ` [Qemu-devel] [PATCH 0/3] linux-user: Implement missing *xattr calls Peter Maydell
  3 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2011-12-14 15:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio, patches

Implement listxattr, flistxattr and llistxattr syscalls.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 linux-user/syscall.c |   36 +++++++++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index a4596c0..17c8852 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7644,9 +7644,43 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_setxattr
     case TARGET_NR_listxattr:
     case TARGET_NR_llistxattr:
+    {
+        void *p, *b = 0;
+        if (arg2) {
+            b = lock_user(VERIFY_WRITE, arg2, arg3, 0);
+            if (!b) {
+                ret = -TARGET_EFAULT;
+                break;
+            }
+        }
+        p = lock_user_string(arg1);
+        if (p) {
+            if (num == TARGET_NR_listxattr) {
+                ret = get_errno(listxattr(p, b, arg3));
+            } else {
+                ret = get_errno(llistxattr(p, b, arg3));
+            }
+        } else {
+            ret = -TARGET_EFAULT;
+        }
+        unlock_user(p, arg1, 0);
+        unlock_user(b, arg2, arg3);
+        break;
+    }
     case TARGET_NR_flistxattr:
-        ret = -TARGET_EOPNOTSUPP;
+    {
+        void *b = 0;
+        if (arg2) {
+            b = lock_user(VERIFY_WRITE, arg2, arg3, 0);
+            if (!b) {
+                ret = -TARGET_EFAULT;
+                break;
+            }
+        }
+        ret = get_errno(flistxattr(arg1, b, arg3));
+        unlock_user(b, arg2, arg3);
         break;
+    }
     case TARGET_NR_setxattr:
     case TARGET_NR_lsetxattr:
         {
-- 
1.7.5.4

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

* Re: [Qemu-devel] [PATCH 0/3] linux-user: Implement missing *xattr calls
  2011-12-14 15:37 [Qemu-devel] [PATCH 0/3] linux-user: Implement missing *xattr calls Peter Maydell
                   ` (2 preceding siblings ...)
  2011-12-14 15:37 ` [Qemu-devel] [PATCH 3/3] linux-user: Implement *listxattr syscalls Peter Maydell
@ 2012-01-04 11:39 ` Peter Maydell
  2012-01-27 14:32   ` Peter Maydell
  3 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2012-01-04 11:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio, patches

Ping?

-- PMM

On 14 December 2011 15:37, Peter Maydell <peter.maydell@linaro.org> wrote:
> These patches implement the missing *xattr syscalls:
>  listxattr
>  fsetattr, fgetattr, fremovexattr, flistxattr
>  lsetattr, lgetattr, lremovexattr, llistxattr
>
> They also fix a bug in the existing code where we weren't allowing a
> NULL value pointer.
>
> Tested with the testcases in crackerjack. (There are some cases where
> we don't behave exactly like the native kernel:
>  * we check for bad pointers earlier, so tend to return EFAULT when the
>   kernel might return EINVAL in a "caller did two wrong things" case
>  * we insist on the whole of the caller's buffer being writable whereas
>   the kernel only cares about being able to write the data it actually
>   needs, so we will fail EFAULT some bad callers that the kernel doesn't
> I don't think these are important.)
>
> Peter Maydell (3):
>  linux-user: Allow NULL value pointer in setxattr and getxattr
>  linux-user/syscall.c: Implement f and l versions of
>    set/get/removexattr
>  linux-user: Implement *listxattr syscalls
>
>  linux-user/syscall.c |  139 ++++++++++++++++++++++++++++++++++++++++++++------
>  1 files changed, 123 insertions(+), 16 deletions(-)
>
> --
> 1.7.5.4
>
>

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

* Re: [Qemu-devel] [PATCH 0/3] linux-user: Implement missing *xattr calls
  2012-01-04 11:39 ` [Qemu-devel] [PATCH 0/3] linux-user: Implement missing *xattr calls Peter Maydell
@ 2012-01-27 14:32   ` Peter Maydell
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2012-01-27 14:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio, patches

Ping^2 ?

-- PMM

On 4 January 2012 11:39, Peter Maydell <peter.maydell@linaro.org> wrote:
> Ping?
>
> -- PMM
>
> On 14 December 2011 15:37, Peter Maydell <peter.maydell@linaro.org> wrote:
>> These patches implement the missing *xattr syscalls:
>>  listxattr
>>  fsetattr, fgetattr, fremovexattr, flistxattr
>>  lsetattr, lgetattr, lremovexattr, llistxattr
>>
>> They also fix a bug in the existing code where we weren't allowing a
>> NULL value pointer.
>>
>> Tested with the testcases in crackerjack. (There are some cases where
>> we don't behave exactly like the native kernel:
>>  * we check for bad pointers earlier, so tend to return EFAULT when the
>>   kernel might return EINVAL in a "caller did two wrong things" case
>>  * we insist on the whole of the caller's buffer being writable whereas
>>   the kernel only cares about being able to write the data it actually
>>   needs, so we will fail EFAULT some bad callers that the kernel doesn't
>> I don't think these are important.)
>>
>> Peter Maydell (3):
>>  linux-user: Allow NULL value pointer in setxattr and getxattr
>>  linux-user/syscall.c: Implement f and l versions of
>>    set/get/removexattr
>>  linux-user: Implement *listxattr syscalls
>>
>>  linux-user/syscall.c |  139 ++++++++++++++++++++++++++++++++++++++++++++------
>>  1 files changed, 123 insertions(+), 16 deletions(-)
>>
>> --
>> 1.7.5.4
>>
>>

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

end of thread, other threads:[~2012-01-27 14:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-14 15:37 [Qemu-devel] [PATCH 0/3] linux-user: Implement missing *xattr calls Peter Maydell
2011-12-14 15:37 ` [Qemu-devel] [PATCH 1/3] linux-user: Allow NULL value pointer in setxattr and getxattr Peter Maydell
2011-12-14 15:37 ` [Qemu-devel] [PATCH 2/3] linux-user/syscall.c: Implement f and l versions of set/get/removexattr Peter Maydell
2011-12-14 15:37 ` [Qemu-devel] [PATCH 3/3] linux-user: Implement *listxattr syscalls Peter Maydell
2012-01-04 11:39 ` [Qemu-devel] [PATCH 0/3] linux-user: Implement missing *xattr calls Peter Maydell
2012-01-27 14:32   ` Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.