Skip to contentSkip to conversation

linux-user: Support prctl PR_GET/SET_NAME

PATCH In review Peter Maydell 3 participants 8 messages Feb 3, 2012 – Mar 21, 2012

lore
Share & tools
lore
#0 lore raw

cover linux-user: Support prctl PR_GET/SET_NAME

These patches add support for the prctl options PR_GET_NAME and PR_SET_NAME. In particular, perl 5.14 will use PR_SET_NAME if you change the value of $0, which means that adduser will fail if run under qemu with a sufficiently modern perl.

Patch one is just indentation cleanup, the meat is patch 2.

The only other prctl options which take pointer arguments are all architecture specific, so there didn't seem much point in adding them (they all work like PR_GET_PDEATHSIG in that they pass an int* to be filled in); we'd have to actually emulate them if we cared about them.

Peter Maydell (2):
linux-user/syscall.c: Fix indentation in prctl handling
linux-user: Add support for prctl PR_GET_NAME and PR_SET_NAME

 linux-user/syscall.c |   53 ++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 39 insertions(+), 14 deletions(-)
#1 lore raw

PATCH 1/2 linux-user/syscall.c: Fix indentation in prctl handling

Clean up the odd indentation of this switch statement before we double its size by adding new cases to it.

---
 linux-user/syscall.c |   29 +++++++++++++++--------------
 1 files changed, 15 insertions(+), 14 deletions(-)
linux-user/syscall.c +15 -14
index 2bf9e7e..7851fb5 100644
@@ -6842,21 +6842,22 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
         goto unimplemented;
 #endif
     case TARGET_NR_prctl:
-        switch (arg1)
-            {
-            case PR_GET_PDEATHSIG:
-                {
-                    int deathsig;
-                    ret = get_errno(prctl(arg1, &deathsig, arg3, arg4, arg5));
-                    if (!is_error(ret) && arg2
-                        && put_user_ual(deathsig, arg2))
-                        goto efault;
-                }
-                break;
-            default:
-                ret = get_errno(prctl(arg1, arg2, arg3, arg4, arg5));
-                break;
+        switch (arg1) {
+        case PR_GET_PDEATHSIG:
+        {
+            int deathsig;
+            ret = get_errno(prctl(arg1, &deathsig, arg3, arg4, arg5));
+            if (!is_error(ret) && arg2
+                && put_user_ual(deathsig, arg2)) {
+                goto efault;
             }
+            break;
+        }
+        default:
+            /* Most prctl options have no pointer arguments */
+            ret = get_errno(prctl(arg1, arg2, arg3, arg4, arg5));
+            break;
+        }
         break;
 #ifdef TARGET_NR_arch_prctl
     case TARGET_NR_arch_prctl:
Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/2 linux-user: Add support for prctl PR_GET_NAME and PR_SET_NAME

In reply to Peter Maydell

Add support for the prctl options PR_GET_NAME and PR_SET_NAME, which take or return a name in a 16 byte buffer pointed to by arg2.

---
 linux-user/syscall.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
linux-user/syscall.c +24 -0
index 7851fb5..489a8c2 100644
@@ -6853,6 +6853,30 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             }
             break;
         }
+#ifdef PR_GET_NAME
+        case PR_GET_NAME:
+        {
+            void *name = lock_user(VERIFY_WRITE, arg2, 16, 1);
+            if (!name) {
+                goto efault;
+            }
+            ret = get_errno(prctl(arg1, (unsigned long)name,
+                                  arg3, arg4, arg5));
+            unlock_user(name, arg2, 16);
+            break;
+        }
+        case PR_SET_NAME:
+        {
+            void *name = lock_user(VERIFY_READ, arg2, 16, 1);
+            if (!name) {
+                goto efault;
+            }
+            ret = get_errno(prctl(arg1, (unsigned long)name,
+                                  arg3, arg4, arg5));
+            unlock_user(name, arg2, 0);
+            break;
+        }
+#endif
         default:
             /* Most prctl options have no pointer arguments */
             ret = get_errno(prctl(arg1, arg2, arg3, arg4, arg5));
Signature · 1 line
1.7.1
#3 lore raw
In reply to Peter Maydell

Ping?

Quoted 21 lines · Peter Maydell

These patches add support for the prctl options PR_GET_NAME and PR_SET_NAME. In particular, perl 5.14 will use PR_SET_NAME if you change the value of $0, which means that adduser will fail if run under qemu with a sufficiently modern perl.

Patch one is just indentation cleanup, the meat is patch 2.

The only other prctl options which take pointer arguments are all architecture specific, so there didn't seem much point in adding them (they all work like PR_GET_PDEATHSIG in that they pass an int* to be filled in); we'd have to actually emulate them if we cared about them.

Peter Maydell (2):
 linux-user/syscall.c: Fix indentation in prctl handling
 linux-user: Add support for prctl PR_GET_NAME and PR_SET_NAME

 linux-user/syscall.c |   53 ++++++++++++++++++++++++++++++++++++-------------

 1 files changed, 39 insertions(+), 14 deletions(-)
