struct task_struct *tsk = current; 
void avc_audit(u32 ssid, u32 tsid,               u16 tclass, u32 requested,               struct av_decision *avd, int result, struct avc_audit_data *a){	struct task_struct *tsk = current;	struct inode *inode = NULL;	u32 denied, audited;	struct audit_buffer *ab;	denied = requested & ~avd->allowed;	if (denied) {		audited = denied;		if (!(audited & avd->auditdeny))			return;	} else if (result) {		audited = denied = requested;        } else {		audited = requested;		if (!(audited & avd->auditallow))			return;	}	ab = audit_log_start(current->audit_context);	if (!ab)		return;		/* audit_panic has been called */	audit_log_format(ab, "avc:  %s ", denied ? "denied" : "granted");	avc_dump_av(ab, tclass,audited);	audit_log_format(ab, " for ");	if (a && a->tsk)		tsk = a->tsk;	if (tsk && tsk->pid) {		struct mm_struct *mm;		struct vm_area_struct *vma;		audit_log_format(ab, " pid=%d", tsk->pid);		if (tsk == current)			mm = current->mm;		else			mm = get_task_mm(tsk);		if (mm) {			if (down_read_trylock(&mm->mmap_sem)) {				vma = mm->mmap;				while (vma) {					if ((vma->vm_flags & VM_EXECUTABLE) &&					    vma->vm_file) {						audit_log_d_path(ab, "exe=",							vma->vm_file->f_dentry,							vma->vm_file->f_vfsmnt);						break;					}					vma = vma->vm_next;				}				up_read(&mm->mmap_sem);			} else {				audit_log_format(ab, " comm=%s", tsk->comm);			}			if (tsk != current)				mmput(mm);		} else {			audit_log_format(ab, " comm=%s", tsk->comm);		}	}	if (a) {		switch (a->type) {		case AVC_AUDIT_DATA_IPC:			audit_log_format(ab, " key=%d", a->u.ipc_id);			break;		case AVC_AUDIT_DATA_CAP:			audit_log_format(ab, " capability=%d", a->u.cap);			break;		case AVC_AUDIT_DATA_FS:			if (a->u.fs.dentry) {				struct dentry *dentry = a->u.fs.dentry;				if (a->u.fs.mnt) {					audit_log_d_path(ab, "path=", dentry,							a->u.fs.mnt);				} else {					audit_log_format(ab, " name=%s",							 dentry->d_name.name);				}				inode = dentry->d_inode;			} else if (a->u.fs.inode) {				struct dentry *dentry;				inode = a->u.fs.inode;				dentry = d_find_alias(inode);				if (dentry) {					audit_log_format(ab, " name=%s",							 dentry->d_name.name);					dput(dentry);				}			}			if (inode)				audit_log_format(ab, " dev=%s ino=%ld",						 inode->i_sb->s_id,						 inode->i_ino);			break;		case AVC_AUDIT_DATA_NET:			if (a->u.net.sk) {				struct sock *sk = a->u.net.sk;				struct unix_sock *u;				int len = 0;				char *p = NULL;				switch (sk->sk_family) {				case AF_INET: {					struct inet_sock *inet = inet_sk(sk);					avc_print_ipv4_addr(ab, inet->rcv_saddr,							    inet->sport,							    "laddr", "lport");					avc_print_ipv4_addr(ab, inet->daddr,							    inet->dport,							    "faddr", "fport");					break;				}				case AF_INET6: {					struct inet_sock *inet = inet_sk(sk);					struct ipv6_pinfo *inet6 = inet6_sk(sk);					avc_print_ipv6_addr(ab, &inet6->rcv_saddr,							    inet->sport,							    "laddr", "lport");					avc_print_ipv6_addr(ab, &inet6->daddr,							    inet->dport,							    "faddr", "fport");					break;				}				case AF_UNIX:					u = unix_sk(sk);					if (u->dentry) {						audit_log_d_path(ab, "path=",							u->dentry, u->mnt);						break;					}					if (!u->addr)						break;					len = u->addr->len-sizeof(short);					p = &u->addr->name->sun_path[0];					if (*p)						audit_log_format(ab,							"path=%*.*s", len,							len, p);					else						audit_log_format(ab,							"path=@%*.*s", len-1,							len-1, p+1);					break;				}			}						switch (a->u.net.family) {			case AF_INET:				avc_print_ipv4_addr(ab, a->u.net.v4info.saddr,						    a->u.net.sport,						    "saddr", "src");				avc_print_ipv4_addr(ab, a->u.net.v4info.daddr,						    a->u.net.dport,						    "daddr", "dest");				break;			case AF_INET6:				avc_print_ipv6_addr(ab, &a->u.net.v6info.saddr,						    a->u.net.sport,						    "saddr", "src");				avc_print_ipv6_addr(ab, &a->u.net.v6info.daddr,						    a->u.net.dport,						    "daddr", "dest");				break;			}			if (a->u.net.netif)				audit_log_format(ab, " netif=%s",					a->u.net.netif);			break;		}	}	audit_log_format(ab, " ");	avc_dump_query(ab, ssid, tsid, tclass);	audit_log_end(ab);}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/219f0817038cabc722968e914490adf6b686499e/avc.c/buggy/security/selinux/avc.c