Skip to contentSkip to conversation

linux-user/signal.c: Use frame->retcode instead of frame address for alpha target restorer

PATCH Superseded [email protected] 3 participants 4 messages Mar 29, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user/signal.c: Use frame->retcode instead of frame address for alpha target restorer

From: Chen Gang <[email protected]>

The restorer needs the return code address which is frame->retcode, not frame itself.

---
 linux-user/signal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/signal.c +1 -1
index e487f9e..4157154 100644
@@ -5455,7 +5455,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
                    &frame->retcode[1]);
         __put_user(INSN_CALLSYS, &frame->retcode[2]);
         /* imb(); */
-        r26 = frame_addr;
+        r26 = frame_addr + offsetof(struct target_rt_sigframe, retcode);
     }
 
     if (err) {
Signature · 1 line
1.9.3
#1 lore raw
Quoted 16 lines · Le 29/03/2016 16:01, [email protected] a écrit :

From: Chen Gang <[email protected]>

The restorer needs the return code address which is frame->retcode, not frame itself.

---
 linux-user/signal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/signal.c +0 -0
index e487f9e..4157154 100644

linux-user/signal.c static void setup_rt_frame(int sig, struct target_sigaction *ka, · line 5461

Quoted 8 lines
linux-user/signal.c +1 -1
@@ -5455,7 +5455,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
                    &frame->retcode[1]);
         __put_user(INSN_CALLSYS, &frame->retcode[2]);
         /* imb(); */
-        r26 = frame_addr;
+        r26 = frame_addr + offsetof(struct target_rt_sigframe, retcode);
     }
 
     if (err) {

If you change setup_rt_frame(), you must update setup_frame() too.

It seems correct.

Richard, as you have written the original code, could you check this is correct?

Laurent

author
#2 lore raw
Quoted 21 lines · Laurent Vivier
Quoted 20 lines · Le 29/03/2016 16:01, [email protected] a écrit :

The restorer needs the return code address which is frame->retcode, not frame itself.

---
 linux-user/signal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/signal.c +1 -1
index e487f9e..4157154 100644
@@ -5455,7 +5455,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
                    &frame->retcode[1]);
         __put_user(INSN_CALLSYS, &frame->retcode[2]);
         /* imb(); */
-        r26 = frame_addr;
+        r26 = frame_addr + offsetof(struct target_rt_sigframe, retcode);
     }
 
Quoted 5 lines

linux-user/signal.c static void setup_rt_frame(int sig, struct target_sigaction *ka, · line 5461

Quoted 2 lines
linux-user/signal.c +0 -0
     if (err) {

If you change setup_rt_frame(), you must update setup_frame() too.

Oh, yes, thanks.

Quoted 5 lines

It seems correct.

Richard, as you have written the original code, could you check this is correct?

Please give a check when you have time.

Thanks.

Signature · 3 lines
Chen Gang (陈刚)

Managing Natural Environments is the Duty of Human Beings.
#3 lore raw
In reply to Laurent Vivier
Quoted 30 lines · Laurent Vivier
Quoted 16 lines · Le 29/03/2016 16:01, [email protected] a écrit :

From: Chen Gang <[email protected]>

The restorer needs the return code address which is frame->retcode, not frame itself.

---
 linux-user/signal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/signal.c +0 -0
index e487f9e..4157154 100644

linux-user/signal.c static void setup_rt_frame(int sig, struct target_sigaction *ka, · line 5461

Quoted 8 lines
linux-user/signal.c +1 -1
@@ -5455,7 +5455,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
                    &frame->retcode[1]);
         __put_user(INSN_CALLSYS, &frame->retcode[2]);
         /* imb(); */
-        r26 = frame_addr;
+        r26 = frame_addr + offsetof(struct target_rt_sigframe, retcode);
     }
 
     if (err) {

If you change setup_rt_frame(), you must update setup_frame() too.

Quoted 4 lines

It seems correct.

Richard, as you have written the original code, could you check this is correct?

Yes, it's correct, and yes both functions need fixing.

In practice, this path is historical and will never be used; it was now a very old glibc that didn't supply a restorer.

r~