Tested-by
#4 lore raw

Hello,

2012/2/22 Peter Maydell <[email protected]>:

Quoted 1 line

Ping?

In case it helps, I have successfully tested this patch running adduser on Debian armhf target emulated via qemu-arm-static.

Quoted 23 lines · Peter Maydell
Quoted 21 lines

These patches add support for the prctl options PR_GET_NAME and PR_SET_NAME. In particular, perl 5.14 will use PR_SET_NAME if you change the value of $0, which means that adduser will fail if run under qemu with a sufficiently modern perl.

Patch one is just indentation cleanup, the meat is patch 2.

The only other prctl options which take pointer arguments are all architecture specific, so there didn't seem much point in adding them (they all work like PR_GET_PDEATHSIG in that they pass an int* to be filled in); we'd have to actually emulate them if we cared about them.

Peter Maydell (2):
 linux-user/syscall.c: Fix indentation in prctl handling
 linux-user: Add support for prctl PR_GET_NAME and PR_SET_NAME

 linux-user/syscall.c |   53 ++++++++++++++++++++++++++++++++++++-------------

 1 files changed, 39 insertions(+), 14 deletions(-)
Signature · 1 line
 Héctor Orón  -.. . -... .. .- -.   -.. . ...- . .-.. --- .--. . .-.
#5 lore raw
In reply to Peter Maydell

Ping^2 ?

-- PMM

Quoted 24 lines · Peter Maydell

Ping?

Quoted 21 lines · Peter Maydell

These patches add support for the prctl options PR_GET_NAME and PR_SET_NAME. In particular, perl 5.14 will use PR_SET_NAME if you change the value of $0, which means that adduser will fail if run under qemu with a sufficiently modern perl.

Patch one is just indentation cleanup, the meat is patch 2.

The only other prctl options which take pointer arguments are all architecture specific, so there didn't seem much point in adding them (they all work like PR_GET_PDEATHSIG in that they pass an int* to be filled in); we'd have to actually emulate them if we cared about them.

Peter Maydell (2):
 linux-user/syscall.c: Fix indentation in prctl handling
 linux-user: Add support for prctl PR_GET_NAME and PR_SET_NAME

 linux-user/syscall.c |   53 ++++++++++++++++++++++++++++++++++++-------------

 1 files changed, 39 insertions(+), 14 deletions(-)
Signature · 2 lines
12345678901234567890123456789012345678901234567890123456789012345678901234567890
         1         2         3         4         5         6         7         8
#6 lore raw

Ping^3 (past the six-week mark now...)

-- PMM

Quoted 30 lines · Peter Maydell

Ping^2 ?

-- PMM

Quoted 24 lines · Peter Maydell

Ping?

Quoted 21 lines · Peter Maydell

These patches add support for the prctl options PR_GET_NAME and PR_SET_NAME. In particular, perl 5.14 will use PR_SET_NAME if you change the value of $0, which means that adduser will fail if run under qemu with a sufficiently modern perl.

Patch one is just indentation cleanup, the meat is patch 2.

The only other prctl options which take pointer arguments are all architecture specific, so there didn't seem much point in adding them (they all work like PR_GET_PDEATHSIG in that they pass an int* to be filled in); we'd have to actually emulate them if we cared about them.

Peter Maydell (2):
 linux-user/syscall.c: Fix indentation in prctl handling
 linux-user: Add support for prctl PR_GET_NAME and PR_SET_NAME

 linux-user/syscall.c |   53 ++++++++++++++++++++++++++++++++++++-------------

 1 files changed, 39 insertions(+), 14 deletions(-)
#7 lore raw

Hi,

looks like I'll be busy for the rest of the of the month :/

Riku

Quoted 35 lines · Peter Maydell

Ping^3 (past the six-week mark now...)

-- PMM

Quoted 30 lines · Peter Maydell

Ping^2 ?

-- PMM

Quoted 24 lines · Peter Maydell

Ping?

Quoted 21 lines · Peter Maydell

These patches add support for the prctl options PR_GET_NAME and PR_SET_NAME. In particular, perl 5.14 will use PR_SET_NAME if you change the value of $0, which means that adduser will fail if run under qemu with a sufficiently modern perl.

Patch one is just indentation cleanup, the meat is patch 2.

The only other prctl options which take pointer arguments are all architecture specific, so there didn't seem much point in adding them (they all work like PR_GET_PDEATHSIG in that they pass an int* to be filled in); we'd have to actually emulate them if we cared about them.

Peter Maydell (2):
 linux-user/syscall.c: Fix indentation in prctl handling
 linux-user: Add support for prctl PR_GET_NAME and PR_SET_NAME

 linux-user/syscall.c |   53 ++++++++++++++++++++++++++++++++++++-------------

 1 files changed, 39 insertions(+), 14 deletions(-)