Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Soohoon Lee <soohoon.lee@api-networks.com>
To: "'axp-list@redhat.com'" <axp-list@redhat.com>
Subject: __kernel_execve() bug in 2.2.x
Date: Wed, 24 Jan 2001 17:14:23 -0500	[thread overview]
Message-ID: <051DFF3BBA73D3119A5800A0C95BD021C0394D@barracuda.alpha-processor.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1670 bytes --]


problem was race condition on free_filp.
They have to acquire kernel lock before touch free_filp but
in-kernel-use execve(), include/asm-alpha/unistd.h:execve() and 
arch/alpha/kernel/process.c:__kernel_execve() doesn't do that.
so following situation was possible.

CPU0
0xfffffc0000351e44 get_empty_filp+0x44  (AR:0xfffffc007e043578)
0xfffffc0000359308 open_dentry+0x68  (AR:0xfffffc007e043598)
0xfffffc0000367e48 load_elf_binary+0x1a8  (AR:0xfffffc007e0435d8)
0xfffffc000035a604 search_binary_handler+0x144  (AR:0xfffffc007e0437b8)
0xfffffc000035a908 do_execve+0x1a8  (AR:0xfffffc007e0439c8)
0xfffffc00003107f4 __kernel_execve+0x1c  (AR:0xfffffc007e043bd8)
0xfffffc000033ced8 exec_usermodehelper+0x218  (AR:0xfffffc007e043be8)
0xfffffc000033cf70 exec_modprobe+0x50  (AR:0xfffffc007e043d08)
0xfffffc00003107c0 __kernel_thread+0x50  (AR:0xfffffc007e043d58)

CPU 1
0xfffffc0000351e00 get_empty_filp  (AR:0xfffffc000025be38)
0xfffffc000034fafc filp_open+0x3c  (AR:0xfffffc000025be38)
0xfffffc000034fffc sys_open+0xbc  (AR:0xfffffc000025be68)
Exception frame:
0xfffffc0000310c50 entSys+0xa8  (AR:0xfffffc000025bf18)

Both cpus are accessing free_filp... In normal case, either CPU0 is waiting
at __kernel_execve() or
CPU1 is waiting at sys_open() for kernel lock.
And It causes many different kind of panics and will cause other problems
too, not only this free_filp case.
So I put lock_kernel() and unlock_kernel() in __kernel_execve() and seems
working fine.

And more, 2.4.0 is changed and execve() doesn't need to acquire kernel lock.
So lock/unlock_kernel() in arch/alpha/kernel/process.c:sys_execve() need to
be removed.

Attached is a patch for 2.2.18.

Soohoon.


[-- Attachment #2: __kernel_execve.txt --]
[-- Type: text/plain, Size: 1363 bytes --]

diff -Naur linux/arch/alpha/kernel/entry.S ../t/arch/alpha/kernel/entry.S
--- linux/arch/alpha/kernel/entry.S     Wed May  3 20:16:30 2000
+++ ../t/arch/alpha/kernel/entry.S      Tue Jan 23 02:56:27 2001
@@ -272,7 +272,7 @@
        stq     $26,0($30)
        stq     $19,8($30)
        .prologue 1
-       jsr     $26,do_execve
+       jsr     $26,___kernel_execve
        bne     $0,1f           /* error! */
        ldq     $30,8($30)
        br      $31,ret_from_sys_call
diff -Naur linux/arch/alpha/kernel/process.c ../t/arch/alpha/kernel/process.c
--- linux/arch/alpha/kernel/process.c   Wed May  3 20:16:30 2000
+++ ../t/arch/alpha/kernel/process.c    Tue Jan 23 02:58:59 2001
@@ -463,3 +463,24 @@
        unlock_kernel();
        return error;
 }
+
+/*
+ * execve() system call for in kernel use.
+ * Two(user and kernel) execve() have quite different call path and 
+ * following function is to put lock_kernel() and unlock_kernel() in kernel execve(). 
+ * You could put them in unistd.h but you will have to modify many files to 
+ * clear compile error - soohoon.lee@api-networks.com. 
+*/
+asmlinkage int ___kernel_execve(char *filename, char **argp, char **envp,
+       struct pt_regs *regs)
+{
+       int error;
+
+       lock_kernel();
+
+       error = do_execve(filename, argp, envp, regs);
+
+       unlock_kernel();
+
+       return error;
+}

                 reply	other threads:[~2001-01-24 22:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox