@@ -89,6 +89,7 @@ static int audit_backlog_wait_overflow = 0;
8989/* The identity of the user shutting down the audit system. */
9090uid_t audit_sig_uid = -1 ;
9191pid_t audit_sig_pid = -1 ;
92+ u32 audit_sig_sid = 0 ;
9293
9394/* Records can be lost in several ways:
9495 0) [suppressed in audit_alloc]
@@ -479,7 +480,9 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
479480 struct audit_buffer * ab ;
480481 u16 msg_type = nlh -> nlmsg_type ;
481482 uid_t loginuid ; /* loginuid of sender */
482- struct audit_sig_info sig_data ;
483+ struct audit_sig_info * sig_data ;
484+ char * ctx ;
485+ u32 len ;
483486
484487 err = audit_netlink_ok (NETLINK_CB (skb ).eff_cap , msg_type );
485488 if (err )
@@ -531,12 +534,9 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
531534 if (status_get -> mask & AUDIT_STATUS_PID ) {
532535 int old = audit_pid ;
533536 if (sid ) {
534- char * ctx = NULL ;
535- u32 len ;
536- int rc ;
537- if ((rc = selinux_ctxid_to_string (
537+ if ((err = selinux_ctxid_to_string (
538538 sid , & ctx , & len )))
539- return rc ;
539+ return err ;
540540 else
541541 audit_log (NULL , GFP_KERNEL ,
542542 AUDIT_CONFIG_CHANGE ,
@@ -572,8 +572,6 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
572572 "user pid=%d uid=%u auid=%u" ,
573573 pid , uid , loginuid );
574574 if (sid ) {
575- char * ctx = NULL ;
576- u32 len ;
577575 if (selinux_ctxid_to_string (
578576 sid , & ctx , & len )) {
579577 audit_log_format (ab ,
@@ -612,10 +610,21 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
612610 loginuid , sid );
613611 break ;
614612 case AUDIT_SIGNAL_INFO :
615- sig_data .uid = audit_sig_uid ;
616- sig_data .pid = audit_sig_pid ;
613+ err = selinux_ctxid_to_string (audit_sig_sid , & ctx , & len );
614+ if (err )
615+ return err ;
616+ sig_data = kmalloc (sizeof (* sig_data ) + len , GFP_KERNEL );
617+ if (!sig_data ) {
618+ kfree (ctx );
619+ return - ENOMEM ;
620+ }
621+ sig_data -> uid = audit_sig_uid ;
622+ sig_data -> pid = audit_sig_pid ;
623+ memcpy (sig_data -> ctx , ctx , len );
624+ kfree (ctx );
617625 audit_send_reply (NETLINK_CB (skb ).pid , seq , AUDIT_SIGNAL_INFO ,
618- 0 , 0 , & sig_data , sizeof (sig_data ));
626+ 0 , 0 , sig_data , sizeof (* sig_data ) + len );
627+ kfree (sig_data );
619628 break ;
620629 default :
621630 err = - EINVAL ;
0 commit comments