Remove READ_IMPLIES_EXEC during restart
PATCH 1/1 Remove READ_IMPLIES_EXEC during restart
On s390, all tasks have READ_IMPLIES_EXEC set in current->personality, which causes the restart process to map things like the stack and heap as executable. During the restart process, remove this bit and restore the original personality afterwards.
This seems a little ugly, but I don't know that there's a better place for it.
--- checkpoint/restart.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
checkpoint/restart.c +7 -0
@@ -13,6 +13,7 @@#include <linux/wait.h> #include <linux/file.h> #include <linux/magic.h> +#include <linux/personality.h> #include <linux/checkpoint.h> #include <linux/checkpoint_hdr.h>
@@ -535,12 +536,18 @@ static int do_restart_root(struct cr_ctx *ctx, pid_t pid)int do_restart (struct cr_ctx *ctx,pid_t pid) {int ret; +unsigned int original_personality; + + original_personality = current->personality; + current->personality &= ~READ_IMPLIES_EXEC ;if (ctx) ret =do_restart_root (ctx, pid);else ret =do_restart_task (pid); + current->personality = original_personality; +/* on success, adjust the return value if needed [TODO] */ return ret; }
Signature · 1 line
1.6.1
A message that is not in the archive (sent off-list or not yet received): 1239039694-22332-1-git-send-email-danms-r/[email protected]
Serge E. Hallyn
Acked-byQuoted 7 lines · Dan Smith
On s390, all tasks have
READ_IMPLIES_EXECset incurrent->personality, which causes the restart process to map things like the stack and heap as executable. During the restart process, remove this bit and restore the original personality afterwards.This seems a little ugly, but I don't know that there's a better place for it.
Well imo the only other thing to do would be to do the same thing but just around the main restart_memory function.
Quoted 2 lines
Signed-off-by Dan Smith <danms-r/[email protected]>
Quoted 42 lines
--- checkpoint/restart.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)checkpoint/restart.c +7
-0@@ -13,6 +13,7 @@#include <linux/wait.h> #include <linux/file.h> #include <linux/magic.h> +#include <linux/personality.h> #include <linux/checkpoint.h> #include <linux/checkpoint_hdr.h> @@ -535,12 +536,18 @@ static int do_restart_root(struct cr_ctx *ctx, pid_t pid)int do_restart (struct cr_ctx *ctx,pid_t pid) {int ret; +unsigned int original_personality; + + original_personality = current->personality; + current->personality &= ~READ_IMPLIES_EXEC ;if (ctx) ret =do_restart_root (ctx, pid);else ret =do_restart_task (pid); + current->personality = original_personality; +/* on success, adjust the return value if needed [TODO] */ return ret; }Signature · 6 lines
1.6.1 _______________________________________________ Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org https://lists.linux-foundation.org/mailman/listinfo/containers
A message that is not in the archive (sent off-list or not yet received): 20090406181748.GA24751-r/[email protected]
Quoted 6 lines · Serge E. Hallyn
Quoted 5 lines · Dan Smith
On s390, all tasks have
READ_IMPLIES_EXECset incurrent->personality, which causes the restart process to map things like the stack and heap as executable. During the restart process, remove this bit and restore the original personality afterwards.
Quoted 6 lines
Quoted 2 lines
This seems a little ugly, but I don't know that there's a better place for it.
Well imo the only other thing to do would be to do the same thing but just around the main
restart_memoryfunction.
I second that. Added.
Oren.
Quoted 52 lines
Quoted 2 lines
Signed-off-by Dan Smith <danms-r/[email protected]>Quoted 42 lines
--- checkpoint/restart.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)checkpoint/restart.c +7
-0@@ -13,6 +13,7 @@#include <linux/wait.h> #include <linux/file.h> #include <linux/magic.h> +#include <linux/personality.h> #include <linux/checkpoint.h> #include <linux/checkpoint_hdr.h> @@ -535,12 +536,18 @@ static int do_restart_root(struct cr_ctx *ctx, pid_t pid)int do_restart (struct cr_ctx *ctx,pid_t pid) {int ret; +unsigned int original_personality; + + original_personality = current->personality; + current->personality &= ~READ_IMPLIES_EXEC ;if (ctx) ret =do_restart_root (ctx, pid);else ret =do_restart_task (pid); + current->personality = original_personality; +/* on success, adjust the return value if needed [TODO] */ return ret; }Signature · 6 lines
1.6.1 _______________________________________________ Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org https://lists.linux-foundation.org/mailman/listinfo/containers_______________________________________________
Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 8 lines · Oren Laadan
Quoted 6 lines · Serge E. Hallyn
Quoted 5 lines · Dan Smith
On s390, all tasks have
READ_IMPLIES_EXECset incurrent->personality, which causes the restart process to map things like the stack and heap as executable. During the restart process, remove this bit and restore the original personality afterwards.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
This seems a little ugly, but I don't know that there's a better place for it.
Well imo the only other thing to do would be to do the same thing but just around the main
restart_memoryfunction.I second that. Added.
In fact, if elsewhere we restore current->personality of the task, then unless we move it to cr_read_mm(), it will overwrite it :(
Oren.
A message that is not in the archive (sent off-list or not yet received): [email protected]
OL> In fact, if elsewhere we restore current->personality of the task, OL> then unless we move it to cr_read_mm(), it will overwrite it :(
Should we move it or just remove RIE before we start the restart and let the task regain the flag if it had it before?
Signature · 3 lines
Dan Smith IBM Linux Technology Center email: danms-r/[email protected]
A message that is not in the archive (sent off-list or not yet received): 87y6u3cqd0.fsf-FLMGYpZoEPULwtHQx/[email protected]
Probably best is to (a) save and restore the task's personality (regardless), and (b) in do_restart() (re)set the personality as we wish, with a clear comment about why and the fact that the 'real' personality is restore later.
Oren.
Quoted 6 lines · Dan Smith
OL> In fact, if elsewhere we restore
current->personalityof the task, OL> then unless we move it tocr_read_mm(), it will overwrite it :(Should we move it or just remove RIE before we start the restart and let the task regain the flag if it had it before?
Dan,
Now after the rework of the patchset, it's probably a good time to add support for this.
I'm unsure if the personality can affect other restore actions that take place elsewhere If so, probably the correct way is to:
1) restore personality as part of the task (in the beginning)
2) temporarily change it around those places where we want the "native" personality, e.g. the call to do_mmap_pgoff(), or shmat(),
(The reason not to put it around the entire restore_mm() is to be safe in case a personality makes a difference when you open files. This way we isolate the effect of changing personality).
Any thoughts ?
Oren.
Quoted 6 lines · Dan Smith
OL> In fact, if elsewhere we restore
current->personalityof the task, OL> then unless we move it tocr_read_mm(), it will overwrite it :(Should we move it or just remove RIE before we start the restart and let the task regain the flag if it had it before?