task ornaments
Subsystems (6)
PATCH 1/1 task ornaments
Hi Linus,
The attached patch does the following:
* adds task ornaments, which:
* permit notification of certain major process events (such as signals, exec, fork/clone, exit, syscall entry/exit).
* will permit ptrace() stuff to be done without task reparenting.
* will make it easier to produce a Wine support module.
* may make it possible to abstract out the parent signal notification.
* ([email protected] has also expressed interest with respect to tux).
* ([email protected] has also expressed interest with respect to the linux ABI stuff).
* ([email protected] has also expressed interest with respect to the IA64 performance monitor).
Most notable are the changes to the following files:
include/linux/taskornament.h
kernel/taskornament.c
David
arch/i386/kernel/ptrace.c +4 -0
@@ -13,6 +13,7 @@#include <linux/errno.h> #include <linux/ptrace.h> #include <linux/user.h> +#include <linux/taskornament.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
@@ -449,6 +450,9 @@ {if (!test_thread_flag (TIF_SYSCALL_TRACE ))return ; + +task_ornament_notify_syscall (regs,entryexit); +if (!(current->ptrace &PT_PTRACED ))return ;/* the 0x80 provides a way for the tracing parent to distinguish
arch/i386/kernel/signal.c +25 -0
@@ -20,6 +20,7 @@#include <linux/stddef.h> #include <linux/tty.h> #include <linux/personality.h> +#include <linux/taskornament.h> #include <asm/ucontext.h> #include <asm/uaccess.h> #include <asm/i387.h>
@@ -606,6 +607,27 @@if (!signr)break ; +if (!list_empty (¤t->ornaments)) { +int action =task_ornament_notify_signal (signr,&info); +switch (action) { +case 0 :/* no action */ +break ; +case -1 :/* cancelled */ +continue ; + +default : +/* change of signal +* - if the (new) signal is now blocked, requeue it +*/ + signr = action; +if (sigismember (¤t->blocked,signr)) { +send_sig_info (signr,&info,current); +continue ; + } +break ; + } + } +if ((current->ptrace &PT_PTRACED ) && signr !=SIGKILL ) {/* Let the debugger run. */ current->exit_code = signr;
@@ -724,4 +746,7 @@/* deal with pending signal delivery */ if (thread_info_flags & _TIF_SIGPENDING)do_signal (regs,oldset); + +if (thread_info_flags & _TIF_NOTIFY_RESUME) +task_ornament_notify_resume (regs); }
fs/exec.c +4 -0
@@ -36,6 +36,7 @@#include <linux/spinlock.h> #include <linux/personality.h> #include <linux/binfmts.h> +#include <linux/taskornament.h> #define __NO_VERSION__#include <linux/module.h>
@@ -549,6 +550,9 @@if (retval) goto mmap_failed;/* This is the point of no return */ +if (!list_empty (¤t->ornaments)) +task_ornament_notify_execve (); +release_old_signals (oldsig); current->sas_ss_sp = current->sas_ss_size =0 ;
fs/proc/base.c +19 -0
@@ -26,6 +26,7 @@#include <linux/seq_file.h> #include <linux/namespace.h> #include <linux/mm.h> +#include <linux/taskornament.h> /* * For hysterical raisins we keep the same inumbers as in the old procfs.
@@ -295,6 +296,19 @@ release: mounts_release, }; +static ssize_t pid_taskornlist_read (struct file * file,char * buf, +size_t count,loff_t *ppos) +{ +struct inode *inode = file->f_dentry->d_inode; +struct task_struct *task =proc_task (inode); + +return proc_pid_read_taskornlist (task, file, buf, count, ppos); +} + +static struct file_operations proc_taskornlist_operations = { + read: pid_taskornlist_read, +}; +#define PROC_BLOCK_SIZE (3*1024)/* 4K page size but our output routines use some slack for overruns */ static ssize_t proc_info_read(struct file * file, char * buf,
@@ -547,6 +561,7 @@PROC_PID_MAPS ,PROC_PID_CPU ,PROC_PID_MOUNTS , +PROC_PID_TASKORN , PROC_PID_FD_DIR = 0x8000, /* 0x8000-0xffff */ };
@@ -563,6 +578,7 @@#endif E (PROC_PID_MAPS ,"maps" ,S_IFREG |S_IRUGO ),E (PROC_PID_MEM ,"mem" ,S_IFREG |S_IRUSR |S_IWUSR ), +E (PROC_PID_TASKORN ,"ornaments" ,S_IFREG |S_IRUGO ),E (PROC_PID_CWD ,"cwd" ,S_IFLNK |S_IRWXUGO ),E (PROC_PID_ROOT ,"root" ,S_IFLNK |S_IRWXUGO ), E(PROC_PID_EXE, "exe", S_IFLNK|S_IRWXUGO),
@@ -937,6 +953,9 @@ inode->i_op = &proc_mem_inode_operations; inode->i_fop = &proc_mem_operations;break ; +case PROC_PID_TASKORN : + inode->i_fop = &proc_taskornlist_operations; +break ;case PROC_PID_MOUNTS : inode->i_fop = &proc_mounts_operations;break ;
include/linux/init_task.h +1 -0
@@ -76,6 +76,7 @@ pending: { NULL, &tsk.pending.head, {{0}}}, \ blocked: {{0}}, \ alloc_lock: SPIN_LOCK_UNLOCKED, \ + ornaments: LIST_HEAD_INIT(tsk.ornaments), \ journal_info: NULL, \ }
include/linux/sched.h +3 -0
@@ -345,6 +345,9 @@/* Protection of (de-)allocation: mm, files, fs, tty */ spinlock_t alloc_lock; +/* Task ornaments */ +struct list_head ornaments;/* must hold alloc_lock to walk/modify */ +/* journalling filesystem info */ void *journal_info; };
include/linux/taskornament.h +193 -0
193 lines not on this page · raw message
kernel/Makefile +2 -2
@@ -10,12 +10,12 @@ O_TARGET := kernel.o export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o \ - printk.o + printk.o taskornament.o obj-y = sched.o dma.o fork.o exec_domain.o panic.o printk.o \ module.o exit.o itimer.o info.o time.o softirq.o resource.o \ sysctl.o acct.o capability.o ptrace.o timer.o user.o \ - signal.o sys.o kmod.o context.o + signal.o sys.o kmod.o context.o taskornament.o obj-$(CONFIG_UID16) += uid16.o obj-$(CONFIG_MODULES) += ksyms.o
kernel/exit.c +2 -1
@@ -19,6 +19,7 @@#endif #include <linux/file.h> #include <linux/binfmts.h> +#include <linux/taskornament.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
@@ -462,7 +463,6 @@* as a result of our exiting, and if they have any stopped * jobs, send them a SIGHUP and then a SIGCONT. (POSIX 3.2.2.2) */ -write_lock_irq (&tasklist_lock); current->state =TASK_ZOMBIE ;do_notify_parent (current, current->exit_signal);
@@ -534,6 +534,7 @@if (tsk->binfmt && tsk->binfmt->module)__MOD_DEC_USE_COUNT (tsk->binfmt->module); +exit_task_ornaments (code); tsk->exit_code = code;exit_notify ();schedule ();
kernel/fork.c +10 -0
@@ -24,6 +24,7 @@#include <linux/file.h> #include <linux/binfmts.h> #include <linux/fs.h> +#include <linux/taskornament.h> #include <asm/pgtable.h> #include <asm/pgalloc.h>
@@ -722,6 +723,13 @@if (retval) goto bad_fork_cleanup_namespace; p->semundo =NULL ; + +/* +* tell attached ornaments that they may want to duplicate themselves +*/ +INIT_LIST_HEAD (&p->ornaments); +if (!list_empty (¤t->ornaments)) +task_ornament_notify_fork (p,clone_flags);/* Our parent execution domain becomes current domain These must match for thread signalling to apply */
@@ -874,4 +882,6 @@ SLAB_HWCACHE_ALIGN, NULL, NULL);if (!mm_cachep)panic ("vma_init: Cannot alloc mm_struct SLAB cache" ); + +task_ornament_init (); }
kernel/taskornament.c +692 -0
692 lines not on this page · raw message