1 $Id: bproc-patch-2.4.20,v 1.7 2004/03/19 06:33:08 phil Exp $
4 ===================================================================
5 --- linux.orig/fs/exec.c 2003-09-03 17:52:00.000000000 -0400
6 +++ linux/fs/exec.c 2003-09-03 17:52:04.000000000 -0400
8 #include <linux/utsname.h>
10 #include <linux/module.h>
11 +#include <linux/bproc.h>
13 #include <asm/uaccess.h>
14 #include <asm/pgalloc.h>
16 xa_call_actions (XA_EXEC, XA_KOE, NULL);
18 retval = search_binary_handler(&bprm,regs);
22 + bproc_hook_im(do_execve,());
27 /* Something went wrong, return the inode and free the argument pages*/
28 Index: linux/fs/binfmt_script.c
29 ===================================================================
30 --- linux.orig/fs/binfmt_script.c 2002-08-02 20:39:45.000000000 -0400
31 +++ linux/fs/binfmt_script.c 2003-09-03 17:52:04.000000000 -0400
33 #include <linux/init.h>
34 #include <linux/file.h>
35 #include <linux/smp_lock.h>
36 +#include <linux/bproc.h>
38 static int load_script(struct linux_binprm *bprm,struct pt_regs *regs)
41 * user environment and arguments are stored.
43 remove_arg_zero(bprm);
44 - retval = copy_strings_kernel(1, &bprm->filename, bprm);
45 + retval = copy_strings_kernel(1,bproc_hook_v(&bprm->filename,load_script,(&bprm->filename)), bprm);
46 if (retval < 0) return retval;
49 Index: linux/fs/binfmt_elf.c
50 ===================================================================
51 --- linux.orig/fs/binfmt_elf.c 2002-08-02 20:39:45.000000000 -0400
52 +++ linux/fs/binfmt_elf.c 2003-09-03 17:52:04.000000000 -0400
54 #define ELF_PAGEOFFSET(_v) ((_v) & (ELF_MIN_ALIGN-1))
55 #define ELF_PAGEALIGN(_v) (((_v) + ELF_MIN_ALIGN - 1) & ~(ELF_MIN_ALIGN - 1))
57 -static struct linux_binfmt elf_format = {
58 +struct linux_binfmt elf_format = {
59 NULL, THIS_MODULE, load_elf_binary, load_elf_library, elf_core_dump, ELF_EXEC_PAGESIZE
62 Index: linux/fs/proc/base.c
63 ===================================================================
64 --- linux.orig/fs/proc/base.c 2003-09-03 17:52:00.000000000 -0400
65 +++ linux/fs/proc/base.c 2003-09-03 17:52:04.000000000 -0400
67 #include <linux/string.h>
68 #include <linux/seq_file.h>
69 #include <linux/namespace.h>
70 +#include <linux/bproc.h>
73 * For hysterical raisins we keep the same inumbers as in the old procfs.
75 if (!(page = __get_free_page(GFP_KERNEL)))
78 + if (bproc_isghost(task)) bproc_hook(refresh_status,(task));
79 length = inode->u.proc_i.op.proc_read(task, (char*)page);
83 static int proc_self_readlink(struct dentry *dentry, char *buffer, int buflen)
86 - sprintf(tmp, "%d", current->pid);
87 + sprintf(tmp, "%d", bproc_hook_imv(current->pid,proc3,()));
88 return vfs_readlink(dentry,buffer,buflen,tmp);
91 static int proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
94 - sprintf(tmp, "%d", current->pid);
95 + sprintf(tmp, "%d", bproc_hook_imv(current->pid,proc3,()));
96 return vfs_follow_link(nd,tmp);
103 + pid = bproc_hook_imv(pid,proc2,(pid));
104 read_lock(&tasklist_lock);
105 task = find_task_by_pid(pid);
107 @@ -1082,7 +1085,7 @@
109 read_lock(&tasklist_lock);
112 + int pid = bproc_hook_imv(p->pid,proc1,(p));
116 Index: linux/fs/proc/array.c
117 ===================================================================
118 --- linux.orig/fs/proc/array.c 2002-08-02 20:39:45.000000000 -0400
119 +++ linux/fs/proc/array.c 2003-09-03 17:52:04.000000000 -0400
121 #include <linux/smp.h>
122 #include <linux/signal.h>
123 #include <linux/highmem.h>
124 +#include <linux/bproc.h>
126 #include <asm/uaccess.h>
127 #include <asm/pgtable.h>
130 static inline const char * get_task_state(struct task_struct *tsk)
132 - unsigned int state = tsk->state & (TASK_RUNNING |
133 + unsigned int state = (bproc_hook_v(tsk->state,get_task_state,(tsk)))
136 TASK_UNINTERRUPTIBLE |
139 "Uid:\t%d\t%d\t%d\t%d\n"
140 "Gid:\t%d\t%d\t%d\t%d\n",
141 get_task_state(p), p->tgid,
142 - p->pid, p->pid ? p->p_opptr->pid : 0, 0,
143 + bproc_hook_imv(p->pid, proc_pid, (p)),
144 + bproc_hook_imv(p->p_opptr->pid, proc_ppid, (p)), 0,
145 p->uid, p->euid, p->suid, p->fsuid,
146 p->gid, p->egid, p->sgid, p->fsgid);
147 read_unlock(&tasklist_lock);
149 sigset_t sigign, sigcatch;
154 struct mm_struct *mm;
156 state = *get_task_state(task);
157 @@ -343,12 +346,14 @@
160 read_lock(&tasklist_lock);
161 - ppid = task->pid ? task->p_opptr->pid : 0;
162 + pid = bproc_hook_imv(task->pid, proc_pid, (task)),
163 + ppid = bproc_hook_imv(task->pid ? task->p_opptr->pid : 0,
164 + proc_ppid, (task));
165 read_unlock(&tasklist_lock);
166 res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \
167 %lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld %lu %lu %ld %lu %lu %lu %lu %lu \
168 %lu %lu %lu %lu %lu %lu %lu %lu %d %d\n",
174 Index: linux/kernel/timer.c
175 ===================================================================
176 --- linux.orig/kernel/timer.c 2003-09-03 17:51:01.000000000 -0400
177 +++ linux/kernel/timer.c 2003-09-03 17:52:04.000000000 -0400
179 #include <linux/smp_lock.h>
180 #include <linux/interrupt.h>
181 #include <linux/kernel_stat.h>
182 +#include <linux/bproc.h>
184 #include <asm/uaccess.h>
188 asmlinkage long sys_getpid(void)
190 - return current->tgid;
191 + return bproc_hook_imv(current->tgid, sys_getpid, ());
197 parent = me->p_opptr;
200 + pid = bproc_hook_imv(parent->pid,sys_getppid,(parent));
203 struct task_struct *old = parent;
204 Index: linux/kernel/signal.c
205 ===================================================================
206 --- linux.orig/kernel/signal.c 2003-09-03 17:51:01.000000000 -0400
207 +++ linux/kernel/signal.c 2003-09-03 17:52:04.000000000 -0400
210 #include <asm/uaccess.h>
212 +#include <linux/bproc.h>
215 * SLAB caches for signal bits.
218 if (sig < SIGRTMIN && sigismember(&t->pending.signal, sig))
221 + if (bproc_hook_v(0, send_sig_info, (sig, info, t)))
224 ret = deliver_signal(sig, info, t);
226 spin_unlock_irqrestore(&t->sigmask_lock, flags);
228 kill_pg_info(int sig, struct siginfo *info, pid_t pgrp)
230 int retval = -EINVAL;
232 + if (bproc_hook_imv(0,kill_pg_info, (sig, info, &pgrp, &retval)) == 1)
235 struct task_struct *p;
238 kill_sl_info(int sig, struct siginfo *info, pid_t sess)
240 int retval = -EINVAL;
241 + /* XXX bproc: Need ways to deal with session leaders...*/
243 struct task_struct *p;
247 struct task_struct *p;
249 + if (bproc_hook_imv(0, kill_proc_info,(sig, info, &pid, &error)) == 1)
252 read_lock(&tasklist_lock);
253 p = find_task_by_pid(pid);
256 read_unlock(&tasklist_lock);
257 return count ? retval : -ESRCH;
258 } else if (pid < 0) {
259 + /* XXX pid masq - do PG stuff. */
260 return kill_pg_info(sig, info, -pid);
262 return kill_proc_info(sig, info, pid);
264 EXPORT_SYMBOL(recalc_sigpending);
265 EXPORT_SYMBOL(send_sig);
266 EXPORT_SYMBOL(send_sig_info);
267 +EXPORT_SYMBOL(kill_something_info);
268 EXPORT_SYMBOL(block_all_signals);
269 EXPORT_SYMBOL(unblock_all_signals);
271 Index: linux/kernel/sched.c
272 ===================================================================
273 --- linux.orig/kernel/sched.c 2003-09-03 17:51:05.000000000 -0400
274 +++ linux/kernel/sched.c 2003-09-03 17:52:04.000000000 -0400
276 #include <linux/dump.h>
277 #include <linux/prefetch.h>
278 #include <linux/compiler.h>
279 +#include <linux/bproc.h>
281 #include <asm/uaccess.h>
282 #include <asm/mmu_context.h>
285 inline int wake_up_process(struct task_struct * p)
287 + if (p->state == TASK_STOPPED && bproc_ismasq(p))
288 + bproc_hook(wake_up_process, (p));
289 return try_to_wake_up(p, 0);
292 Index: linux/kernel/ksyms.c
293 ===================================================================
294 --- linux.orig/kernel/ksyms.c 2003-09-03 17:52:02.000000000 -0400
295 +++ linux/kernel/ksyms.c 2003-09-03 17:52:04.000000000 -0400
297 extern void set_device_ro(kdev_t dev,int flag);
299 extern void *sys_call_table;
300 +extern struct task_struct *child_reaper;
301 +#if defined(CONFIG_BINFMT_ELF)
302 +extern struct linux_binfmt elf_format;
305 extern struct timezone sys_tz;
306 extern int request_dma(unsigned int dmanr, char * deviceID);
308 EXPORT_SYMBOL(do_munmap);
309 EXPORT_SYMBOL(do_brk);
310 EXPORT_SYMBOL(exit_mm);
311 +EXPORT_SYMBOL(do_exit);
312 EXPORT_SYMBOL(exit_files);
313 EXPORT_SYMBOL(exit_fs);
314 EXPORT_SYMBOL(exit_sighand);
315 +EXPORT_SYMBOL(is_orphaned_pgrp);
316 +EXPORT_SYMBOL(child_reaper);
317 +#if defined(CONFIG_BINFMT_ELF)
318 +EXPORT_SYMBOL(elf_format);
320 +EXPORT_SYMBOL(alloc_uid);
321 +EXPORT_SYMBOL(free_uid);
322 EXPORT_SYMBOL(copy_fs_struct);
323 EXPORT_SYMBOL_GPL(make_pages_present);
326 EXPORT_SYMBOL(read_ahead);
327 EXPORT_SYMBOL(get_hash_table);
328 EXPORT_SYMBOL(new_inode);
329 +EXPORT_SYMBOL(get_empty_inode);
330 EXPORT_SYMBOL(insert_inode_hash);
331 EXPORT_SYMBOL(remove_inode_hash);
332 EXPORT_SYMBOL(buffer_insert_inode_queue);
333 Index: linux/kernel/fork.c
334 ===================================================================
335 --- linux.orig/kernel/fork.c 2003-09-03 17:52:00.000000000 -0400
336 +++ linux/kernel/fork.c 2003-09-03 17:52:04.000000000 -0400
338 #include <linux/personality.h>
339 #include <linux/compiler.h>
341 +#include <linux/bproc.h>
343 #include <asm/pgtable.h>
344 #include <asm/pgalloc.h>
345 #include <asm/uaccess.h>
348 static inline int copy_fs(unsigned long clone_flags, struct task_struct * tsk)
350 + if (!current->fs) return 0;
351 if (clone_flags & CLONE_FS) {
352 atomic_inc(¤t->fs->count);
359 + if ((retval = bproc_hook_v(p->pid, do_fork, (p, clone_flags))) < 0)
360 + goto bad_fork_cleanup_mm;
362 INIT_LIST_HEAD(&p->thread_group);
368 + bproc_hook(do_fork_2, (p));
369 write_unlock_irq(&tasklist_lock);
371 if (p->ptrace & PT_PTRACED)
373 wait_for_completion(&vfork);
376 + bproc_clear_kcall();
379 bad_fork_cleanup_namespace:
380 Index: linux/kernel/exit.c
381 ===================================================================
382 --- linux.orig/kernel/exit.c 2003-09-03 17:52:00.000000000 -0400
383 +++ linux/kernel/exit.c 2003-09-03 17:52:04.000000000 -0400
385 #include <asm/pgtable.h>
386 #include <asm/mmu_context.h>
388 +#include <linux/bproc.h>
390 extern void sem_exit (void);
391 extern struct task_struct *child_reaper;
397 + bproc_hook(release,(p));
398 atomic_dec(&p->user->processes);
403 int is_orphaned_pgrp(int pgrp)
405 - return will_become_orphaned_pgrp(pgrp, 0);
406 + return bproc_hook_imv(will_become_orphaned_pgrp(pgrp, 0),
407 + is_orphaned_pgrp,(pgrp));
410 static inline int has_stopped_jobs(int pgrp)
414 /* Make sure we're not reparenting to ourselves */
415 - p->p_opptr = child_reaper;
416 + p->p_opptr = bproc_hook_v(child_reaper, child_reaper, (p));
418 if (p->pdeath_signal) send_sig(p->pdeath_signal, p, 0);
424 + bproc_hook(do_exit, (tsk,code));
429 asmlinkage long sys_wait4(pid_t pid,unsigned int * stat_addr, int options, struct rusage * ru)
432 + pid_t orig_pid = pid;
433 DECLARE_WAITQUEUE(wait, current);
434 struct task_struct *tsk;
438 current->state = TASK_INTERRUPTIBLE;
439 read_lock(&tasklist_lock);
441 + if (bproc_hook_imv(0, sys_wait4_1, (&pid, stat_addr, options, ru, &retval)))
442 + goto end_wait4; /* handler will unlock tasklist_lock */
445 struct task_struct *p;
447 && !(options & __WALL))
450 - switch (p->state) {
451 + switch (bproc_hook_v(p->state,sys_wait4_2,(p))) {
456 retval = put_user((p->exit_code << 8) | 0x7f, stat_addr);
460 + retval = bproc_hook_imv(p->pid, sys_wait4_3, (p));
465 retval = put_user(p->exit_code, stat_addr);
469 + retval = bproc_hook_imv(p->pid, sys_wait4_3, (p));
470 if (p->p_opptr != p->p_pptr) {
471 write_lock_irq(&tasklist_lock);
474 write_unlock_irq(&tasklist_lock);
477 + bproc_hook_im(sys_wait4_4,(retval, options));
483 current->state = TASK_RUNNING;
484 remove_wait_queue(¤t->wait_chldexit,&wait);
485 + bproc_clear_kcall();
489 Index: linux/kernel/sys.c
490 ===================================================================
491 --- linux.orig/kernel/sys.c 2003-09-03 17:51:05.000000000 -0400
492 +++ linux/kernel/sys.c 2003-09-03 17:52:04.000000000 -0400
494 #include <asm/uaccess.h>
497 +#include <linux/bproc.h>
500 * this is where the system-wide overflow UID and GID are defined, for
501 * architectures that now have 32-bit UID/GID but didn't in the past
503 current->fsgid = new_egid;
504 current->egid = new_egid;
505 current->gid = new_rgid;
506 + bproc_hook_im(set_creds, ());
514 + bproc_hook_im(set_creds, ());
519 cap_emulate_setxuid(old_ruid, old_euid, old_suid);
522 + bproc_hook_im(set_creds, ());
527 cap_emulate_setxuid(old_ruid, old_euid, old_suid);
530 + bproc_hook_im(set_creds, ());
531 + bproc_hook_im(set_creds, ());
537 if (sgid != (gid_t) -1)
538 current->sgid = sgid;
539 + bproc_hook_im(set_creds, ());
547 + if (current->fsuid != old_fsuid) bproc_hook_im(set_creds, ());
553 current->fsgid = gid;
556 + if (current->fsgid != old_fsgid) bproc_hook_im(set_creds, ());
561 struct task_struct * p;
564 + bproc_hook_imr(sys_setpgid1, (pid, pgid));
573 + if (bproc_isghost(p)) bproc_hook(sys_setpgid2, (p));
576 /* All paths lead to here, thus we are safe. -DaveM */
579 asmlinkage long sys_getpgid(pid_t pid)
581 + bproc_hook_imr(sys_getpgid,(pid));
583 return current->pgrp;
585 @@ -930,23 +945,25 @@
586 asmlinkage long sys_getpgrp(void)
588 /* SMP - assuming writes are word atomic this is fine */
589 - return current->pgrp;
590 + return bproc_hook_imv(current->pgrp,sys_getpgrp,());
593 asmlinkage long sys_getsid(pid_t pid)
596 - return current->session;
597 + return bproc_hook_imv(current->session,sys_getsid1,());
600 struct task_struct *p;
601 + if (bproc_hook_imv(0,sys_getsid2, (&pid, &retval))==1)
604 read_lock(&tasklist_lock);
605 p = find_task_by_pid(pid);
609 - retval = p->session;
610 + retval = bproc_hook_imv(p->session,sys_getsid3,(p));
611 read_unlock(&tasklist_lock);
615 struct task_struct * p;
618 + bproc_hook_imr(sys_setsid,());
620 read_lock(&tasklist_lock);
622 if (p->pgrp == current->pid)
623 @@ -1011,6 +1030,7 @@
624 if(copy_from_user(current->groups, grouplist, gidsetsize * sizeof(gid_t)))
626 current->ngroups = gidsetsize;
627 + bproc_hook_im(set_creds, ());
631 Index: linux/kernel/ptrace.c
632 ===================================================================
633 --- linux.orig/kernel/ptrace.c 2003-09-03 17:51:04.000000000 -0400
634 +++ linux/kernel/ptrace.c 2003-09-03 17:52:04.000000000 -0400
636 #include <linux/mm.h>
637 #include <linux/highmem.h>
638 #include <linux/smp_lock.h>
639 +#include <linux/bproc.h>
641 #include <asm/pgtable.h>
642 #include <asm/uaccess.h>
644 if (!(child->ptrace & PT_PTRACED))
647 - if (child->p_pptr != current)
649 + if (child->p_pptr != current &&
650 + !bproc_hook_v(0,ptrace_slave_call,
651 + (PTRACE_DETACH, child, current->bproc.arg)))
654 + if (bproc_isghost(child))
658 if (child->state != TASK_STOPPED)
661 int ptrace_attach(struct task_struct *task)
668 task->ptrace |= PT_PTRACE_CAP;
672 write_lock_irq(&tasklist_lock);
673 if (task->p_pptr != current) {
674 + if (bproc_isghost(current) && !bproc_isghost(task)) ret = 1;
676 task->p_pptr = current;
679 + if (bproc_ismasq(task))
680 + bproc_hook(ptrace_attach, (task, current->bproc.arg, &ret));
681 write_unlock_irq(&tasklist_lock);
683 - send_sig(SIGSTOP, task, 1);
685 + if (bproc_isghost(task))
686 + bproc_hook(ptraceg,(PTRACE_ATTACH, task, 0, 0, &ret, 0));
688 + send_sig(SIGSTOP, task, 1);
695 int ptrace_detach(struct task_struct *child, unsigned int data)
698 if ((unsigned long) data > _NSIG)
701 @@ -111,14 +125,19 @@
703 child->exit_code = data;
704 write_lock_irq(&tasklist_lock);
705 + if (bproc_isghost(current) && !bproc_isghost(child) &&
706 + child->p_pptr != child->p_opptr)
709 + if (bproc_ismasq(child))
710 + bproc_hook(ptrace_detach,(child,(long*)&ret));
711 child->p_pptr = child->p_opptr;
713 write_unlock_irq(&tasklist_lock);
715 /* .. and wake it up. */
716 wake_up_process(child);
722 Index: linux/kernel/Makefile
723 ===================================================================
724 --- linux.orig/kernel/Makefile 2003-09-03 17:51:06.000000000 -0400
725 +++ linux/kernel/Makefile 2003-09-03 17:52:04.000000000 -0400
730 -export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o printk.o
731 +export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o printk.o bproc_hook.o
733 obj-y = sched.o dma.o fork.o exec_domain.o panic.o printk.o \
734 module.o exit.o itimer.o info.o time.o softirq.o resource.o \
736 obj-$(CONFIG_MODULES) += ksyms.o
737 obj-$(CONFIG_PM) += pm.o
738 obj-$(CONFIG_KALLSYMS) += kallsyms.o
739 +obj-$(CONFIG_BPROC) += bproc_hook.o
741 ifneq ($(CONFIG_IA64),y)
742 # According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is
743 Index: linux/kernel/bproc_hook.c
744 ===================================================================
745 --- linux.orig/kernel/bproc_hook.c 2003-09-03 17:52:04.000000000 -0400
746 +++ linux/kernel/bproc_hook.c 2003-09-03 17:52:04.000000000 -0400
748 +/*-------------------------------------------------------------------------
749 + * bproc_hook.c: Beowulf distributed PID space (bproc) definitions
751 + * Copyright (C) 2000 by Erik Hendriks <hendriks@scyld.com>
753 + * This program is free software; you can redistribute it and/or modify
754 + * it under the terms of the GNU General Public License as published by
755 + * the Free Software Foundation; either version 2 of the License, or
756 + * (at your option) any later version.
758 + * This program is distributed in the hope that it will be useful,
759 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
760 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
761 + * GNU General Public License for more details.
763 + * You should have received a copy of the GNU General Public License
764 + * along with this program; if not, write to the Free Software
765 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
767 + * $Id: bproc-patch-2.4.20,v 1.7 2004/03/19 06:33:08 phil Exp $
768 + *-----------------------------------------------------------------------*/
769 +#include <linux/kernel.h>
770 +#include <linux/sched.h>
771 +#include <linux/module.h>
773 +#define bprocdeclhook(ret,func,args) \
774 + ret (* bproc_hook_ ## func ## _hook) args = 0;\
775 + EXPORT_SYMBOL( bproc_hook_ ## func ## _hook )
777 +#include <linux/bproc.h>
781 + * c-basic-offset: 4
784 Index: linux/include/linux/sched.h
785 ===================================================================
786 --- linux.orig/include/linux/sched.h 2003-09-03 17:51:06.000000000 -0400
787 +++ linux/include/linux/sched.h 2003-09-03 17:52:04.000000000 -0400
790 /* journalling filesystem info */
797 + struct bproc_masq_proc_t *masq;
798 + struct bproc_ghost_proc_t *ghost;
804 alloc_lock: SPIN_LOCK_UNLOCKED, \
805 exit_actions: NULL, \
806 journal_info: NULL, \
807 + bproc: {0, 0, 0, 0} \
811 Index: linux/include/linux/bproc.h
812 ===================================================================
813 --- linux.orig/include/linux/bproc.h 2003-09-03 17:52:04.000000000 -0400
814 +++ linux/include/linux/bproc.h 2003-09-03 17:52:04.000000000 -0400
816 +/*-------------------------------------------------------------------------
817 + * bproc.h: Beowulf distributed PID space (bproc) definitions
819 + * Copyright (C) 1999-2001 by Erik Hendriks <erik@hendriks.cx>
821 + * This program is free software; you can redistribute it and/or modify
822 + * it under the terms of the GNU General Public License as published by
823 + * the Free Software Foundation; either version 2 of the License, or
824 + * (at your option) any later version.
826 + * This program is distributed in the hope that it will be useful,
827 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
828 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
829 + * GNU General Public License for more details.
831 + * You should have received a copy of the GNU General Public License
832 + * along with this program; if not, write to the Free Software
833 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
835 + * $Id: bproc-patch-2.4.20,v 1.7 2004/03/19 06:33:08 phil Exp $
836 + *-----------------------------------------------------------------------*/
837 +#ifndef _LINUX_BPROC_H
838 +#define _LINUX_BPROC_H
840 +#include <linux/config.h>
841 +#include <linux/types.h>
845 +#ifndef bprocdeclhook
846 +/* Function pointers for bproc hooks. */
847 +#define bprocdeclhook(ret,func,args) extern ret (* bproc_hook_ ## func ## _hook) args
850 +struct bproc_ghost_proc_t;
855 +/*----- fs/exec.c -------------------------------------------------------*/
856 +bprocdeclhook(void, do_execve, (void));
857 +/*----- fs/binfmt_script.c ----------------------------------------------*/
858 +bprocdeclhook(char**,load_script, (char **));
859 +/*----- fs/proc/array.c ----------------------------------------------------*/
860 +bprocdeclhook(void, refresh_status, (struct task_struct *));
861 +bprocdeclhook(int, get_task_state, (struct task_struct *));
862 +bprocdeclhook(int, proc_pid, (struct task_struct *));
863 +bprocdeclhook(int, proc_ppid, (struct task_struct *));
864 +bprocdeclhook(int, proc1, (struct task_struct *));
865 +bprocdeclhook(int, proc2, (int));
866 +bprocdeclhook(int, proc3, (void));
867 +/*----- kernel/timer.c --------------------------------------------------*/
868 +bprocdeclhook(int, sys_getpid, (void));
869 +bprocdeclhook(int, sys_getppid, (struct task_struct *));
870 +/*----- kernel/sched.c --------------------------------------------------*/
871 +bprocdeclhook(void, wake_up_process, (struct task_struct *));
872 +/*----- kernel/exit.c ---------------------------------------------------*/
873 +bprocdeclhook(void, release, (struct task_struct *));
874 +bprocdeclhook(int, is_orphaned_pgrp,(int));
875 +bprocdeclhook(struct task_struct *,child_reaper,(struct task_struct *));
876 +bprocdeclhook(void, do_exit, (struct task_struct *, long code));
877 +bprocdeclhook(int, sys_wait4_1, (pid_t *, unsigned int *, int,
878 + struct rusage *, int *));
879 +bprocdeclhook(long, sys_wait4_2, (struct task_struct *));
880 +bprocdeclhook(int, sys_wait4_3, (struct task_struct *));
881 +bprocdeclhook(void, sys_wait4_4, (pid_t, int options));
882 +/*----- kernel/fork.c ---------------------------------------------------*/
883 +bprocdeclhook(int, do_fork, (struct task_struct *, unsigned long));
884 +bprocdeclhook(void, do_fork_2, (struct task_struct *));
885 +/*----- kernel/signal.c -------------------------------------------------*/
886 +bprocdeclhook(int, send_sig_info, (int, struct siginfo *,
887 + struct task_struct *));
888 +bprocdeclhook(int, kill_pg_info, (int, struct siginfo *, pid_t *, int *));
889 +bprocdeclhook(int, kill_proc_info, (int, struct siginfo *, pid_t *, int *));
890 +/*----- kernel/sys.c ----------------------------------------------------*/
891 +bprocdeclhook(int, sys_setpgid1, (pid_t, pid_t));
892 +bprocdeclhook(void, sys_setpgid2, (struct task_struct *p));
893 +bprocdeclhook(int, sys_getpgid, (pid_t pid));
894 +bprocdeclhook(int, sys_getpgrp, (void));
895 +bprocdeclhook(int, sys_getsid1, (void));
896 +bprocdeclhook(int, sys_getsid2, (pid_t *pid, int *error));
897 +bprocdeclhook(int, sys_getsid3, (struct task_struct *p));
898 +bprocdeclhook(int, sys_setsid, (void));
899 +bprocdeclhook(void, set_creds, (void));
900 +/*----- arch/???/kernel/ptrace.c,signal.c -------------------------------*/
901 +bprocdeclhook(void, stop_notify, (int));
902 +bprocdeclhook(int, ptracem, (long, long *, long, long,
904 +bprocdeclhook(void, ptrace_attach, (struct task_struct *, long, long *));
905 +bprocdeclhook(void, ptraceg, (long, struct task_struct *, long,
906 + long, long *, long *));
907 +bprocdeclhook(int, ptrace_slave_call,(long, struct task_struct *, long));
908 +bprocdeclhook(void, ptrace_detach, (struct task_struct *, long *));
909 +bprocdeclhook(int, sys_execve, (struct pt_regs *, char *,
910 + char **, char **));
913 + * (none) = execute this hook if it's present.
915 + * nkc = no kernel call (kcall must be 0 to call hook)
916 + * r = return the value of this hook
917 + * v = hook returns a value.
919 +#define hookname(func) bproc_hook_ ## func ## _hook
920 +#define bproc_hook(func,args) do{if(hookname(func))hookname(func)args;}while(0)
921 +#define bproc_hook_im(func,args) do{if(hookname(func)&¤t->bproc.masq)hookname(func)args;}while(0)
922 +#define bproc_hook_imr(func,args) do{if(hookname(func)&¤t->bproc.masq)return hookname(func)args;}while(0)
923 +#define bproc_hook_v(defl,func,args) ( hookname(func) ?hookname(func)args:defl)
924 +#define bproc_hook_imv(defl,func,args) ((hookname(func)&¤t->bproc.masq)?hookname(func)args:defl)
926 +#define bproc_isghost(tsk) ((tsk)->bproc.ghost != 0)
927 +#define bproc_ismasq(tsk) ((tsk)->bproc.masq != 0)
928 +#define bproc_set_arg(x) do{current->bproc.arg=(x);}while(0)
930 +/* Kernel call weirdness... a kernel call is a call made from the
931 + * kernel which we do not want to be subject to the usual rules for
932 + * PID masquerading. This is mostly used for drivers which create and
933 + * possibly wait for kernel threads which they create. These
934 + * functions are called from the relevant places within the kernel
935 + * (like within kernel_thread) to set a flag so that things will be
936 + * handled correctly later on. */
937 +static inline void bproc_no_kcall(void) {
938 + current->bproc.flag = (current->bproc.flag & ~3) | 2;
940 +static inline void bproc_clear_kcall(void) {
941 + current->bproc.flag &= ~3;
943 +static inline void bproc_kcall(void) {
944 + if (current->bproc.flag & 2)
945 + bproc_clear_kcall();
947 + current->bproc.flag |= 1; /* set kernel call flag */
951 +/* Stubs for when hooks are not compiled in */
952 +#define bproc_hook(func,args) do{}while(0)
953 +#define bproc_hook_im(func,args) do{}while(0)
954 +#define bproc_hook_imr(func,args) do{}while(0)
955 +#define bproc_hook_v(defl,func,args) (defl)
956 +#define bproc_hook_imv(defl,func,args) (defl)
957 +#define bproc_isghost(tsk) (0)
958 +#define bproc_ismasq(tsk) (0)
959 +#define bproc_set_arg(x) do{}while(0)
960 +#define bproc_no_kcall() do{}while(0)
961 +#define bproc_clear_kcall() do{}while(0)
962 +#define bproc_kcall() do{}while(0)
968 + * c-basic-offset: 4
971 Index: linux/include/asm-i386/unistd.h
972 ===================================================================
973 --- linux.orig/include/asm-i386/unistd.h 2002-11-28 18:53:15.000000000 -0500
974 +++ linux/include/asm-i386/unistd.h 2003-09-03 17:52:04.000000000 -0400
977 #ifdef __KERNEL_SYSCALLS__
979 +#include <linux/bproc.h>
981 * we need this inline - forking from kernel space will result
982 * in NO COPY ON WRITE (!!!), until an execve is executed. This
984 static inline _syscall3(int,open,const char *,file,int,flag,int,mode)
985 static inline _syscall1(int,close,int,fd)
986 static inline _syscall1(int,_exit,int,exitcode)
987 -static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
988 +static inline pid_t waitpid(pid_t pid, int *wait_stat, int options) {
991 + __asm__ volatile ("int $0x80"
993 + : "0" (__NR_waitpid),"b" ((long)(pid)),"c" ((long)(wait_stat)),
994 + "d" ((long)(options)));
995 + __syscall_return(pid_t,__res);
998 static inline _syscall1(int,delete_module,const char *,name)
1000 static inline pid_t wait(int * wait_stat)
1001 Index: linux/include/asm-alpha/unistd.h
1002 ===================================================================
1003 --- linux.orig/include/asm-alpha/unistd.h 2002-08-02 20:39:45.000000000 -0400
1004 +++ linux/include/asm-alpha/unistd.h 2003-09-03 17:52:04.000000000 -0400
1007 #include <linux/string.h>
1008 #include <linux/signal.h>
1009 +#include <linux/bproc.h>
1011 extern void sys_idle(void);
1012 static inline void idle(void)
1013 @@ -591,11 +592,13 @@
1015 static inline pid_t waitpid(int pid, int * wait_stat, int flags)
1018 return sys_wait4(pid, wait_stat, flags, NULL);
1021 static inline pid_t wait(int * wait_stat)
1024 return waitpid(-1,wait_stat,0);
1027 Index: linux/net/socket.c
1028 ===================================================================
1029 --- linux.orig/net/socket.c 2003-09-03 17:51:05.000000000 -0400
1030 +++ linux/net/socket.c 2003-09-03 17:52:04.000000000 -0400
1032 * in the operation structures but are done directly via the socketcall() multiplexor.
1035 -static struct file_operations socket_file_ops = {
1036 +struct file_operations socket_file_ops = {
1040 @@ -298,13 +298,13 @@
1044 -static struct vfsmount *sock_mnt;
1045 +struct vfsmount *sock_mnt;
1046 static DECLARE_FSTYPE(sock_fs_type, "sockfs", sockfs_read_super, FS_NOMOUNT);
1047 static int sockfs_delete_dentry(struct dentry *dentry)
1051 -static struct dentry_operations sockfs_dentry_operations = {
1052 +struct dentry_operations sockfs_dentry_operations = {
1053 d_delete: sockfs_delete_dentry,
1056 Index: linux/net/netsyms.c
1057 ===================================================================
1058 --- linux.orig/net/netsyms.c 2003-09-03 17:52:04.000000000 -0400
1059 +++ linux/net/netsyms.c 2003-09-03 17:52:04.000000000 -0400
1060 @@ -599,4 +599,11 @@
1061 EXPORT_SYMBOL(wireless_send_event);
1062 #endif /* CONFIG_NET_RADIO || CONFIG_NET_PCMCIA_RADIO */
1064 +extern struct vfsmount *sock_mnt;
1065 +extern struct dentry_operations sockfs_dentry_operations;
1066 +extern struct file_operations socket_file_ops;
1067 +EXPORT_SYMBOL(sock_mnt);
1068 +EXPORT_SYMBOL(sockfs_dentry_operations);
1069 +EXPORT_SYMBOL(socket_file_ops);
1071 #endif /* CONFIG_NET */
1072 Index: linux/arch/i386/config.in
1073 ===================================================================
1074 --- linux.orig/arch/i386/config.in 2003-09-03 17:51:06.000000000 -0400
1075 +++ linux/arch/i386/config.in 2003-09-03 17:52:04.000000000 -0400
1078 bool 'System V IPC' CONFIG_SYSVIPC
1079 bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT
1080 +bool 'Beowulf Distributed Process Space' CONFIG_BPROC
1081 bool 'Sysctl support' CONFIG_SYSCTL
1082 if [ "$CONFIG_PROC_FS" = "y" ]; then
1083 choice 'Kernel core (/proc/kcore) format' \
1084 Index: linux/arch/i386/kernel/signal.c
1085 ===================================================================
1086 --- linux.orig/arch/i386/kernel/signal.c 2002-08-02 20:39:42.000000000 -0400
1087 +++ linux/arch/i386/kernel/signal.c 2003-09-03 17:52:04.000000000 -0400
1089 #include <linux/stddef.h>
1090 #include <linux/tty.h>
1091 #include <linux/personality.h>
1092 +#include <linux/bproc.h>
1093 #include <asm/ucontext.h>
1094 #include <asm/uaccess.h>
1095 #include <asm/i387.h>
1097 /* Let the debugger run. */
1098 current->exit_code = signr;
1099 current->state = TASK_STOPPED;
1100 + bproc_hook_im(stop_notify,(signr));
1101 notify_parent(current, SIGCHLD);
1105 struct signal_struct *sig;
1106 current->state = TASK_STOPPED;
1107 current->exit_code = signr;
1108 + bproc_hook_im(stop_notify,(signr));
1109 sig = current->p_pptr->sig;
1110 if (sig && !(sig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP))
1111 notify_parent(current, SIGCHLD);
1112 Index: linux/arch/i386/kernel/ptrace.c
1113 ===================================================================
1114 --- linux.orig/arch/i386/kernel/ptrace.c 2002-08-02 20:39:42.000000000 -0400
1115 +++ linux/arch/i386/kernel/ptrace.c 2003-09-03 17:52:04.000000000 -0400
1117 #include <asm/i387.h>
1118 #include <asm/debugreg.h>
1120 +#include <linux/bproc.h>
1123 * does not yet catch signals sent when the child dies.
1124 * in exit.c or in signal.c.
1125 @@ -152,6 +154,15 @@
1126 struct task_struct *child;
1127 struct user * dummy = NULL;
1134 + if (bproc_hook_imv(0, ptracem, (request,&pid,addr,data,(long*)&ret,0))) {
1135 + if (ret == -ELOOP) goto retry_ptrace;
1141 @@ -178,14 +189,21 @@
1144 if (request == PTRACE_ATTACH) {
1145 + bproc_set_arg(addr);
1146 ret = ptrace_attach(child);
1150 + bproc_set_arg(request == PTRACE_DETACH ? addr : 0);
1151 ret = ptrace_check_attach(child, request == PTRACE_KILL);
1155 + if (bproc_isghost(child)) {
1156 + bproc_hook(ptraceg, (request,child,addr,data,(long*)&ret,0));
1161 /* when I and D space are separate, these will need to be fixed. */
1162 case PTRACE_PEEKTEXT: /* read word at location addr. */
1164 free_task_struct(child);
1167 + if (ret == -ELOOP) goto retry_ptrace;
1172 current->exit_code = SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
1174 current->state = TASK_STOPPED;
1175 + bproc_hook_im(stop_notify,(SIGTRAP));
1176 notify_parent(current, SIGCHLD);
1179 Index: linux/arch/i386/kernel/process.c
1180 ===================================================================
1181 --- linux.orig/arch/i386/kernel/process.c 2003-09-03 17:51:02.000000000 -0400
1182 +++ linux/arch/i386/kernel/process.c 2003-09-03 17:52:04.000000000 -0400
1184 #include <linux/reboot.h>
1185 #include <linux/init.h>
1186 #include <linux/mc146818rtc.h>
1187 +#include <linux/bproc.h>
1189 #include <asm/uaccess.h>
1190 #include <asm/pgtable.h>
1196 __asm__ __volatile__(
1197 "movl %%esp,%%esi\n\t"
1198 "int $0x80\n\t" /* Linux/i386 system call */
1199 @@ -789,6 +791,11 @@
1200 current->ptrace &= ~PT_DTRACE;
1203 + if (error == -ENOENT)
1204 + error = bproc_hook_imv(error, sys_execve,
1205 + (®s,(char *)regs.ebx,
1206 + (char **)regs.ecx, (char **)regs.edx));
1211 Index: linux/arch/i386/kernel/i386_ksyms.c
1212 ===================================================================
1213 --- linux.orig/arch/i386/kernel/i386_ksyms.c 2003-09-03 17:51:04.000000000 -0400
1214 +++ linux/arch/i386/kernel/i386_ksyms.c 2003-09-03 17:52:04.000000000 -0400
1215 @@ -107,6 +107,11 @@
1216 EXPORT_SYMBOL(__generic_copy_to_user);
1217 EXPORT_SYMBOL(strnlen_user);
1219 +asmlinkage void ret_from_sys_call(void) __asm__("ret_from_sys_call");
1220 +EXPORT_SYMBOL_NOVERS(ret_from_sys_call);
1221 +asmlinkage void syscall_trace(void);
1222 +EXPORT_SYMBOL(syscall_trace);
1224 EXPORT_SYMBOL(pci_alloc_consistent);
1225 EXPORT_SYMBOL(pci_free_consistent);
1227 Index: linux/arch/alpha/config.in
1228 ===================================================================
1229 --- linux.orig/arch/alpha/config.in 2003-09-03 17:51:04.000000000 -0400
1230 +++ linux/arch/alpha/config.in 2003-09-03 17:52:04.000000000 -0400
1233 bool 'Networking support' CONFIG_NET
1234 bool 'System V IPC' CONFIG_SYSVIPC
1235 +bool 'Beowulf Distributed Process Space' CONFIG_BPROC
1236 bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT
1237 bool 'Sysctl support' CONFIG_SYSCTL
1238 if [ "$CONFIG_PROC_FS" = "y" ]; then
1239 Index: linux/arch/alpha/kernel/signal.c
1240 ===================================================================
1241 --- linux.orig/arch/alpha/kernel/signal.c 2002-08-02 20:39:42.000000000 -0400
1242 +++ linux/arch/alpha/kernel/signal.c 2003-09-03 17:52:04.000000000 -0400
1244 #include <asm/uaccess.h>
1245 #include <asm/sigcontext.h>
1246 #include <asm/ucontext.h>
1247 +#include <linux/bproc.h>
1252 /* Let the debugger run. */
1253 current->exit_code = signr;
1254 current->state = TASK_STOPPED;
1255 + bproc_hook_im(stop_notify,(signr));
1256 notify_parent(current, SIGCHLD);
1258 single_stepping |= ptrace_cancel_bpt(current);
1261 current->state = TASK_STOPPED;
1262 current->exit_code = signr;
1263 + bproc_hook_im(stop_notify,(signr));
1264 if (!(current->p_pptr->sig->action[SIGCHLD-1]
1265 .sa.sa_flags & SA_NOCLDSTOP))
1266 notify_parent(current, SIGCHLD);
1267 Index: linux/arch/alpha/kernel/osf_sys.c
1268 ===================================================================
1269 --- linux.orig/arch/alpha/kernel/osf_sys.c 2002-08-02 20:39:42.000000000 -0400
1270 +++ linux/arch/alpha/kernel/osf_sys.c 2003-09-03 17:52:04.000000000 -0400
1272 #include <linux/file.h>
1273 #include <linux/types.h>
1274 #include <linux/ipc.h>
1275 +#include <linux/bproc.h>
1277 #include <asm/fpu.h>
1280 * isn't actually going to matter, as if the parent happens
1281 * to change we can happily return either of the pids.
1283 - (®s)->r20 = tsk->p_opptr->tgid;
1285 + (®s)->r20 = bproc_hook_imv(tsk->p_opptr->tgid,sys_getppid,(tsk->p_opptr));
1286 + return bproc_hook_imv(tsk->tgid,sys_getpid,());
1289 asmlinkage unsigned long osf_mmap(unsigned long addr, unsigned long len,
1290 Index: linux/arch/alpha/kernel/entry.S
1291 ===================================================================
1292 --- linux.orig/arch/alpha/kernel/entry.S 2003-09-03 17:52:01.000000000 -0400
1293 +++ linux/arch/alpha/kernel/entry.S 2003-09-03 17:52:04.000000000 -0400
1294 @@ -212,8 +212,10 @@
1295 * stack buildup, as we can't do system calls from kernel space.
1298 +.globl kernel_clone
1301 + ldgp $29,0($27) /* we can be called from a module */
1305 @@ -230,6 +232,23 @@
1306 br ret_from_sys_call
1310 +.globl ret_to_user_space
1311 +.ent ret_to_user_space
1313 + ldgp $29, 0($27) /* We can jump here from a module */
1314 + bsr $1, undo_switch_stack
1315 + lda $1, 8($31) /* Set ps = 8 */
1318 + /* This tidbit ripped from entSys. Is this appropriate here ? */
1319 + blt $0,syscall_error /* the call failed */
1321 + stq $31,72($30) /* a3=0 => no error */
1323 + br ret_from_sys_call
1324 +.end ret_to_user_space
1327 * arch_kernel_thread(fn, arg, clone_flags)
1329 @@ -240,19 +259,24 @@
1330 ldgp $29,0($27) /* we can be called from a module */
1331 .frame $30, 4*8, $26
1339 mov $16,$9 /* save fn */
1340 mov $17,$10 /* save arg */
1341 - or $18,$0,$16 /* shuffle flags to front; add CLONE_VM. */
1342 - bsr $26,kernel_clone
1343 + mov $18,$11 /* save flags */
1344 + bsr $26,bproc_kcall_
1346 + or $11,$0,$16 /* shuffle flags to front; add CLONE_VM. */
1347 + jsr $26,kernel_clone
1349 bne $20,1f /* $20 is non-zero in child */
1356 /* this is in child: look out as we don't have any stack here.. */
1358 .end __kernel_execve
1361 +.globl do_switch_stack
1362 .ent do_switch_stack
1364 lda $30,-SWITCH_STACK_SIZE($30)
1366 .end do_switch_stack
1369 +.globl undo_switch_stack
1370 .ent undo_switch_stack
1373 @@ -1062,7 +1088,7 @@
1374 .quad alpha_ni_syscall
1375 .quad alpha_ni_syscall
1376 .quad alpha_ni_syscall /* 290 */
1377 - .quad alpha_ni_syscall
1378 + .quad sys_ni_syscall /* bproc: please shut up... */
1379 .quad alpha_ni_syscall
1380 .quad alpha_ni_syscall
1381 .quad alpha_ni_syscall
1382 Index: linux/arch/alpha/kernel/alpha_ksyms.c
1383 ===================================================================
1384 --- linux.orig/arch/alpha/kernel/alpha_ksyms.c 2002-08-02 20:39:42.000000000 -0400
1385 +++ linux/arch/alpha/kernel/alpha_ksyms.c 2003-09-03 17:52:04.000000000 -0400
1386 @@ -164,6 +164,17 @@
1387 EXPORT_SYMBOL(sys_sync);
1388 EXPORT_SYMBOL(sys_wait4);
1390 +extern void kernel_clone(void);
1391 +extern void ret_to_user_space(void);
1392 +extern void do_switch_stack(void);
1393 +extern void undo_switch_stack(void);
1394 +asmlinkage void syscall_trace(void);
1395 +EXPORT_SYMBOL_NOVERS(kernel_clone);
1396 +EXPORT_SYMBOL_NOVERS(ret_to_user_space);
1397 +EXPORT_SYMBOL_NOVERS(do_switch_stack);
1398 +EXPORT_SYMBOL_NOVERS(undo_switch_stack);
1399 +EXPORT_SYMBOL(syscall_trace);
1401 /* Networking helper routines. */
1402 EXPORT_SYMBOL(csum_tcpudp_magic);
1403 EXPORT_SYMBOL(ip_compute_csum);
1404 Index: linux/arch/alpha/kernel/process.c
1405 ===================================================================
1406 --- linux.orig/arch/alpha/kernel/process.c 2001-09-30 15:26:08.000000000 -0400
1407 +++ linux/arch/alpha/kernel/process.c 2003-09-03 17:52:04.000000000 -0400
1409 #include <linux/reboot.h>
1410 #include <linux/tty.h>
1411 #include <linux/console.h>
1412 +#include <linux/bproc.h>
1414 #include <asm/reg.h>
1415 #include <asm/uaccess.h>
1417 error = do_execve(filename, argv, envp, ®s);
1420 + if (error == -ENOENT)
1421 + error = bproc_hook_imv(error, sys_execve,
1422 + (®s,ufilename,argv,envp));
1426 @@ -465,3 +469,10 @@
1431 +/* This is usually inlined. It's packaged in a function here so that
1432 + * we can call it from ASM code on this architecture. */
1433 +void bproc_kcall_(void)
1437 Index: linux/arch/alpha/kernel/ptrace.c
1438 ===================================================================
1439 --- linux.orig/arch/alpha/kernel/ptrace.c 2001-09-18 20:03:51.000000000 -0400
1440 +++ linux/arch/alpha/kernel/ptrace.c 2003-09-03 17:52:04.000000000 -0400
1442 #include <linux/ptrace.h>
1443 #include <linux/user.h>
1444 #include <linux/slab.h>
1445 +#include <linux/bproc.h>
1447 #include <asm/uaccess.h>
1448 #include <asm/pgtable.h>
1449 @@ -248,7 +249,15 @@
1450 int a4, int a5, struct pt_regs regs)
1452 struct task_struct *child;
1454 + long ret, orig_pid;
1459 + if (bproc_hook_imv(0, ptracem, (request,&pid,addr,data,&ret,®s.r0))) {
1460 + if (ret == -ELOOP && regs.r0) goto retry_ptrace;
1465 DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n",
1469 if (request == PTRACE_ATTACH) {
1470 + bproc_set_arg(addr);
1471 ret = ptrace_attach(child);
1474 @@ -282,15 +292,20 @@
1475 DBG(DBG_MEM, ("child not traced\n"));
1478 + if (child->p_pptr != current &&
1479 + !bproc_hook_v(0,ptrace_slave_call,(request,child,addr))) {
1480 + DBG(DBG_MEM, ("child not parent of this process\n"));
1483 + if (bproc_isghost(child)) {
1484 + bproc_hook(ptraceg,(request,child,addr,data,&ret,®s.r0));
1487 if (child->state != TASK_STOPPED) {
1488 DBG(DBG_MEM, ("child process not stopped\n"));
1489 if (request != PTRACE_KILL)
1492 - if (child->p_pptr != current) {
1493 - DBG(DBG_MEM, ("child not parent of this process\n"));
1498 /* When I and D space are separate, these will need to be fixed. */
1500 free_task_struct(child);
1503 + if (ret == -ELOOP && regs.r0) goto retry_ptrace;
1509 current->exit_code = SIGTRAP;
1510 current->state = TASK_STOPPED;
1511 + bproc_hook_im(stop_notify,(SIGTRAP));
1512 notify_parent(current, SIGCHLD);
1515 Index: linux/arch/ppc/config.in
1516 ===================================================================
1517 --- linux.orig/arch/ppc/config.in 2002-11-28 18:53:11.000000000 -0500
1518 +++ linux/arch/ppc/config.in 2003-09-03 17:52:04.000000000 -0400
1520 bool 'Networking support' CONFIG_NET
1521 bool 'Sysctl support' CONFIG_SYSCTL
1522 bool 'System V IPC' CONFIG_SYSVIPC
1523 +bool 'Beowulf Distributed Process Space' CONFIG_BPROC
1524 bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT
1526 # only elf supported, a.out is not -- Cort
1527 Index: linux/arch/ppc/kernel/signal.c
1528 ===================================================================
1529 --- linux.orig/arch/ppc/kernel/signal.c 2002-11-28 18:53:11.000000000 -0500
1530 +++ linux/arch/ppc/kernel/signal.c 2003-09-03 17:52:04.000000000 -0400
1532 #include <linux/unistd.h>
1533 #include <linux/stddef.h>
1534 #include <linux/elf.h>
1535 +#include <linux/bproc.h>
1536 #include <asm/ucontext.h>
1537 #include <asm/uaccess.h>
1538 #include <asm/pgtable.h>
1540 /* Let the debugger run. */
1541 current->exit_code = signr;
1542 current->state = TASK_STOPPED;
1543 + bproc_hook_im(stop_notify,(signr));
1544 notify_parent(current, SIGCHLD);
1549 current->state = TASK_STOPPED;
1550 current->exit_code = signr;
1551 + bproc_hook_im(stop_notify,(signr));
1552 if (!(current->p_pptr->sig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP))
1553 notify_parent(current, SIGCHLD);
1555 Index: linux/arch/ppc/kernel/ptrace.c
1556 ===================================================================
1557 --- linux.orig/arch/ppc/kernel/ptrace.c 2002-11-28 18:53:11.000000000 -0500
1558 +++ linux/arch/ppc/kernel/ptrace.c 2003-09-03 17:52:04.000000000 -0400
1560 #include <linux/errno.h>
1561 #include <linux/ptrace.h>
1562 #include <linux/user.h>
1563 +#include <linux/bproc.h>
1565 #include <asm/uaccess.h>
1566 #include <asm/page.h>
1567 @@ -161,6 +162,15 @@
1569 struct task_struct *child;
1576 + if (bproc_hook_imv(0, ptracem,(request,&pid,addr,data,(long*)&ret,0))){
1577 + if (ret == -ELOOP) goto retry_ptrace;
1582 if (request == PTRACE_TRACEME) {
1583 @@ -186,14 +196,21 @@
1586 if (request == PTRACE_ATTACH) {
1587 + bproc_set_arg(addr);
1588 ret = ptrace_attach(child);
1592 + bproc_set_arg(request == PTRACE_DETACH ? addr : 0);
1593 ret = ptrace_check_attach(child, request == PTRACE_KILL);
1597 + if (bproc_isghost(child)) {
1598 + bproc_hook(ptraceg, (request,child,addr,data,(long*)&ret,0));
1603 /* when I and D space are separate, these will need to be fixed. */
1604 case PTRACE_PEEKTEXT: /* read word at location addr. */
1606 free_task_struct(child);
1609 + if (ret == -ELOOP) goto retry_ptrace;
1615 current->exit_code = SIGTRAP;
1616 current->state = TASK_STOPPED;
1617 + bproc_hook_im(stop_notify,(SIGTRAP));
1618 notify_parent(current, SIGCHLD);
1621 Index: linux/arch/ppc/kernel/ppc_ksyms.c
1622 ===================================================================
1623 --- linux.orig/arch/ppc/kernel/ppc_ksyms.c 2002-11-28 18:53:11.000000000 -0500
1624 +++ linux/arch/ppc/kernel/ppc_ksyms.c 2003-09-03 17:52:04.000000000 -0400
1626 EXPORT_SYMBOL_NOVERS(agp_special_page);
1627 #endif /* defined(CONFIG_ALL_PPC) */
1629 +asmlinkage void ret_from_syscall_1(void) __asm__("ret_from_syscall_1");
1630 +EXPORT_SYMBOL_NOVERS(ret_from_syscall_1);
1631 Index: linux/arch/ppc/kernel/misc.S
1632 ===================================================================
1633 --- linux.orig/arch/ppc/kernel/misc.S 2003-09-03 17:51:02.000000000 -0400
1634 +++ linux/arch/ppc/kernel/misc.S 2003-09-03 17:52:04.000000000 -0400
1635 @@ -901,6 +901,20 @@
1636 * arch_kernel_thread(fn, arg, flags)
1638 _GLOBAL(arch_kernel_thread)
1639 + stwu r1,-28(r1) /* Setup stack frame to save args */
1645 + bl bproc_kcall_ /* Call bproc_kcall_ hook */
1646 + lwz r0, 32(r1) /* Restore stack + arguments */
1653 mr r6,r3 /* function */
1654 ori r3,r5,CLONE_VM /* flags */
1656 @@ -941,7 +955,29 @@
1662 + stwu r1,-28(r1) /* Setup stack frame to save args */
1668 + bl bproc_kcall_ /* Call bproc_kcall_ hook */
1669 + lwz r0, 32(r1) /* Restore stack + arguments */
1676 + li r0,__NR_waitpid
1680 + stw r3,errno@l(r4)
1685 SYSCALL(delete_module)
1687 Index: linux/arch/ppc/kernel/process.c
1688 ===================================================================
1689 --- linux.orig/arch/ppc/kernel/process.c 2001-11-26 08:29:17.000000000 -0500
1690 +++ linux/arch/ppc/kernel/process.c 2003-09-03 17:52:04.000000000 -0400
1692 #include <linux/user.h>
1693 #include <linux/elf.h>
1694 #include <linux/init.h>
1695 +#include <linux/bproc.h>
1697 #include <asm/pgtable.h>
1698 #include <asm/uaccess.h>
1699 @@ -443,6 +444,10 @@
1700 current->ptrace &= ~PT_DTRACE;
1703 + if (error == -ENOENT)
1704 + error = bproc_hook_imv(error, sys_execve,
1705 + (regs,(char*)a0,(char**)a1,(char**)a2));
1710 @@ -605,3 +610,10 @@
1711 } while (count++ < 16);
1715 +/* This is usually inlined. It's packaged in a function here so that
1716 + * we can call it from ASM code on this architecture. */
1717 +void bproc_kcall_(void)
1721 Index: linux/fs/inode.c
1722 ===================================================================
1723 --- linux.orig/fs/inode.c 2003-09-03 17:52:00.000000000 -0400
1724 +++ linux/fs/inode.c 2003-09-03 17:52:04.000000000 -0400
1725 @@ -816,6 +816,76 @@
1730 + * This just initializes the inode fields
1731 + * to known values before returning the inode..
1733 + * i_sb, i_ino, i_count, i_state and the lists have
1734 + * been initialized elsewhere..
1736 +static void clean_inode(struct inode *inode)
1738 + static struct address_space_operations empty_aops;
1739 + static struct inode_operations empty_iops;
1740 + static struct file_operations empty_fops;
1741 + memset(&inode->u, 0, sizeof(inode->u));
1742 + inode->i_sock = 0;
1743 + inode->i_op = &empty_iops;
1744 + inode->i_fop = &empty_fops;
1745 + inode->i_nlink = 1;
1746 + atomic_set(&inode->i_writecount, 0);
1747 + inode->i_size = 0;
1748 + inode->i_blocks = 0;
1749 + inode->i_generation = 0;
1750 + memset(&inode->i_dquot, 0, sizeof(inode->i_dquot));
1751 + inode->i_pipe = NULL;
1752 + inode->i_bdev = NULL;
1753 + inode->i_cdev = NULL;
1754 + inode->i_data.a_ops = &empty_aops;
1755 + inode->i_data.host = inode;
1756 + inode->i_data.gfp_mask = GFP_HIGHUSER;
1757 + inode->i_mapping = &inode->i_data;
1761 + * get_empty_inode - obtain an inode
1763 + * This is called by things like the networking layer
1764 + * etc that want to get an inode without any inode
1765 + * number, or filesystems that allocate new inodes with
1766 + * no pre-existing information.
1768 + * On a successful return the inode pointer is returned. On a failure
1769 + * a %NULL pointer is returned. The returned inode is not on any superblock
1773 +struct inode * get_empty_inode(void)
1775 + static unsigned long last_ino;
1776 + struct inode * inode;
1778 + spin_lock_prefetch(&inode_lock);
1780 + inode = (struct inode *) kmem_cache_alloc(inode_cachep, SLAB_KERNEL);
1783 + spin_lock(&inode_lock);
1784 + inodes_stat.nr_inodes++;
1785 + list_add(&inode->i_list, &inode_in_use);
1786 + inode->i_sb = NULL;
1788 + inode->i_blkbits = 0;
1789 + inode->i_ino = ++last_ino;
1790 + inode->i_flags = 0;
1791 + atomic_set(&inode->i_count, 1);
1792 + inode->i_state = 0;
1793 + spin_unlock(&inode_lock);
1794 + clean_inode(inode);
1800 * new_inode - obtain an inode
1802 Index: linux/include/linux/fs.h
1803 ===================================================================
1804 --- linux.orig/include/linux/fs.h 2003-09-03 17:52:02.000000000 -0400
1805 +++ linux/include/linux/fs.h 2003-09-03 17:52:04.000000000 -0400
1806 @@ -1440,6 +1440,7 @@
1808 extern void clear_inode(struct inode *);
1809 extern struct inode *new_inode(struct super_block *sb);
1810 +extern struct inode * get_empty_inode(void);
1811 extern void remove_suid(struct inode *inode);
1813 extern void insert_inode_hash(struct inode *);
1814 Index: linux/arch/i386/kernel/setup.c
1815 ===================================================================
1816 --- linux.orig/arch/i386/kernel/setup.c 2003-09-03 17:51:01.000000000 -0400
1817 +++ linux/arch/i386/kernel/setup.c 2003-09-03 17:53:05.000000000 -0400
1819 static u32 disabled_x86_caps[NCAPINTS] __initdata = { 0 };
1820 extern int blk_nohighio;
1822 +int enable_acpi_smp_table;
1825 * This is set up by the setup-routine at boot-time