5252#include  <linux/errno.h> 
5353#include  <linux/time.h> 
5454#include  <linux/proc_fs.h> 
55- #include  <linux/signal.h> 
5655#include  <linux/stat.h> 
5756#include  <linux/task_io_accounting_ops.h> 
5857#include  <linux/init.h> 
@@ -1069,12 +1068,18 @@ static const struct file_operations proc_ctl_operations = {
10691068
10701069static  ssize_t  eventmessage_read (struct  file  * file , char  __user  * buf ,
10711070size_t  count , loff_t  * ppos ) {
1071+ int  length ;
10721072struct  task_struct  * task  =  get_proc_task (file -> f_path .dentry -> d_inode );
10731073
1074- if  (count  <  sizeof (task -> ptrace_message ))
1075- return  - EIO ;
1074+ length  =  - ESRCH ;
1075+ if  (!task )
1076+ goto out_no_task ;
10761077
1077- return  put_user (task -> ptrace_message , buf );
1078+ length  =  simple_read_from_buffer (buf , count , ppos ,
1079+ (char  * )& task -> ptrace_message , sizeof (task -> ptrace_message ));
1080+ 
1081+ out_no_task :
1082+ return  length ;
10781083}
10791084
10801085static  const  struct  file_operations  proc_eventmessage_operations  =  {
@@ -1086,27 +1091,30 @@ static ssize_t last_siginfo_read(struct file *file, char __user *buf,
10861091size_t  count , loff_t  * ppos ) {
10871092unsigned long  flags ;
10881093siginfo_t  info ;
1089- int  error   =   - ESRCH ;
1094+ int  length ;
10901095struct  task_struct  * task  =  get_proc_task (file -> f_path .dentry -> d_inode );
10911096
1092- if  (count  <  sizeof (siginfo_t ) &&  lock_task_sighand (task , & flags )) {
1093- error  =  - EINVAL ;
1097+ length  =  - ESRCH ;
1098+ if  (!task )
1099+ goto out_no_task ;
1100+ length  =  - EINVAL ;
1101+ 
1102+ if  (lock_task_sighand (task , & flags )) {
1103+ length  =  0 ;
10941104if  (likely (task -> last_siginfo  !=  NULL )) {
10951105info  =  * task -> last_siginfo ;
1096- error  =  0 ;
1106+ length  =  sizeof ( info ) ;
10971107}
10981108
10991109unlock_task_sighand (task , & flags );
11001110}
11011111
1102- if  (!error ) {
1103- error  =  copy_siginfo_to_user ((siginfo_t  __user  * ) buf , & info );
1104- }
1105- 
1106- if  (!error )
1107- error  =  sizeof (siginfo_t );
1112+ if  (length  >= 0 )
1113+ length  =  simple_read_from_buffer (buf , count ,
1114+ ppos , (char  * )& info , length );
11081115
1109- return  error ;
1116+ out_no_task :
1117+ return  length ;
11101118}
11111119
11121120static  const  struct  file_operations  proc_last_siginfo_operations  =  {
0 commit comments