2 ===================================================================
3 --- linux.orig/fs/exec.c 2003-09-03 17:52:00.000000000 -0400
4 +++ linux/fs/exec.c 2003-09-03 17:52:04.000000000 -0400
6 #include <linux/utsname.h>
8 #include <linux/module.h>
9 +#include <linux/bproc.h>
11 #include <asm/uaccess.h>
12 #include <asm/pgalloc.h>
14 xa_call_actions (XA_EXEC, XA_KOE, NULL);
16 retval = search_binary_handler(&bprm,regs);
20 + bproc_hook_im(do_execve,());
25 /* Something went wrong, return the inode and free the argument pages*/
26 Index: linux/fs/binfmt_script.c
27 ===================================================================
28 --- linux.orig/fs/binfmt_script.c 2002-08-02 20:39:45.000000000 -0400
29 +++ linux/fs/binfmt_script.c 2003-09-03 17:52:04.000000000 -0400
31 #include <linux/init.h>
32 #include <linux/file.h>
33 #include <linux/smp_lock.h>
34 +#include <linux/bproc.h>
36 static int load_script(struct linux_binprm *bprm,struct pt_regs *regs)
39 * user environment and arguments are stored.
41 remove_arg_zero(bprm);
42 - retval = copy_strings_kernel(1, &bprm->filename, bprm);
43 + retval = copy_strings_kernel(1,bproc_hook_v(&bprm->filename,load_script,(&bprm->filename)), bprm);
44 if (retval < 0) return retval;
47 Index: linux/fs/binfmt_elf.c
48 ===================================================================
49 --- linux.orig/fs/binfmt_elf.c 2002-08-02 20:39:45.000000000 -0400
50 +++ linux/fs/binfmt_elf.c 2003-09-03 17:52:04.000000000 -0400
52 #define ELF_PAGEOFFSET(_v) ((_v) & (ELF_MIN_ALIGN-1))
53 #define ELF_PAGEALIGN(_v) (((_v) + ELF_MIN_ALIGN - 1) & ~(ELF_MIN_ALIGN - 1))
55 -static struct linux_binfmt elf_format = {
56 +struct linux_binfmt elf_format = {
57 NULL, THIS_MODULE, load_elf_binary, load_elf_library, elf_core_dump, ELF_EXEC_PAGESIZE
60 Index: linux/fs/proc/base.c
61 ===================================================================
62 --- linux.orig/fs/proc/base.c 2003-09-03 17:52:00.000000000 -0400
63 +++ linux/fs/proc/base.c 2003-09-03 17:52:04.000000000 -0400
65 #include <linux/string.h>
66 #include <linux/seq_file.h>
67 #include <linux/namespace.h>
68 +#include <linux/bproc.h>
71 * For hysterical raisins we keep the same inumbers as in the old procfs.
73 if (!(page = __get_free_page(GFP_KERNEL)))
76 + if (bproc_isghost(task)) bproc_hook(refresh_status,(task));
77 length = inode->u.proc_i.op.proc_read(task, (char*)page);
81 static int proc_self_readlink(struct dentry *dentry, char *buffer, int buflen)
84 - sprintf(tmp, "%d", current->pid);
85 + sprintf(tmp, "%d", bproc_hook_imv(current->pid,proc3,()));
86 return vfs_readlink(dentry,buffer,buflen,tmp);
89 static int proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
92 - sprintf(tmp, "%d", current->pid);
93 + sprintf(tmp, "%d", bproc_hook_imv(current->pid,proc3,()));
94 return vfs_follow_link(nd,tmp);
101 + pid = bproc_hook_imv(pid,proc2,(pid));
102 read_lock(&tasklist_lock);
103 task = find_task_by_pid(pid);
105 @@ -1082,7 +1085,7 @@
107 read_lock(&tasklist_lock);
110 + int pid = bproc_hook_imv(p->pid,proc1,(p));
114 Index: linux/fs/proc/array.c
115 ===================================================================
116 --- linux.orig/fs/proc/array.c 2002-08-02 20:39:45.000000000 -0400
117 +++ linux/fs/proc/array.c 2003-09-03 17:52:04.000000000 -0400
119 #include <linux/smp.h>
120 #include <linux/signal.h>
121 #include <linux/highmem.h>
122 +#include <linux/bproc.h>
124 #include <asm/uaccess.h>
125 #include <asm/pgtable.h>
128 static inline const char * get_task_state(struct task_struct *tsk)
130 - unsigned int state = tsk->state & (TASK_RUNNING |
131 + unsigned int state = (bproc_hook_v(tsk->state,get_task_state,(tsk)))
134 TASK_UNINTERRUPTIBLE |
137 "Uid:\t%d\t%d\t%d\t%d\n"
138 "Gid:\t%d\t%d\t%d\t%d\n",
139 get_task_state(p), p->tgid,
140 - p->pid, p->pid ? p->p_opptr->pid : 0, 0,
141 + bproc_hook_imv(p->pid, proc_pid, (p)),
142 + bproc_hook_imv(p->p_opptr->pid, proc_ppid, (p)), 0,
143 p->uid, p->euid, p->suid, p->fsuid,
144 p->gid, p->egid, p->sgid, p->fsgid);
145 read_unlock(&tasklist_lock);
147 sigset_t sigign, sigcatch;
152 struct mm_struct *mm;
154 state = *get_task_state(task);
155 @@ -343,12 +346,14 @@
158 read_lock(&tasklist_lock);
159 - ppid = task->pid ? task->p_opptr->pid : 0;
160 + pid = bproc_hook_imv(task->pid, proc_pid, (task)),
161 + ppid = bproc_hook_imv(task->pid ? task->p_opptr->pid : 0,
162 + proc_ppid, (task));
163 read_unlock(&tasklist_lock);
164 res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \
165 %lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld %lu %lu %ld %lu %lu %lu %lu %lu \
166 %lu %lu %lu %lu %lu %lu %lu %lu %d %d\n",
172 Index: linux/kernel/timer.c
173 ===================================================================
174 --- linux.orig/kernel/timer.c 2003-09-03 17:51:01.000000000 -0400
175 +++ linux/kernel/timer.c 2003-09-03 17:52:04.000000000 -0400
177 #include <linux/smp_lock.h>
178 #include <linux/interrupt.h>
179 #include <linux/kernel_stat.h>
180 +#include <linux/bproc.h>
182 #include <asm/uaccess.h>
186 asmlinkage long sys_getpid(void)
188 - return current->tgid;
189 + return bproc_hook_imv(current->tgid, sys_getpid, ());
195 parent = me->p_opptr;
198 + pid = bproc_hook_imv(parent->pid,sys_getppid,(parent));
201 struct task_struct *old = parent;
202 Index: linux/kernel/signal.c
203 ===================================================================
204 --- linux.orig/kernel/signal.c 2003-09-03 17:51:01.000000000 -0400
205 +++ linux/kernel/signal.c 2003-09-03 17:52:04.000000000 -0400
208 #include <asm/uaccess.h>
210 +#include <linux/bproc.h>
213 * SLAB caches for signal bits.
216 if (sig < SIGRTMIN && sigismember(&t->pending.signal, sig))
219 + if (bproc_hook_v(0, send_sig_info, (sig, info, t)))
222 ret = deliver_signal(sig, info, t);
224 spin_unlock_irqrestore(&t->sigmask_lock, flags);
226 kill_pg_info(int sig, struct siginfo *info, pid_t pgrp)
228 int retval = -EINVAL;
230 + if (bproc_hook_imv(0,kill_pg_info, (sig, info, &pgrp, &retval)) == 1)
233 struct task_struct *p;
236 kill_sl_info(int sig, struct siginfo *info, pid_t sess)
238 int retval = -EINVAL;
239 + /* XXX bproc: Need ways to deal with session leaders...*/
241 struct task_struct *p;
245 struct task_struct *p;
247 + if (bproc_hook_imv(0, kill_proc_info,(sig, info, &pid, &error)) == 1)
250 read_lock(&tasklist_lock);
251 p = find_task_by_pid(pid);
254 read_unlock(&tasklist_lock);
255 return count ? retval : -ESRCH;
256 } else if (pid < 0) {
257 + /* XXX pid masq - do PG stuff. */
258 return kill_pg_info(sig, info, -pid);
260 return kill_proc_info(sig, info, pid);
262 EXPORT_SYMBOL(recalc_sigpending);
263 EXPORT_SYMBOL(send_sig);
264 EXPORT_SYMBOL(send_sig_info);
265 +EXPORT_SYMBOL(kill_something_info);
266 EXPORT_SYMBOL(block_all_signals);
267 EXPORT_SYMBOL(unblock_all_signals);
269 Index: linux/kernel/sched.c
270 ===================================================================
271 --- linux.orig/kernel/sched.c 2003-09-03 17:51:05.000000000 -0400
272 +++ linux/kernel/sched.c 2003-09-03 17:52:04.000000000 -0400
274 #include <linux/dump.h>
275 #include <linux/prefetch.h>
276 #include <linux/compiler.h>
277 +#include <linux/bproc.h>
279 #include <asm/uaccess.h>
280 #include <asm/mmu_context.h>
283 inline int wake_up_process(struct task_struct * p)
285 + if (p->state == TASK_STOPPED && bproc_ismasq(p))
286 + bproc_hook(wake_up_process, (p));
287 return try_to_wake_up(p, 0);
290 Index: linux/kernel/ksyms.c
291 ===================================================================
292 --- linux.orig/kernel/ksyms.c 2003-09-03 17:52:02.000000000 -0400
293 +++ linux/kernel/ksyms.c 2003-09-03 17:52:04.000000000 -0400
295 extern void set_device_ro(kdev_t dev,int flag);
297 extern void *sys_call_table;
298 +extern struct task_struct *child_reaper;
299 +#if defined(CONFIG_BINFMT_ELF)
300 +extern struct linux_binfmt elf_format;
303 extern struct timezone sys_tz;
304 extern int request_dma(unsigned int dmanr, char * deviceID);
306 EXPORT_SYMBOL(do_munmap);
307 EXPORT_SYMBOL(do_brk);
308 EXPORT_SYMBOL(exit_mm);
309 +EXPORT_SYMBOL(do_exit);
310 EXPORT_SYMBOL(exit_files);
311 EXPORT_SYMBOL(exit_fs);
312 EXPORT_SYMBOL(exit_sighand);
313 +EXPORT_SYMBOL(is_orphaned_pgrp);
314 +EXPORT_SYMBOL(child_reaper);
315 +#if defined(CONFIG_BINFMT_ELF)
316 +EXPORT_SYMBOL(elf_format);
318 +EXPORT_SYMBOL(alloc_uid);
319 +EXPORT_SYMBOL(free_uid);
320 EXPORT_SYMBOL(copy_fs_struct);
321 EXPORT_SYMBOL_GPL(make_pages_present);
324 EXPORT_SYMBOL(read_ahead);
325 EXPORT_SYMBOL(get_hash_table);
326 EXPORT_SYMBOL(new_inode);
327 +EXPORT_SYMBOL(get_empty_inode);
328 EXPORT_SYMBOL(insert_inode_hash);
329 EXPORT_SYMBOL(remove_inode_hash);
330 EXPORT_SYMBOL(buffer_insert_inode_queue);
331 Index: linux/kernel/fork.c
332 ===================================================================
333 --- linux.orig/kernel/fork.c 2003-09-03 17:52:00.000000000 -0400
334 +++ linux/kernel/fork.c 2003-09-03 17:52:04.000000000 -0400
336 #include <linux/personality.h>
337 #include <linux/compiler.h>
339 +#include <linux/bproc.h>
341 #include <asm/pgtable.h>
342 #include <asm/pgalloc.h>
343 #include <asm/uaccess.h>
346 static inline int copy_fs(unsigned long clone_flags, struct task_struct * tsk)
348 + if (!current->fs) return 0;
349 if (clone_flags & CLONE_FS) {
350 atomic_inc(¤t->fs->count);
357 + if ((retval = bproc_hook_v(p->pid, do_fork, (p, clone_flags))) < 0)
358 + goto bad_fork_cleanup_mm;
360 INIT_LIST_HEAD(&p->thread_group);
366 + bproc_hook(do_fork_2, (p));
367 write_unlock_irq(&tasklist_lock);
369 if (p->ptrace & PT_PTRACED)
371 wait_for_completion(&vfork);
374 + bproc_clear_kcall();
377 bad_fork_cleanup_namespace:
378 Index: linux/kernel/exit.c
379 ===================================================================
380 --- linux.orig/kernel/exit.c 2003-09-03 17:52:00.000000000 -0400
381 +++ linux/kernel/exit.c 2003-09-03 17:52:04.000000000 -0400
383 #include <asm/pgtable.h>
384 #include <asm/mmu_context.h>
386 +#include <linux/bproc.h>
388 extern void sem_exit (void);
389 extern struct task_struct *child_reaper;
395 + bproc_hook(release,(p));
396 atomic_dec(&p->user->processes);
401 int is_orphaned_pgrp(int pgrp)
403 - return will_become_orphaned_pgrp(pgrp, 0);
404 + return bproc_hook_imv(will_become_orphaned_pgrp(pgrp, 0),
405 + is_orphaned_pgrp,(pgrp));
408 static inline int has_stopped_jobs(int pgrp)
412 /* Make sure we're not reparenting to ourselves */
413 - p->p_opptr = child_reaper;
414 + p->p_opptr = bproc_hook_v(child_reaper, child_reaper, (p));
416 if (p->pdeath_signal) send_sig(p->pdeath_signal, p, 0);
422 + bproc_hook(do_exit, (tsk,code));
427 asmlinkage long sys_wait4(pid_t pid,unsigned int * stat_addr, int options, struct rusage * ru)
430 + pid_t orig_pid = pid;
431 DECLARE_WAITQUEUE(wait, current);
432 struct task_struct *tsk;
436 current->state = TASK_INTERRUPTIBLE;
437 read_lock(&tasklist_lock);
439 + if (bproc_hook_imv(0, sys_wait4_1, (&pid, stat_addr, options, ru, &retval)))
440 + goto end_wait4; /* handler will unlock tasklist_lock */
443 struct task_struct *p;
445 && !(options & __WALL))
448 - switch (p->state) {
449 + switch (bproc_hook_v(p->state,sys_wait4_2,(p))) {
454 retval = put_user((p->exit_code << 8) | 0x7f, stat_addr);
458 + retval = bproc_hook_imv(p->pid, sys_wait4_3, (p));
463 retval = put_user(p->exit_code, stat_addr);
467 + retval = bproc_hook_imv(p->pid, sys_wait4_3, (p));
468 if (p->p_opptr != p->p_pptr) {
469 write_lock_irq(&tasklist_lock);
472 write_unlock_irq(&tasklist_lock);
475 + bproc_hook_im(sys_wait4_4,(retval, options));
481 current->state = TASK_RUNNING;
482 remove_wait_queue(¤t->wait_chldexit,&wait);
483 + bproc_clear_kcall();
487 Index: linux/kernel/sys.c
488 ===================================================================
489 --- linux.orig/kernel/sys.c 2003-09-03 17:51:05.000000000 -0400
490 +++ linux/kernel/sys.c 2003-09-03 17:52:04.000000000 -0400
492 #include <asm/uaccess.h>
495 +#include <linux/bproc.h>
498 * this is where the system-wide overflow UID and GID are defined, for
499 * architectures that now have 32-bit UID/GID but didn't in the past
501 current->fsgid = new_egid;
502 current->egid = new_egid;
503 current->gid = new_rgid;
504 + bproc_hook_im(set_creds, ());
512 + bproc_hook_im(set_creds, ());
517 cap_emulate_setxuid(old_ruid, old_euid, old_suid);
520 + bproc_hook_im(set_creds, ());
525 cap_emulate_setxuid(old_ruid, old_euid, old_suid);
528 + bproc_hook_im(set_creds, ());
529 + bproc_hook_im(set_creds, ());
535 if (sgid != (gid_t) -1)
536 current->sgid = sgid;
537 + bproc_hook_im(set_creds, ());
545 + if (current->fsuid != old_fsuid) bproc_hook_im(set_creds, ());
551 current->fsgid = gid;
554 + if (current->fsgid != old_fsgid) bproc_hook_im(set_creds, ());
559 struct task_struct * p;
562 + bproc_hook_imr(sys_setpgid1, (pid, pgid));
571 + if (bproc_isghost(p)) bproc_hook(sys_setpgid2, (p));
574 /* All paths lead to here, thus we are safe. -DaveM */
577 asmlinkage long sys_getpgid(pid_t pid)
579 + bproc_hook_imr(sys_getpgid,(pid));
581 return current->pgrp;
583 @@ -930,23 +945,25 @@
584 asmlinkage long sys_getpgrp(void)
586 /* SMP - assuming writes are word atomic this is fine */
587 - return current->pgrp;
588 + return bproc_hook_imv(current->pgrp,sys_getpgrp,());
591 asmlinkage long sys_getsid(pid_t pid)
594 - return current->session;
595 + return bproc_hook_imv(current->session,sys_getsid1,());
598 struct task_struct *p;
599 + if (bproc_hook_imv(0,sys_getsid2, (&pid, &retval))==1)
602 read_lock(&tasklist_lock);
603 p = find_task_by_pid(pid);
607 - retval = p->session;
608 + retval = bproc_hook_imv(p->session,sys_getsid3,(p));
609 read_unlock(&tasklist_lock);
613 struct task_struct * p;
616 + bproc_hook_imr(sys_setsid,());
618 read_lock(&tasklist_lock);
620 if (p->pgrp == current->pid)
621 @@ -1011,6 +1030,7 @@
622 if(copy_from_user(current->groups, grouplist, gidsetsize * sizeof(gid_t)))
624 current->ngroups = gidsetsize;
625 + bproc_hook_im(set_creds, ());
629 Index: linux/kernel/ptrace.c
630 ===================================================================
631 --- linux.orig/kernel/ptrace.c 2003-09-03 17:51:04.000000000 -0400
632 +++ linux/kernel/ptrace.c 2003-09-03 17:52:04.000000000 -0400
634 #include <linux/mm.h>
635 #include <linux/highmem.h>
636 #include <linux/smp_lock.h>
637 +#include <linux/bproc.h>
639 #include <asm/pgtable.h>
640 #include <asm/uaccess.h>
642 if (!(child->ptrace & PT_PTRACED))
645 - if (child->p_pptr != current)
647 + if (child->p_pptr != current &&
648 + !bproc_hook_v(0,ptrace_slave_call,
649 + (PTRACE_DETACH, child, current->bproc.arg)))
652 + if (bproc_isghost(child))
656 if (child->state != TASK_STOPPED)
659 int ptrace_attach(struct task_struct *task)
666 task->ptrace |= PT_PTRACE_CAP;
670 write_lock_irq(&tasklist_lock);
671 if (task->p_pptr != current) {
672 + if (bproc_isghost(current) && !bproc_isghost(task)) ret = 1;
674 task->p_pptr = current;
677 + if (bproc_ismasq(task))
678 + bproc_hook(ptrace_attach, (task, current->bproc.arg, &ret));
679 write_unlock_irq(&tasklist_lock);
681 - send_sig(SIGSTOP, task, 1);
683 + if (bproc_isghost(task))
684 + bproc_hook(ptraceg,(PTRACE_ATTACH, task, 0, 0, &ret, 0));
686 + send_sig(SIGSTOP, task, 1);
693 int ptrace_detach(struct task_struct *child, unsigned int data)
696 if ((unsigned long) data > _NSIG)
699 @@ -111,14 +125,19 @@
701 child->exit_code = data;
702 write_lock_irq(&tasklist_lock);
703 + if (bproc_isghost(current) && !bproc_isghost(child) &&
704 + child->p_pptr != child->p_opptr)
707 + if (bproc_ismasq(child))
708 + bproc_hook(ptrace_detach,(child,(long*)&ret));
709 child->p_pptr = child->p_opptr;
711 write_unlock_irq(&tasklist_lock);
713 /* .. and wake it up. */
714 wake_up_process(child);
720 Index: linux/kernel/Makefile
721 ===================================================================
722 --- linux.orig/kernel/Makefile 2003-09-03 17:51:06.000000000 -0400
723 +++ linux/kernel/Makefile 2003-09-03 17:52:04.000000000 -0400
728 -export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o printk.o
729 +export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o printk.o bproc_hook.o
731 obj-y = sched.o dma.o fork.o exec_domain.o panic.o printk.o \
732 module.o exit.o itimer.o info.o time.o softirq.o resource.o \
734 obj-$(CONFIG_MODULES) += ksyms.o
735 obj-$(CONFIG_PM) += pm.o
736 obj-$(CONFIG_KALLSYMS) += kallsyms.o
737 +obj-$(CONFIG_BPROC) += bproc_hook.o
739 ifneq ($(CONFIG_IA64),y)
740 # According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is
741 Index: linux/kernel/bproc_hook.c
742 ===================================================================
743 --- linux.orig/kernel/bproc_hook.c 2003-09-03 17:52:04.000000000 -0400
744 +++ linux/kernel/bproc_hook.c 2003-09-03 17:52:04.000000000 -0400
746 +/*-------------------------------------------------------------------------
747 + * bproc_hook.c: Beowulf distributed PID space (bproc) definitions
749 + * Copyright (C) 2000 by Erik Hendriks <hendriks@scyld.com>
751 + * This program is free software; you can redistribute it and/or modify
752 + * it under the terms of the GNU General Public License as published by
753 + * the Free Software Foundation; either version 2 of the License, or
754 + * (at your option) any later version.
756 + * This program is distributed in the hope that it will be useful,
757 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
758 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
759 + * GNU General Public License for more details.
761 + * You should have received a copy of the GNU General Public License
762 + * along with this program; if not, write to the Free Software
763 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
765 + * Id: bproc-patch-2.4.20,v 1.8 2004/04/12 21:44:45 nic Exp $
766 + *-----------------------------------------------------------------------*/
767 +#include <linux/kernel.h>
768 +#include <linux/sched.h>
769 +#include <linux/module.h>
771 +#define bprocdeclhook(ret,func,args) \
772 + ret (* bproc_hook_ ## func ## _hook) args = 0;\
773 + EXPORT_SYMBOL( bproc_hook_ ## func ## _hook )
775 +#include <linux/bproc.h>
779 + * c-basic-offset: 4
782 Index: linux/include/linux/sched.h
783 ===================================================================
784 --- linux.orig/include/linux/sched.h 2003-09-03 17:51:06.000000000 -0400
785 +++ linux/include/linux/sched.h 2003-09-03 17:52:04.000000000 -0400
788 /* journalling filesystem info */
795 + struct bproc_masq_proc_t *masq;
796 + struct bproc_ghost_proc_t *ghost;
802 alloc_lock: SPIN_LOCK_UNLOCKED, \
803 exit_actions: NULL, \
804 journal_info: NULL, \
805 + bproc: {0, 0, 0, 0} \
809 Index: linux/include/linux/bproc.h
810 ===================================================================
811 --- linux.orig/include/linux/bproc.h 2003-09-03 17:52:04.000000000 -0400
812 +++ linux/include/linux/bproc.h 2003-09-03 17:52:04.000000000 -0400
814 +/*-------------------------------------------------------------------------
815 + * bproc.h: Beowulf distributed PID space (bproc) definitions
817 + * Copyright (C) 1999-2001 by Erik Hendriks <erik@hendriks.cx>
819 + * This program is free software; you can redistribute it and/or modify
820 + * it under the terms of the GNU General Public License as published by
821 + * the Free Software Foundation; either version 2 of the License, or
822 + * (at your option) any later version.
824 + * This program is distributed in the hope that it will be useful,
825 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
826 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
827 + * GNU General Public License for more details.
829 + * You should have received a copy of the GNU General Public License
830 + * along with this program; if not, write to the Free Software
831 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
833 + * Id: bproc-patch-2.4.20,v 1.8 2004/04/12 21:44:45 nic Exp $
834 + *-----------------------------------------------------------------------*/
835 +#ifndef _LINUX_BPROC_H
836 +#define _LINUX_BPROC_H
838 +#include <linux/config.h>
839 +#include <linux/types.h>
843 +#ifndef bprocdeclhook
844 +/* Function pointers for bproc hooks. */
845 +#define bprocdeclhook(ret,func,args) extern ret (* bproc_hook_ ## func ## _hook) args
848 +struct bproc_ghost_proc_t;
853 +/*----- fs/exec.c -------------------------------------------------------*/
854 +bprocdeclhook(void, do_execve, (void));
855 +/*----- fs/binfmt_script.c ----------------------------------------------*/
856 +bprocdeclhook(char**,load_script, (char **));
857 +/*----- fs/proc/array.c ----------------------------------------------------*/
858 +bprocdeclhook(void, refresh_status, (struct task_struct *));
859 +bprocdeclhook(int, get_task_state, (struct task_struct *));
860 +bprocdeclhook(int, proc_pid, (struct task_struct *));
861 +bprocdeclhook(int, proc_ppid, (struct task_struct *));
862 +bprocdeclhook(int, proc1, (struct task_struct *));
863 +bprocdeclhook(int, proc2, (int));
864 +bprocdeclhook(int, proc3, (void));
865 +/*----- kernel/timer.c --------------------------------------------------*/
866 +bprocdeclhook(int, sys_getpid, (void));
867 +bprocdeclhook(int, sys_getppid, (struct task_struct *));
868 +/*----- kernel/sched.c --------------------------------------------------*/
869 +bprocdeclhook(void, wake_up_process, (struct task_struct *));
870 +/*----- kernel/exit.c ---------------------------------------------------*/
871 +bprocdeclhook(void, release, (struct task_struct *));
872 +bprocdeclhook(int, is_orphaned_pgrp,(int));
873 +bprocdeclhook(struct task_struct *,child_reaper,(struct task_struct *));
874 +bprocdeclhook(void, do_exit, (struct task_struct *, long code));
875 +bprocdeclhook(int, sys_wait4_1, (pid_t *, unsigned int *, int,
876 + struct rusage *, int *));
877 +bprocdeclhook(long, sys_wait4_2, (struct task_struct *));
878 +bprocdeclhook(int, sys_wait4_3, (struct task_struct *));
879 +bprocdeclhook(void, sys_wait4_4, (pid_t, int options));
880 +/*----- kernel/fork.c ---------------------------------------------------*/
881 +bprocdeclhook(int, do_fork, (struct task_struct *, unsigned long));
882 +bprocdeclhook(void, do_fork_2, (struct task_struct *));
883 +/*----- kernel/signal.c -------------------------------------------------*/
884 +bprocdeclhook(int, send_sig_info, (int, struct siginfo *,
885 + struct task_struct *));
886 +bprocdeclhook(int, kill_pg_info, (int, struct siginfo *, pid_t *, int *));
887 +bprocdeclhook(int, kill_proc_info, (int, struct siginfo *, pid_t *, int *));
888 +/*----- kernel/sys.c ----------------------------------------------------*/
889 +bprocdeclhook(int, sys_setpgid1, (pid_t, pid_t));
890 +bprocdeclhook(void, sys_setpgid2, (struct task_struct *p));
891 +bprocdeclhook(int, sys_getpgid, (pid_t pid));
892 +bprocdeclhook(int, sys_getpgrp, (void));
893 +bprocdeclhook(int, sys_getsid1, (void));
894 +bprocdeclhook(int, sys_getsid2, (pid_t *pid, int *error));
895 +bprocdeclhook(int, sys_getsid3, (struct task_struct *p));
896 +bprocdeclhook(int, sys_setsid, (void));
897 +bprocdeclhook(void, set_creds, (void));
898 +/*----- arch/???/kernel/ptrace.c,signal.c -------------------------------*/
899 +bprocdeclhook(void, stop_notify, (int));
900 +bprocdeclhook(int, ptracem, (long, long *, long, long,
902 +bprocdeclhook(void, ptrace_attach, (struct task_struct *, long, long *));
903 +bprocdeclhook(void, ptraceg, (long, struct task_struct *, long,
904 + long, long *, long *));
905 +bprocdeclhook(int, ptrace_slave_call,(long, struct task_struct *, long));
906 +bprocdeclhook(void, ptrace_detach, (struct task_struct *, long *));
907 +bprocdeclhook(int, sys_execve, (struct pt_regs *, char *,
908 + char **, char **));
911 + * (none) = execute this hook if it's present.
913 + * nkc = no kernel call (kcall must be 0 to call hook)
914 + * r = return the value of this hook
915 + * v = hook returns a value.
917 +#define hookname(func) bproc_hook_ ## func ## _hook
918 +#define bproc_hook(func,args) do{if(hookname(func))hookname(func)args;}while(0)
919 +#define bproc_hook_im(func,args) do{if(hookname(func)&¤t->bproc.masq)hookname(func)args;}while(0)
920 +#define bproc_hook_imr(func,args) do{if(hookname(func)&¤t->bproc.masq)return hookname(func)args;}while(0)
921 +#define bproc_hook_v(defl,func,args) ( hookname(func) ?hookname(func)args:defl)
922 +#define bproc_hook_imv(defl,func,args) ((hookname(func)&¤t->bproc.masq)?hookname(func)args:defl)
924 +#define bproc_isghost(tsk) ((tsk)->bproc.ghost != 0)
925 +#define bproc_ismasq(tsk) ((tsk)->bproc.masq != 0)
926 +#define bproc_set_arg(x) do{current->bproc.arg=(x);}while(0)
928 +/* Kernel call weirdness... a kernel call is a call made from the
929 + * kernel which we do not want to be subject to the usual rules for
930 + * PID masquerading. This is mostly used for drivers which create and
931 + * possibly wait for kernel threads which they create. These
932 + * functions are called from the relevant places within the kernel
933 + * (like within kernel_thread) to set a flag so that things will be
934 + * handled correctly later on. */
935 +static inline void bproc_no_kcall(void) {
936 + current->bproc.flag = (current->bproc.flag & ~3) | 2;
938 +static inline void bproc_clear_kcall(void) {
939 + current->bproc.flag &= ~3;
941 +static inline void bproc_kcall(void) {
942 + if (current->bproc.flag & 2)
943 + bproc_clear_kcall();
945 + current->bproc.flag |= 1; /* set kernel call flag */
949 +/* Stubs for when hooks are not compiled in */
950 +#define bproc_hook(func,args) do{}while(0)
951 +#define bproc_hook_im(func,args) do{}while(0)
952 +#define bproc_hook_imr(func,args) do{}while(0)
953 +#define bproc_hook_v(defl,func,args) (defl)
954 +#define bproc_hook_imv(defl,func,args) (defl)
955 +#define bproc_isghost(tsk) (0)
956 +#define bproc_ismasq(tsk) (0)
957 +#define bproc_set_arg(x) do{}while(0)
958 +#define bproc_no_kcall() do{}while(0)
959 +#define bproc_clear_kcall() do{}while(0)
960 +#define bproc_kcall() do{}while(0)
966 + * c-basic-offset: 4
969 Index: linux/include/asm-i386/unistd.h
970 ===================================================================
971 --- linux.orig/include/asm-i386/unistd.h 2002-11-28 18:53:15.000000000 -0500
972 +++ linux/include/asm-i386/unistd.h 2003-09-03 17:52:04.000000000 -0400
975 #ifdef __KERNEL_SYSCALLS__
977 +#include <linux/bproc.h>
979 * we need this inline - forking from kernel space will result
980 * in NO COPY ON WRITE (!!!), until an execve is executed. This
982 static inline _syscall3(int,open,const char *,file,int,flag,int,mode)
983 static inline _syscall1(int,close,int,fd)
984 static inline _syscall1(int,_exit,int,exitcode)
985 -static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
986 +static inline pid_t waitpid(pid_t pid, int *wait_stat, int options) {
989 + __asm__ volatile ("int $0x80"
991 + : "0" (__NR_waitpid),"b" ((long)(pid)),"c" ((long)(wait_stat)),
992 + "d" ((long)(options)));
993 + __syscall_return(pid_t,__res);
996 static inline _syscall1(int,delete_module,const char *,name)
998 static inline pid_t wait(int * wait_stat)
999 Index: linux/include/asm-alpha/unistd.h
1000 ===================================================================
1001 --- linux.orig/include/asm-alpha/unistd.h 2002-08-02 20:39:45.000000000 -0400
1002 +++ linux/include/asm-alpha/unistd.h 2003-09-03 17:52:04.000000000 -0400
1005 #include <linux/string.h>
1006 #include <linux/signal.h>
1007 +#include <linux/bproc.h>
1009 extern void sys_idle(void);
1010 static inline void idle(void)
1011 @@ -591,11 +592,13 @@
1013 static inline pid_t waitpid(int pid, int * wait_stat, int flags)
1016 return sys_wait4(pid, wait_stat, flags, NULL);
1019 static inline pid_t wait(int * wait_stat)
1022 return waitpid(-1,wait_stat,0);
1025 Index: linux/net/socket.c
1026 ===================================================================
1027 --- linux.orig/net/socket.c 2003-09-03 17:51:05.000000000 -0400
1028 +++ linux/net/socket.c 2003-09-03 17:52:04.000000000 -0400
1030 * in the operation structures but are done directly via the socketcall() multiplexor.
1033 -static struct file_operations socket_file_ops = {
1034 +struct file_operations socket_file_ops = {
1038 @@ -298,13 +298,13 @@
1042 -static struct vfsmount *sock_mnt;
1043 +struct vfsmount *sock_mnt;
1044 static DECLARE_FSTYPE(sock_fs_type, "sockfs", sockfs_read_super, FS_NOMOUNT);
1045 static int sockfs_delete_dentry(struct dentry *dentry)
1049 -static struct dentry_operations sockfs_dentry_operations = {
1050 +struct dentry_operations sockfs_dentry_operations = {
1051 d_delete: sockfs_delete_dentry,
1054 Index: linux/net/netsyms.c
1055 ===================================================================
1056 --- linux.orig/net/netsyms.c 2003-09-03 17:52:04.000000000 -0400
1057 +++ linux/net/netsyms.c 2003-09-03 17:52:04.000000000 -0400
1058 @@ -599,4 +599,11 @@
1059 EXPORT_SYMBOL(wireless_send_event);
1060 #endif /* CONFIG_NET_RADIO || CONFIG_NET_PCMCIA_RADIO */
1062 +extern struct vfsmount *sock_mnt;
1063 +extern struct dentry_operations sockfs_dentry_operations;
1064 +extern struct file_operations socket_file_ops;
1065 +EXPORT_SYMBOL(sock_mnt);
1066 +EXPORT_SYMBOL(sockfs_dentry_operations);
1067 +EXPORT_SYMBOL(socket_file_ops);
1069 #endif /* CONFIG_NET */
1070 Index: linux/arch/i386/config.in
1071 ===================================================================
1072 --- linux.orig/arch/i386/config.in 2003-09-03 17:51:06.000000000 -0400
1073 +++ linux/arch/i386/config.in 2003-09-03 17:52:04.000000000 -0400
1076 bool 'System V IPC' CONFIG_SYSVIPC
1077 bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT
1078 +bool 'Beowulf Distributed Process Space' CONFIG_BPROC
1079 bool 'Sysctl support' CONFIG_SYSCTL
1080 if [ "$CONFIG_PROC_FS" = "y" ]; then
1081 choice 'Kernel core (/proc/kcore) format' \
1082 Index: linux/arch/i386/kernel/signal.c
1083 ===================================================================
1084 --- linux.orig/arch/i386/kernel/signal.c 2002-08-02 20:39:42.000000000 -0400
1085 +++ linux/arch/i386/kernel/signal.c 2003-09-03 17:52:04.000000000 -0400
1087 #include <linux/stddef.h>
1088 #include <linux/tty.h>
1089 #include <linux/personality.h>
1090 +#include <linux/bproc.h>
1091 #include <asm/ucontext.h>
1092 #include <asm/uaccess.h>
1093 #include <asm/i387.h>
1095 /* Let the debugger run. */
1096 current->exit_code = signr;
1097 current->state = TASK_STOPPED;
1098 + bproc_hook_im(stop_notify,(signr));
1099 notify_parent(current, SIGCHLD);
1103 struct signal_struct *sig;
1104 current->state = TASK_STOPPED;
1105 current->exit_code = signr;
1106 + bproc_hook_im(stop_notify,(signr));
1107 sig = current->p_pptr->sig;
1108 if (sig && !(sig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP))
1109 notify_parent(current, SIGCHLD);
1110 Index: linux/arch/i386/kernel/ptrace.c
1111 ===================================================================
1112 --- linux.orig/arch/i386/kernel/ptrace.c 2002-08-02 20:39:42.000000000 -0400
1113 +++ linux/arch/i386/kernel/ptrace.c 2003-09-03 17:52:04.000000000 -0400
1115 #include <asm/i387.h>
1116 #include <asm/debugreg.h>
1118 +#include <linux/bproc.h>
1121 * does not yet catch signals sent when the child dies.
1122 * in exit.c or in signal.c.
1123 @@ -152,6 +154,15 @@
1124 struct task_struct *child;
1125 struct user * dummy = NULL;
1132 + if (bproc_hook_imv(0, ptracem, (request,&pid,addr,data,(long*)&ret,0))) {
1133 + if (ret == -ELOOP) goto retry_ptrace;
1139 @@ -178,14 +189,21 @@
1142 if (request == PTRACE_ATTACH) {
1143 + bproc_set_arg(addr);
1144 ret = ptrace_attach(child);
1148 + bproc_set_arg(request == PTRACE_DETACH ? addr : 0);
1149 ret = ptrace_check_attach(child, request == PTRACE_KILL);
1153 + if (bproc_isghost(child)) {
1154 + bproc_hook(ptraceg, (request,child,addr,data,(long*)&ret,0));
1159 /* when I and D space are separate, these will need to be fixed. */
1160 case PTRACE_PEEKTEXT: /* read word at location addr. */
1162 free_task_struct(child);
1165 + if (ret == -ELOOP) goto retry_ptrace;
1170 current->exit_code = SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
1172 current->state = TASK_STOPPED;
1173 + bproc_hook_im(stop_notify,(SIGTRAP));
1174 notify_parent(current, SIGCHLD);
1177 Index: linux/arch/i386/kernel/process.c
1178 ===================================================================
1179 --- linux.orig/arch/i386/kernel/process.c 2003-09-03 17:51:02.000000000 -0400
1180 +++ linux/arch/i386/kernel/process.c 2003-09-03 17:52:04.000000000 -0400
1182 #include <linux/reboot.h>
1183 #include <linux/init.h>
1184 #include <linux/mc146818rtc.h>
1185 +#include <linux/bproc.h>
1187 #include <asm/uaccess.h>
1188 #include <asm/pgtable.h>
1194 __asm__ __volatile__(
1195 "movl %%esp,%%esi\n\t"
1196 "int $0x80\n\t" /* Linux/i386 system call */
1197 @@ -789,6 +791,11 @@
1198 current->ptrace &= ~PT_DTRACE;
1201 + if (error == -ENOENT)
1202 + error = bproc_hook_imv(error, sys_execve,
1203 + (®s,(char *)regs.ebx,
1204 + (char **)regs.ecx, (char **)regs.edx));
1209 Index: linux/arch/i386/kernel/i386_ksyms.c
1210 ===================================================================
1211 --- linux.orig/arch/i386/kernel/i386_ksyms.c 2003-09-03 17:51:04.000000000 -0400
1212 +++ linux/arch/i386/kernel/i386_ksyms.c 2003-09-03 17:52:04.000000000 -0400
1213 @@ -107,6 +107,11 @@
1214 EXPORT_SYMBOL(__generic_copy_to_user);
1215 EXPORT_SYMBOL(strnlen_user);
1217 +asmlinkage void ret_from_sys_call(void) __asm__("ret_from_sys_call");
1218 +EXPORT_SYMBOL_NOVERS(ret_from_sys_call);
1219 +asmlinkage void syscall_trace(void);
1220 +EXPORT_SYMBOL(syscall_trace);
1222 EXPORT_SYMBOL(pci_alloc_consistent);
1223 EXPORT_SYMBOL(pci_free_consistent);
1225 Index: linux/arch/alpha/config.in
1226 ===================================================================
1227 --- linux.orig/arch/alpha/config.in 2003-09-03 17:51:04.000000000 -0400
1228 +++ linux/arch/alpha/config.in 2003-09-03 17:52:04.000000000 -0400
1231 bool 'Networking support' CONFIG_NET
1232 bool 'System V IPC' CONFIG_SYSVIPC
1233 +bool 'Beowulf Distributed Process Space' CONFIG_BPROC
1234 bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT
1235 bool 'Sysctl support' CONFIG_SYSCTL
1236 if [ "$CONFIG_PROC_FS" = "y" ]; then
1237 Index: linux/arch/alpha/kernel/signal.c
1238 ===================================================================
1239 --- linux.orig/arch/alpha/kernel/signal.c 2002-08-02 20:39:42.000000000 -0400
1240 +++ linux/arch/alpha/kernel/signal.c 2003-09-03 17:52:04.000000000 -0400
1242 #include <asm/uaccess.h>
1243 #include <asm/sigcontext.h>
1244 #include <asm/ucontext.h>
1245 +#include <linux/bproc.h>
1250 /* Let the debugger run. */
1251 current->exit_code = signr;
1252 current->state = TASK_STOPPED;
1253 + bproc_hook_im(stop_notify,(signr));
1254 notify_parent(current, SIGCHLD);
1256 single_stepping |= ptrace_cancel_bpt(current);
1259 current->state = TASK_STOPPED;
1260 current->exit_code = signr;
1261 + bproc_hook_im(stop_notify,(signr));
1262 if (!(current->p_pptr->sig->action[SIGCHLD-1]
1263 .sa.sa_flags & SA_NOCLDSTOP))
1264 notify_parent(current, SIGCHLD);
1265 Index: linux/arch/alpha/kernel/osf_sys.c
1266 ===================================================================
1267 --- linux.orig/arch/alpha/kernel/osf_sys.c 2002-08-02 20:39:42.000000000 -0400
1268 +++ linux/arch/alpha/kernel/osf_sys.c 2003-09-03 17:52:04.000000000 -0400
1270 #include <linux/file.h>
1271 #include <linux/types.h>
1272 #include <linux/ipc.h>
1273 +#include <linux/bproc.h>
1275 #include <asm/fpu.h>
1278 * isn't actually going to matter, as if the parent happens
1279 * to change we can happily return either of the pids.
1281 - (®s)->r20 = tsk->p_opptr->tgid;
1283 + (®s)->r20 = bproc_hook_imv(tsk->p_opptr->tgid,sys_getppid,(tsk->p_opptr));
1284 + return bproc_hook_imv(tsk->tgid,sys_getpid,());
1287 asmlinkage unsigned long osf_mmap(unsigned long addr, unsigned long len,
1288 Index: linux/arch/alpha/kernel/entry.S
1289 ===================================================================
1290 --- linux.orig/arch/alpha/kernel/entry.S 2003-09-03 17:52:01.000000000 -0400
1291 +++ linux/arch/alpha/kernel/entry.S 2003-09-03 17:52:04.000000000 -0400
1292 @@ -212,8 +212,10 @@
1293 * stack buildup, as we can't do system calls from kernel space.
1296 +.globl kernel_clone
1299 + ldgp $29,0($27) /* we can be called from a module */
1303 @@ -230,6 +232,23 @@
1304 br ret_from_sys_call
1308 +.globl ret_to_user_space
1309 +.ent ret_to_user_space
1311 + ldgp $29, 0($27) /* We can jump here from a module */
1312 + bsr $1, undo_switch_stack
1313 + lda $1, 8($31) /* Set ps = 8 */
1316 + /* This tidbit ripped from entSys. Is this appropriate here ? */
1317 + blt $0,syscall_error /* the call failed */
1319 + stq $31,72($30) /* a3=0 => no error */
1321 + br ret_from_sys_call
1322 +.end ret_to_user_space
1325 * arch_kernel_thread(fn, arg, clone_flags)
1327 @@ -240,19 +259,24 @@
1328 ldgp $29,0($27) /* we can be called from a module */
1329 .frame $30, 4*8, $26
1337 mov $16,$9 /* save fn */
1338 mov $17,$10 /* save arg */
1339 - or $18,$0,$16 /* shuffle flags to front; add CLONE_VM. */
1340 - bsr $26,kernel_clone
1341 + mov $18,$11 /* save flags */
1342 + bsr $26,bproc_kcall_
1344 + or $11,$0,$16 /* shuffle flags to front; add CLONE_VM. */
1345 + jsr $26,kernel_clone
1347 bne $20,1f /* $20 is non-zero in child */
1354 /* this is in child: look out as we don't have any stack here.. */
1356 .end __kernel_execve
1359 +.globl do_switch_stack
1360 .ent do_switch_stack
1362 lda $30,-SWITCH_STACK_SIZE($30)
1364 .end do_switch_stack
1367 +.globl undo_switch_stack
1368 .ent undo_switch_stack
1371 @@ -1062,7 +1088,7 @@
1372 .quad alpha_ni_syscall
1373 .quad alpha_ni_syscall
1374 .quad alpha_ni_syscall /* 290 */
1375 - .quad alpha_ni_syscall
1376 + .quad sys_ni_syscall /* bproc: please shut up... */
1377 .quad alpha_ni_syscall
1378 .quad alpha_ni_syscall
1379 .quad alpha_ni_syscall
1380 Index: linux/arch/alpha/kernel/alpha_ksyms.c
1381 ===================================================================
1382 --- linux.orig/arch/alpha/kernel/alpha_ksyms.c 2002-08-02 20:39:42.000000000 -0400
1383 +++ linux/arch/alpha/kernel/alpha_ksyms.c 2003-09-03 17:52:04.000000000 -0400
1384 @@ -164,6 +164,17 @@
1385 EXPORT_SYMBOL(sys_sync);
1386 EXPORT_SYMBOL(sys_wait4);
1388 +extern void kernel_clone(void);
1389 +extern void ret_to_user_space(void);
1390 +extern void do_switch_stack(void);
1391 +extern void undo_switch_stack(void);
1392 +asmlinkage void syscall_trace(void);
1393 +EXPORT_SYMBOL_NOVERS(kernel_clone);
1394 +EXPORT_SYMBOL_NOVERS(ret_to_user_space);
1395 +EXPORT_SYMBOL_NOVERS(do_switch_stack);
1396 +EXPORT_SYMBOL_NOVERS(undo_switch_stack);
1397 +EXPORT_SYMBOL(syscall_trace);
1399 /* Networking helper routines. */
1400 EXPORT_SYMBOL(csum_tcpudp_magic);
1401 EXPORT_SYMBOL(ip_compute_csum);
1402 Index: linux/arch/alpha/kernel/process.c
1403 ===================================================================
1404 --- linux.orig/arch/alpha/kernel/process.c 2001-09-30 15:26:08.000000000 -0400
1405 +++ linux/arch/alpha/kernel/process.c 2003-09-03 17:52:04.000000000 -0400
1407 #include <linux/reboot.h>
1408 #include <linux/tty.h>
1409 #include <linux/console.h>
1410 +#include <linux/bproc.h>
1412 #include <asm/reg.h>
1413 #include <asm/uaccess.h>
1415 error = do_execve(filename, argv, envp, ®s);
1418 + if (error == -ENOENT)
1419 + error = bproc_hook_imv(error, sys_execve,
1420 + (®s,ufilename,argv,envp));
1424 @@ -465,3 +469,10 @@
1429 +/* This is usually inlined. It's packaged in a function here so that
1430 + * we can call it from ASM code on this architecture. */
1431 +void bproc_kcall_(void)
1435 Index: linux/arch/alpha/kernel/ptrace.c
1436 ===================================================================
1437 --- linux.orig/arch/alpha/kernel/ptrace.c 2001-09-18 20:03:51.000000000 -0400
1438 +++ linux/arch/alpha/kernel/ptrace.c 2003-09-03 17:52:04.000000000 -0400
1440 #include <linux/ptrace.h>
1441 #include <linux/user.h>
1442 #include <linux/slab.h>
1443 +#include <linux/bproc.h>
1445 #include <asm/uaccess.h>
1446 #include <asm/pgtable.h>
1447 @@ -248,7 +249,15 @@
1448 int a4, int a5, struct pt_regs regs)
1450 struct task_struct *child;
1452 + long ret, orig_pid;
1457 + if (bproc_hook_imv(0, ptracem, (request,&pid,addr,data,&ret,®s.r0))) {
1458 + if (ret == -ELOOP && regs.r0) goto retry_ptrace;
1463 DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n",
1467 if (request == PTRACE_ATTACH) {
1468 + bproc_set_arg(addr);
1469 ret = ptrace_attach(child);
1472 @@ -282,15 +292,20 @@
1473 DBG(DBG_MEM, ("child not traced\n"));
1476 + if (child->p_pptr != current &&
1477 + !bproc_hook_v(0,ptrace_slave_call,(request,child,addr))) {
1478 + DBG(DBG_MEM, ("child not parent of this process\n"));
1481 + if (bproc_isghost(child)) {
1482 + bproc_hook(ptraceg,(request,child,addr,data,&ret,®s.r0));
1485 if (child->state != TASK_STOPPED) {
1486 DBG(DBG_MEM, ("child process not stopped\n"));
1487 if (request != PTRACE_KILL)
1490 - if (child->p_pptr != current) {
1491 - DBG(DBG_MEM, ("child not parent of this process\n"));
1496 /* When I and D space are separate, these will need to be fixed. */
1498 free_task_struct(child);
1501 + if (ret == -ELOOP && regs.r0) goto retry_ptrace;
1507 current->exit_code = SIGTRAP;
1508 current->state = TASK_STOPPED;
1509 + bproc_hook_im(stop_notify,(SIGTRAP));
1510 notify_parent(current, SIGCHLD);
1513 Index: linux/arch/ppc/config.in
1514 ===================================================================
1515 --- linux.orig/arch/ppc/config.in 2002-11-28 18:53:11.000000000 -0500
1516 +++ linux/arch/ppc/config.in 2003-09-03 17:52:04.000000000 -0400
1518 bool 'Networking support' CONFIG_NET
1519 bool 'Sysctl support' CONFIG_SYSCTL
1520 bool 'System V IPC' CONFIG_SYSVIPC
1521 +bool 'Beowulf Distributed Process Space' CONFIG_BPROC
1522 bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT
1524 # only elf supported, a.out is not -- Cort
1525 Index: linux/arch/ppc/kernel/signal.c
1526 ===================================================================
1527 --- linux.orig/arch/ppc/kernel/signal.c 2002-11-28 18:53:11.000000000 -0500
1528 +++ linux/arch/ppc/kernel/signal.c 2003-09-03 17:52:04.000000000 -0400
1530 #include <linux/unistd.h>
1531 #include <linux/stddef.h>
1532 #include <linux/elf.h>
1533 +#include <linux/bproc.h>
1534 #include <asm/ucontext.h>
1535 #include <asm/uaccess.h>
1536 #include <asm/pgtable.h>
1538 /* Let the debugger run. */
1539 current->exit_code = signr;
1540 current->state = TASK_STOPPED;
1541 + bproc_hook_im(stop_notify,(signr));
1542 notify_parent(current, SIGCHLD);
1547 current->state = TASK_STOPPED;
1548 current->exit_code = signr;
1549 + bproc_hook_im(stop_notify,(signr));
1550 if (!(current->p_pptr->sig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP))
1551 notify_parent(current, SIGCHLD);
1553 Index: linux/arch/ppc/kernel/ptrace.c
1554 ===================================================================
1555 --- linux.orig/arch/ppc/kernel/ptrace.c 2002-11-28 18:53:11.000000000 -0500
1556 +++ linux/arch/ppc/kernel/ptrace.c 2003-09-03 17:52:04.000000000 -0400
1558 #include <linux/errno.h>
1559 #include <linux/ptrace.h>
1560 #include <linux/user.h>
1561 +#include <linux/bproc.h>
1563 #include <asm/uaccess.h>
1564 #include <asm/page.h>
1565 @@ -161,6 +162,15 @@
1567 struct task_struct *child;
1574 + if (bproc_hook_imv(0, ptracem,(request,&pid,addr,data,(long*)&ret,0))){
1575 + if (ret == -ELOOP) goto retry_ptrace;
1580 if (request == PTRACE_TRACEME) {
1581 @@ -186,14 +196,21 @@
1584 if (request == PTRACE_ATTACH) {
1585 + bproc_set_arg(addr);
1586 ret = ptrace_attach(child);
1590 + bproc_set_arg(request == PTRACE_DETACH ? addr : 0);
1591 ret = ptrace_check_attach(child, request == PTRACE_KILL);
1595 + if (bproc_isghost(child)) {
1596 + bproc_hook(ptraceg, (request,child,addr,data,(long*)&ret,0));
1601 /* when I and D space are separate, these will need to be fixed. */
1602 case PTRACE_PEEKTEXT: /* read word at location addr. */
1604 free_task_struct(child);
1607 + if (ret == -ELOOP) goto retry_ptrace;
1613 current->exit_code = SIGTRAP;
1614 current->state = TASK_STOPPED;
1615 + bproc_hook_im(stop_notify,(SIGTRAP));
1616 notify_parent(current, SIGCHLD);
1619 Index: linux/arch/ppc/kernel/ppc_ksyms.c
1620 ===================================================================
1621 --- linux.orig/arch/ppc/kernel/ppc_ksyms.c 2002-11-28 18:53:11.000000000 -0500
1622 +++ linux/arch/ppc/kernel/ppc_ksyms.c 2003-09-03 17:52:04.000000000 -0400
1624 EXPORT_SYMBOL_NOVERS(agp_special_page);
1625 #endif /* defined(CONFIG_ALL_PPC) */
1627 +asmlinkage void ret_from_syscall_1(void) __asm__("ret_from_syscall_1");
1628 +EXPORT_SYMBOL_NOVERS(ret_from_syscall_1);
1629 Index: linux/arch/ppc/kernel/misc.S
1630 ===================================================================
1631 --- linux.orig/arch/ppc/kernel/misc.S 2003-09-03 17:51:02.000000000 -0400
1632 +++ linux/arch/ppc/kernel/misc.S 2003-09-03 17:52:04.000000000 -0400
1633 @@ -901,6 +901,20 @@
1634 * arch_kernel_thread(fn, arg, flags)
1636 _GLOBAL(arch_kernel_thread)
1637 + stwu r1,-28(r1) /* Setup stack frame to save args */
1643 + bl bproc_kcall_ /* Call bproc_kcall_ hook */
1644 + lwz r0, 32(r1) /* Restore stack + arguments */
1651 mr r6,r3 /* function */
1652 ori r3,r5,CLONE_VM /* flags */
1654 @@ -941,7 +955,29 @@
1660 + stwu r1,-28(r1) /* Setup stack frame to save args */
1666 + bl bproc_kcall_ /* Call bproc_kcall_ hook */
1667 + lwz r0, 32(r1) /* Restore stack + arguments */
1674 + li r0,__NR_waitpid
1678 + stw r3,errno@l(r4)
1683 SYSCALL(delete_module)
1685 Index: linux/arch/ppc/kernel/process.c
1686 ===================================================================
1687 --- linux.orig/arch/ppc/kernel/process.c 2001-11-26 08:29:17.000000000 -0500
1688 +++ linux/arch/ppc/kernel/process.c 2003-09-03 17:52:04.000000000 -0400
1690 #include <linux/user.h>
1691 #include <linux/elf.h>
1692 #include <linux/init.h>
1693 +#include <linux/bproc.h>
1695 #include <asm/pgtable.h>
1696 #include <asm/uaccess.h>
1697 @@ -443,6 +444,10 @@
1698 current->ptrace &= ~PT_DTRACE;
1701 + if (error == -ENOENT)
1702 + error = bproc_hook_imv(error, sys_execve,
1703 + (regs,(char*)a0,(char**)a1,(char**)a2));
1708 @@ -605,3 +610,10 @@
1709 } while (count++ < 16);
1713 +/* This is usually inlined. It's packaged in a function here so that
1714 + * we can call it from ASM code on this architecture. */
1715 +void bproc_kcall_(void)
1719 Index: linux/fs/inode.c
1720 ===================================================================
1721 --- linux.orig/fs/inode.c 2003-09-03 17:52:00.000000000 -0400
1722 +++ linux/fs/inode.c 2003-09-03 17:52:04.000000000 -0400
1723 @@ -816,6 +816,76 @@
1728 + * This just initializes the inode fields
1729 + * to known values before returning the inode..
1731 + * i_sb, i_ino, i_count, i_state and the lists have
1732 + * been initialized elsewhere..
1734 +static void clean_inode(struct inode *inode)
1736 + static struct address_space_operations empty_aops;
1737 + static struct inode_operations empty_iops;
1738 + static struct file_operations empty_fops;
1739 + memset(&inode->u, 0, sizeof(inode->u));
1740 + inode->i_sock = 0;
1741 + inode->i_op = &empty_iops;
1742 + inode->i_fop = &empty_fops;
1743 + inode->i_nlink = 1;
1744 + atomic_set(&inode->i_writecount, 0);
1745 + inode->i_size = 0;
1746 + inode->i_blocks = 0;
1747 + inode->i_generation = 0;
1748 + memset(&inode->i_dquot, 0, sizeof(inode->i_dquot));
1749 + inode->i_pipe = NULL;
1750 + inode->i_bdev = NULL;
1751 + inode->i_cdev = NULL;
1752 + inode->i_data.a_ops = &empty_aops;
1753 + inode->i_data.host = inode;
1754 + inode->i_data.gfp_mask = GFP_HIGHUSER;
1755 + inode->i_mapping = &inode->i_data;
1759 + * get_empty_inode - obtain an inode
1761 + * This is called by things like the networking layer
1762 + * etc that want to get an inode without any inode
1763 + * number, or filesystems that allocate new inodes with
1764 + * no pre-existing information.
1766 + * On a successful return the inode pointer is returned. On a failure
1767 + * a %NULL pointer is returned. The returned inode is not on any superblock
1771 +struct inode * get_empty_inode(void)
1773 + static unsigned long last_ino;
1774 + struct inode * inode;
1776 + spin_lock_prefetch(&inode_lock);
1778 + inode = (struct inode *) kmem_cache_alloc(inode_cachep, SLAB_KERNEL);
1781 + spin_lock(&inode_lock);
1782 + inodes_stat.nr_inodes++;
1783 + list_add(&inode->i_list, &inode_in_use);
1784 + inode->i_sb = NULL;
1786 + inode->i_blkbits = 0;
1787 + inode->i_ino = ++last_ino;
1788 + inode->i_flags = 0;
1789 + atomic_set(&inode->i_count, 1);
1790 + inode->i_state = 0;
1791 + spin_unlock(&inode_lock);
1792 + clean_inode(inode);
1798 * new_inode - obtain an inode
1800 Index: linux/include/linux/fs.h
1801 ===================================================================
1802 --- linux.orig/include/linux/fs.h 2003-09-03 17:52:02.000000000 -0400
1803 +++ linux/include/linux/fs.h 2003-09-03 17:52:04.000000000 -0400
1804 @@ -1440,6 +1440,7 @@
1806 extern void clear_inode(struct inode *);
1807 extern struct inode *new_inode(struct super_block *sb);
1808 +extern struct inode * get_empty_inode(void);
1809 extern void remove_suid(struct inode *inode);
1811 extern void insert_inode_hash(struct inode *);
1812 Index: linux/arch/i386/kernel/setup.c
1813 ===================================================================
1814 --- linux.orig/arch/i386/kernel/setup.c 2003-09-03 17:51:01.000000000 -0400
1815 +++ linux/arch/i386/kernel/setup.c 2003-09-03 17:53:05.000000000 -0400
1817 static u32 disabled_x86_caps[NCAPINTS] __initdata = { 0 };
1818 extern int blk_nohighio;
1820 +int enable_acpi_smp_table;
1823 * This is set up by the setup-routine at boot-time