sanitize audit_mq_notify()
PATCH 6/15 sanitize audit_mq_notify()
* don't copy_from_user() twice
* don't bother with allocations
* don't duplicate parts of audit_dummy_context()
* make it return void
Signed-off-by Al Viro <[email protected]>
--- include/linux/audit.h | 9 +++---- ipc/mqueue.c | 14 ++++++------ kernel/auditsc.c | 56 ++++++++++++++----------------------------------- 3 files changed, 27 insertions(+), 52 deletions(-)
include/linux/audit.h +4 -5
@@ -451,7 +451,7 @@ extern int audit_set_macxattr(const char *name);extern int __audit_mq_open (int oflag,mode_t mode,struct mq_attr __user *u_attr);extern int __audit_mq_timedsend (mqd_t mqdes,size_t msg_len,unsigned int msg_prio,const struct timespec __user *u_abs_timeout);extern int __audit_mq_timedreceive (mqd_t mqdes,size_t msg_len,unsigned int __user *u_msg_prio,const struct timespec __user *u_abs_timeout); -extern int __audit_mq_notify (mqd_t mqdes,const struct sigevent __user *u_notification); +extern void __audit_mq_notify (mqd_t mqdes,const struct sigevent *notification);extern void __audit_mq_getsetattr (mqd_t mqdes,struct mq_attr *mqstat);static inline void audit_ipc_obj (struct kern_ipc_perm *ipcp)
@@ -488,11 +488,10 @@ static inline int audit_mq_timedreceive(mqd_t mqdes, size_t msg_len, unsigned inreturn __audit_mq_timedreceive (mqdes, msg_len, u_msg_prio, u_abs_timeout);return 0 ; } -static inline int audit_mq_notify (mqd_t mqdes,const struct sigevent __user *u_notification) +static inline void audit_mq_notify (mqd_t mqdes,const struct sigevent *notification) {if (unlikely (!audit_dummy_context ())) -return __audit_mq_notify (mqdes, u_notification); -return 0 ; +__audit_mq_notify (mqdes, notification); }static inline void audit_mq_getsetattr (mqd_t mqdes,struct mq_attr *mqstat) {
@@ -529,7 +528,7 @@ extern int audit_signals;#define audit_mq_open (o,m,a) ({ 0; })#define audit_mq_timedsend (d,l,p,t) ({ 0; })#define audit_mq_timedreceive (d,l,p,t) ({ 0; }) -#define audit_mq_notify (d,n) ({ 0; }) +#define audit_mq_notify (d,n) ((void)0)#define audit_mq_getsetattr (d,s) ((void)0)#define audit_ptrace (t) ((void)0)#define audit_n_rules 0
ipc/mqueue.c +7 -7
@@ -1000,17 +1000,17 @@ asmlinkage long sys_mq_notify(mqd_t mqdes,struct mqueue_inode_info *info;struct sk_buff *nc; - ret =audit_mq_notify (mqdes, u_notification); -if (ret !=0 ) -return ret; - - nc =NULL ; - sock =NULL ; -if (u_notification !=NULL ) { +if (u_notification) {if (copy_from_user (¬ification, u_notification,sizeof (struct sigevent )))return -EFAULT ; + } + +audit_mq_notify (mqdes, u_notification ? ¬ification :NULL ); + nc =NULL ; + sock =NULL ; +if (u_notification !=NULL ) {if (unlikely (notification.sigev_notify !=SIGEV_NONE && notification.sigev_notify !=SIGEV_SIGNAL && notification.sigev_notify !=SIGEV_THREAD ))
kernel/auditsc.c +16 -40
92 lines not on this page · raw message
Signature · 1 line
1.5.6.5
Quoted 7 lines · Al Viro
* don't
copy_from_user()twice
* don't bother with allocations
* don't duplicate parts ofaudit_dummy_context()
* make it return voidSigned-off-by Al Viro <[email protected]>
Reviewed-by James Morris <[email protected]>
Signature · 2 lines
James Morris <[email protected]>