]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
prctl: remove one-shot limitation for changing exe link
authorStanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Tue, 13 Dec 2016 00:40:42 +0000 (16:40 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 13 Dec 2016 02:55:06 +0000 (18:55 -0800)
This limitation came with the reason to remove "another way for
malicious code to obscure a compromised program and masquerade as a
benign process" by allowing "security-concious program can use this
prctl once during its early initialization to ensure the prctl cannot
later be abused for this purpose":

    http://marc.info/?l=linux-kernel&m=133160684517468&w=2

This explanation doesn't look sufficient.  The only thing "exe" link is
indicating is the file, used to execve, which is basically nothing and
not reliable immediately after process has returned from execve system
call.

Moreover, to use this feture, all the mappings to previous exe file have
to be unmapped and all the new exe file permissions must be satisfied.

Which means, that changing exe link is very similar to calling execve on
the binary.

The need to remove this limitations comes from migration of NFS mount
point, which is not accessible during restore and replaced by other file
system.  Because of this exe link has to be changed twice.

[akpm@linux-foundation.org: fix up comment]
Link: http://lkml.kernel.org/r/20160927153755.9337.69650.stgit@localhost.localdomain
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Matt Helsley <matthltc@us.ibm.com>
Cc: Pavel Emelyanov <xemul@virtuozzo.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/sched.h
kernel/sys.c

index 7551d3e2ab7020067568cacfde25885f80a2fc62..0e90f2973719460cb04cb949ca5fd2203d7cb17d 100644 (file)
@@ -540,7 +540,11 @@ static inline int get_dumpable(struct mm_struct *mm)
                                        /* leave room for more dump flags */
 #define MMF_VM_MERGEABLE       16      /* KSM may merge identical pages */
 #define MMF_VM_HUGEPAGE                17      /* set when VM_HUGEPAGE is set on vma */
-#define MMF_EXE_FILE_CHANGED   18      /* see prctl_set_mm_exe_file() */
+/*
+ * This one-shot flag is dropped due to necessity of changing exe once again
+ * on NFS restore
+ */
+//#define MMF_EXE_FILE_CHANGED 18      /* see prctl_set_mm_exe_file() */
 
 #define MMF_HAS_UPROBES                19      /* has uprobes */
 #define MMF_RECALC_UPROBES     20      /* MMF_HAS_UPROBES can be wrong */
index 89d5be418157fa7a18760b57c11a56a7437c8b81..fd6f50809b6e2ca126d5ce813ec861baa32fa498 100644 (file)
@@ -1696,16 +1696,6 @@ static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd)
                fput(exe_file);
        }
 
-       /*
-        * The symlink can be changed only once, just to disallow arbitrary
-        * transitions malicious software might bring in. This means one
-        * could make a snapshot over all processes running and monitor
-        * /proc/pid/exe changes to notice unusual activity if needed.
-        */
-       err = -EPERM;
-       if (test_and_set_bit(MMF_EXE_FILE_CHANGED, &mm->flags))
-               goto exit;
-
        err = 0;
        /* set the new file, lockless */
        get_file(exe.file);