From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.redhat.com (mail.redhat.com [199.183.24.239]) by listman.redhat.com (Postfix) with ESMTP id CA0B2300FA for ; Wed, 24 Jan 2001 17:20:18 -0500 (EST) Received: (from mail@localhost) by mail.redhat.com (8.11.0/8.8.7) id f0OMK5D08557 for axp-list@listman.redhat.com; Wed, 24 Jan 2001 17:20:05 -0500 Received: from alpha-gw.alpha-processor.com (alpha-gw.alpha-processor.com [192.233.59.9]) by mail.redhat.com (8.11.0/8.8.7) with SMTP id f0OMK4d08549 for ; Wed, 24 Jan 2001 17:20:04 -0500 Received: from barracuda.alpha-processor.com by alpha-gw.alpha-processor.com via smtpd (for mail.redhat.com [199.183.24.239]) with SMTP; 24 Jan 2001 22:21:47 UT Received: by barracuda.alpha-processor.com with Internet Mail Service (5.5.2650.21) id ; Wed, 24 Jan 2001 17:14:23 -0500 Message-ID: <051DFF3BBA73D3119A5800A0C95BD021C0394D@barracuda.alpha-processor.com> From: Soohoon Lee To: "'axp-list@redhat.com'" Subject: __kernel_execve() bug in 2.2.x Date: Wed, 24 Jan 2001 17:14:23 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01C08653.01B35974" X-Loop: axp-list@redhat.com Sender: axp-list-admin@redhat.com Errors-To: axp-list-admin@redhat.com X-BeenThere: axp-list@redhat.com X-Mailman-Version: 2.0beta4 Precedence: bulk Reply-To: axp-list@redhat.com List-Id: Linux and Red Hat on Alpha processors This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01C08653.01B35974 Content-Type: text/plain; charset="iso-8859-1" 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. ------_=_NextPart_000_01C08653.01B35974 Content-Type: text/plain; name="__kernel_execve.txt" Content-Disposition: attachment; filename="__kernel_execve.txt" 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; +} ------_=_NextPart_000_01C08653.01B35974--