diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c index e783244..118d8ae 100644 --- a/security/tomoyo/realpath.c +++ b/security/tomoyo/realpath.c @@ -230,15 +230,19 @@ static char *tomoyo_get_socket_name(const struct path *path, char * const buffer const int buflen) { struct inode *inode = d_backing_inode(path->dentry); - struct socket *sock = inode ? SOCKET_I(inode) : NULL; - struct sock *sk = sock ? sock->sk : NULL; + struct socket *sock; + struct sock *sk; + inode_lock(inode); + sock = SOCKET_I(inode); + sk = sock ? sock->sk : NULL; if (sk) { snprintf(buffer, buflen, "socket:[family=%u:type=%u:protocol=%u]", sk->sk_family, sk->sk_type, sk->sk_protocol); } else { snprintf(buffer, buflen, "socket:[unknown]"); } + inode_unlock(inode); return buffer; }