mirror of
https://github.com/torvalds/linux.git
synced 2024-12-26 04:42:12 +00:00
userns: Print out socket uids in a user namespace aware fashion.
Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> Cc: James Morris <jmorris@namei.org> Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org> Cc: Patrick McHardy <kaber@trash.net> Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> Cc: Sridhar Samudrala <sri@us.ibm.com> Acked-by: Vlad Yasevich <vyasevich@gmail.com> Acked-by: David S. Miller <davem@davemloft.net> Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
This commit is contained in:
parent
adb37c4c67
commit
a7cb5a49bf
@ -1509,7 +1509,8 @@ struct tcp_iter_state {
|
|||||||
sa_family_t family;
|
sa_family_t family;
|
||||||
enum tcp_seq_states state;
|
enum tcp_seq_states state;
|
||||||
struct sock *syn_wait_sk;
|
struct sock *syn_wait_sk;
|
||||||
int bucket, offset, sbucket, num, uid;
|
int bucket, offset, sbucket, num;
|
||||||
|
kuid_t uid;
|
||||||
loff_t last_pos;
|
loff_t last_pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -942,10 +942,7 @@ config UIDGID_CONVERTED
|
|||||||
depends on PROC_EVENTS = n
|
depends on PROC_EVENTS = n
|
||||||
|
|
||||||
# Networking
|
# Networking
|
||||||
depends on PACKET = n
|
|
||||||
depends on NET_9P = n
|
depends on NET_9P = n
|
||||||
depends on IPX = n
|
|
||||||
depends on PHONET = n
|
|
||||||
depends on NET_CLS_FLOW = n
|
depends on NET_CLS_FLOW = n
|
||||||
depends on NETFILTER_XT_MATCH_OWNER = n
|
depends on NETFILTER_XT_MATCH_OWNER = n
|
||||||
depends on NETFILTER_XT_MATCH_RECENT = n
|
depends on NETFILTER_XT_MATCH_RECENT = n
|
||||||
@ -953,14 +950,11 @@ config UIDGID_CONVERTED
|
|||||||
depends on NETFILTER_NETLINK_LOG = n
|
depends on NETFILTER_NETLINK_LOG = n
|
||||||
depends on INET = n
|
depends on INET = n
|
||||||
depends on IPV6 = n
|
depends on IPV6 = n
|
||||||
depends on IP_SCTP = n
|
|
||||||
depends on AF_RXRPC = n
|
depends on AF_RXRPC = n
|
||||||
depends on LLC2 = n
|
|
||||||
depends on NET_KEY = n
|
depends on NET_KEY = n
|
||||||
depends on INET_DIAG = n
|
depends on INET_DIAG = n
|
||||||
depends on DNS_RESOLVER = n
|
depends on DNS_RESOLVER = n
|
||||||
depends on AX25 = n
|
depends on AX25 = n
|
||||||
depends on ATALK = n
|
|
||||||
|
|
||||||
# Filesystems
|
# Filesystems
|
||||||
depends on USB_GADGETFS = n
|
depends on USB_GADGETFS = n
|
||||||
|
@ -183,7 +183,8 @@ static int atalk_seq_socket_show(struct seq_file *seq, void *v)
|
|||||||
ntohs(at->dest_net), at->dest_node, at->dest_port,
|
ntohs(at->dest_net), at->dest_node, at->dest_port,
|
||||||
sk_wmem_alloc_get(s),
|
sk_wmem_alloc_get(s),
|
||||||
sk_rmem_alloc_get(s),
|
sk_rmem_alloc_get(s),
|
||||||
s->sk_state, SOCK_INODE(s->sk_socket)->i_uid);
|
s->sk_state,
|
||||||
|
from_kuid_munged(seq_user_ns(seq), sock_i_uid(s)));
|
||||||
out:
|
out:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -845,7 +845,9 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
|
|||||||
bucket, src, srcp, dest, destp, sp->sk_state,
|
bucket, src, srcp, dest, destp, sp->sk_state,
|
||||||
sk_wmem_alloc_get(sp),
|
sk_wmem_alloc_get(sp),
|
||||||
sk_rmem_alloc_get(sp),
|
sk_rmem_alloc_get(sp),
|
||||||
0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
|
0, 0L, 0,
|
||||||
|
from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
|
||||||
|
0, sock_i_ino(sp),
|
||||||
atomic_read(&sp->sk_refcnt), sp,
|
atomic_read(&sp->sk_refcnt), sp,
|
||||||
atomic_read(&sp->sk_drops), len);
|
atomic_read(&sp->sk_drops), len);
|
||||||
}
|
}
|
||||||
|
@ -992,7 +992,9 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
|
|||||||
i, src, srcp, dest, destp, sp->sk_state,
|
i, src, srcp, dest, destp, sp->sk_state,
|
||||||
sk_wmem_alloc_get(sp),
|
sk_wmem_alloc_get(sp),
|
||||||
sk_rmem_alloc_get(sp),
|
sk_rmem_alloc_get(sp),
|
||||||
0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
|
0, 0L, 0,
|
||||||
|
from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
|
||||||
|
0, sock_i_ino(sp),
|
||||||
atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
|
atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2382,7 +2382,7 @@ void tcp_proc_unregister(struct net *net, struct tcp_seq_afinfo *afinfo)
|
|||||||
EXPORT_SYMBOL(tcp_proc_unregister);
|
EXPORT_SYMBOL(tcp_proc_unregister);
|
||||||
|
|
||||||
static void get_openreq4(const struct sock *sk, const struct request_sock *req,
|
static void get_openreq4(const struct sock *sk, const struct request_sock *req,
|
||||||
struct seq_file *f, int i, int uid, int *len)
|
struct seq_file *f, int i, kuid_t uid, int *len)
|
||||||
{
|
{
|
||||||
const struct inet_request_sock *ireq = inet_rsk(req);
|
const struct inet_request_sock *ireq = inet_rsk(req);
|
||||||
int ttd = req->expires - jiffies;
|
int ttd = req->expires - jiffies;
|
||||||
@ -2399,7 +2399,7 @@ static void get_openreq4(const struct sock *sk, const struct request_sock *req,
|
|||||||
1, /* timers active (only the expire timer) */
|
1, /* timers active (only the expire timer) */
|
||||||
jiffies_to_clock_t(ttd),
|
jiffies_to_clock_t(ttd),
|
||||||
req->retrans,
|
req->retrans,
|
||||||
uid,
|
from_kuid_munged(seq_user_ns(f), uid),
|
||||||
0, /* non standard timer */
|
0, /* non standard timer */
|
||||||
0, /* open_requests have no inode */
|
0, /* open_requests have no inode */
|
||||||
atomic_read(&sk->sk_refcnt),
|
atomic_read(&sk->sk_refcnt),
|
||||||
@ -2450,7 +2450,7 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i, int *len)
|
|||||||
timer_active,
|
timer_active,
|
||||||
jiffies_to_clock_t(timer_expires - jiffies),
|
jiffies_to_clock_t(timer_expires - jiffies),
|
||||||
icsk->icsk_retransmits,
|
icsk->icsk_retransmits,
|
||||||
sock_i_uid(sk),
|
from_kuid_munged(seq_user_ns(f), sock_i_uid(sk)),
|
||||||
icsk->icsk_probes_out,
|
icsk->icsk_probes_out,
|
||||||
sock_i_ino(sk),
|
sock_i_ino(sk),
|
||||||
atomic_read(&sk->sk_refcnt), sk,
|
atomic_read(&sk->sk_refcnt), sk,
|
||||||
|
@ -2110,7 +2110,9 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
|
|||||||
bucket, src, srcp, dest, destp, sp->sk_state,
|
bucket, src, srcp, dest, destp, sp->sk_state,
|
||||||
sk_wmem_alloc_get(sp),
|
sk_wmem_alloc_get(sp),
|
||||||
sk_rmem_alloc_get(sp),
|
sk_rmem_alloc_get(sp),
|
||||||
0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
|
0, 0L, 0,
|
||||||
|
from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
|
||||||
|
0, sock_i_ino(sp),
|
||||||
atomic_read(&sp->sk_refcnt), sp,
|
atomic_read(&sp->sk_refcnt), sp,
|
||||||
atomic_read(&sp->sk_drops), len);
|
atomic_read(&sp->sk_drops), len);
|
||||||
}
|
}
|
||||||
|
@ -1251,7 +1251,8 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
|
|||||||
sk_wmem_alloc_get(sp),
|
sk_wmem_alloc_get(sp),
|
||||||
sk_rmem_alloc_get(sp),
|
sk_rmem_alloc_get(sp),
|
||||||
0, 0L, 0,
|
0, 0L, 0,
|
||||||
sock_i_uid(sp), 0,
|
from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
|
||||||
|
0,
|
||||||
sock_i_ino(sp),
|
sock_i_ino(sp),
|
||||||
atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
|
atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
|
||||||
}
|
}
|
||||||
|
@ -1803,7 +1803,7 @@ static void tcp_v6_destroy_sock(struct sock *sk)
|
|||||||
#ifdef CONFIG_PROC_FS
|
#ifdef CONFIG_PROC_FS
|
||||||
/* Proc filesystem TCPv6 sock list dumping. */
|
/* Proc filesystem TCPv6 sock list dumping. */
|
||||||
static void get_openreq6(struct seq_file *seq,
|
static void get_openreq6(struct seq_file *seq,
|
||||||
const struct sock *sk, struct request_sock *req, int i, int uid)
|
const struct sock *sk, struct request_sock *req, int i, kuid_t uid)
|
||||||
{
|
{
|
||||||
int ttd = req->expires - jiffies;
|
int ttd = req->expires - jiffies;
|
||||||
const struct in6_addr *src = &inet6_rsk(req)->loc_addr;
|
const struct in6_addr *src = &inet6_rsk(req)->loc_addr;
|
||||||
@ -1827,7 +1827,7 @@ static void get_openreq6(struct seq_file *seq,
|
|||||||
1, /* timers active (only the expire timer) */
|
1, /* timers active (only the expire timer) */
|
||||||
jiffies_to_clock_t(ttd),
|
jiffies_to_clock_t(ttd),
|
||||||
req->retrans,
|
req->retrans,
|
||||||
uid,
|
from_kuid_munged(seq_user_ns(seq), uid),
|
||||||
0, /* non standard timer */
|
0, /* non standard timer */
|
||||||
0, /* open_requests have no inode */
|
0, /* open_requests have no inode */
|
||||||
0, req);
|
0, req);
|
||||||
@ -1877,7 +1877,7 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
|
|||||||
timer_active,
|
timer_active,
|
||||||
jiffies_to_clock_t(timer_expires - jiffies),
|
jiffies_to_clock_t(timer_expires - jiffies),
|
||||||
icsk->icsk_retransmits,
|
icsk->icsk_retransmits,
|
||||||
sock_i_uid(sp),
|
from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
|
||||||
icsk->icsk_probes_out,
|
icsk->icsk_probes_out,
|
||||||
sock_i_ino(sp),
|
sock_i_ino(sp),
|
||||||
atomic_read(&sp->sk_refcnt), sp,
|
atomic_read(&sp->sk_refcnt), sp,
|
||||||
|
@ -1458,7 +1458,8 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
|
|||||||
sk_wmem_alloc_get(sp),
|
sk_wmem_alloc_get(sp),
|
||||||
sk_rmem_alloc_get(sp),
|
sk_rmem_alloc_get(sp),
|
||||||
0, 0L, 0,
|
0, 0L, 0,
|
||||||
sock_i_uid(sp), 0,
|
from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
|
||||||
|
0,
|
||||||
sock_i_ino(sp),
|
sock_i_ino(sp),
|
||||||
atomic_read(&sp->sk_refcnt), sp,
|
atomic_read(&sp->sk_refcnt), sp,
|
||||||
atomic_read(&sp->sk_drops));
|
atomic_read(&sp->sk_drops));
|
||||||
|
@ -217,7 +217,8 @@ static int ipx_seq_socket_show(struct seq_file *seq, void *v)
|
|||||||
seq_printf(seq, "%08X %08X %02X %03d\n",
|
seq_printf(seq, "%08X %08X %02X %03d\n",
|
||||||
sk_wmem_alloc_get(s),
|
sk_wmem_alloc_get(s),
|
||||||
sk_rmem_alloc_get(s),
|
sk_rmem_alloc_get(s),
|
||||||
s->sk_state, SOCK_INODE(s->sk_socket)->i_uid);
|
s->sk_state,
|
||||||
|
from_kuid_munged(seq_user_ns(seq), sock_i_uid(s)));
|
||||||
out:
|
out:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3661,7 +3661,7 @@ static int pfkey_seq_show(struct seq_file *f, void *v)
|
|||||||
atomic_read(&s->sk_refcnt),
|
atomic_read(&s->sk_refcnt),
|
||||||
sk_rmem_alloc_get(s),
|
sk_rmem_alloc_get(s),
|
||||||
sk_wmem_alloc_get(s),
|
sk_wmem_alloc_get(s),
|
||||||
sock_i_uid(s),
|
from_kuid_munged(seq_user_ns(f), sock_i_uid(s)),
|
||||||
sock_i_ino(s)
|
sock_i_ino(s)
|
||||||
);
|
);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -151,7 +151,7 @@ static int llc_seq_socket_show(struct seq_file *seq, void *v)
|
|||||||
sk_wmem_alloc_get(sk),
|
sk_wmem_alloc_get(sk),
|
||||||
sk_rmem_alloc_get(sk) - llc->copied_seq,
|
sk_rmem_alloc_get(sk) - llc->copied_seq,
|
||||||
sk->sk_state,
|
sk->sk_state,
|
||||||
sk->sk_socket ? SOCK_INODE(sk->sk_socket)->i_uid : -1,
|
from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
|
||||||
llc->link);
|
llc->link);
|
||||||
out:
|
out:
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -3846,7 +3846,7 @@ static int packet_seq_show(struct seq_file *seq, void *v)
|
|||||||
po->ifindex,
|
po->ifindex,
|
||||||
po->running,
|
po->running,
|
||||||
atomic_read(&s->sk_rmem_alloc),
|
atomic_read(&s->sk_rmem_alloc),
|
||||||
sock_i_uid(s),
|
from_kuid_munged(seq_user_ns(seq), sock_i_uid(s)),
|
||||||
sock_i_ino(s));
|
sock_i_ino(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,7 +612,8 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
|
|||||||
sk->sk_protocol, pn->sobject, pn->dobject,
|
sk->sk_protocol, pn->sobject, pn->dobject,
|
||||||
pn->resource, sk->sk_state,
|
pn->resource, sk->sk_state,
|
||||||
sk_wmem_alloc_get(sk), sk_rmem_alloc_get(sk),
|
sk_wmem_alloc_get(sk), sk_rmem_alloc_get(sk),
|
||||||
sock_i_uid(sk), sock_i_ino(sk),
|
from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
|
||||||
|
sock_i_ino(sk),
|
||||||
atomic_read(&sk->sk_refcnt), sk,
|
atomic_read(&sk->sk_refcnt), sk,
|
||||||
atomic_read(&sk->sk_drops), &len);
|
atomic_read(&sk->sk_drops), &len);
|
||||||
}
|
}
|
||||||
@ -796,7 +797,8 @@ static int pn_res_seq_show(struct seq_file *seq, void *v)
|
|||||||
struct sock *sk = *psk;
|
struct sock *sk = *psk;
|
||||||
|
|
||||||
seq_printf(seq, "%02X %5d %lu%n",
|
seq_printf(seq, "%02X %5d %lu%n",
|
||||||
(int) (psk - pnres.sk), sock_i_uid(sk),
|
(int) (psk - pnres.sk),
|
||||||
|
from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
|
||||||
sock_i_ino(sk), &len);
|
sock_i_ino(sk), &len);
|
||||||
}
|
}
|
||||||
seq_printf(seq, "%*s\n", 63 - len, "");
|
seq_printf(seq, "%*s\n", 63 - len, "");
|
||||||
|
@ -216,7 +216,8 @@ static int sctp_eps_seq_show(struct seq_file *seq, void *v)
|
|||||||
seq_printf(seq, "%8pK %8pK %-3d %-3d %-4d %-5d %5d %5lu ", ep, sk,
|
seq_printf(seq, "%8pK %8pK %-3d %-3d %-4d %-5d %5d %5lu ", ep, sk,
|
||||||
sctp_sk(sk)->type, sk->sk_state, hash,
|
sctp_sk(sk)->type, sk->sk_state, hash,
|
||||||
epb->bind_addr.port,
|
epb->bind_addr.port,
|
||||||
sock_i_uid(sk), sock_i_ino(sk));
|
from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
|
||||||
|
sock_i_ino(sk));
|
||||||
|
|
||||||
sctp_seq_dump_local_addrs(seq, epb);
|
sctp_seq_dump_local_addrs(seq, epb);
|
||||||
seq_printf(seq, "\n");
|
seq_printf(seq, "\n");
|
||||||
@ -324,7 +325,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
|
|||||||
assoc->assoc_id,
|
assoc->assoc_id,
|
||||||
assoc->sndbuf_used,
|
assoc->sndbuf_used,
|
||||||
atomic_read(&assoc->rmem_alloc),
|
atomic_read(&assoc->rmem_alloc),
|
||||||
sock_i_uid(sk), sock_i_ino(sk),
|
from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
|
||||||
|
sock_i_ino(sk),
|
||||||
epb->bind_addr.port,
|
epb->bind_addr.port,
|
||||||
assoc->peer.port);
|
assoc->peer.port);
|
||||||
seq_printf(seq, " ");
|
seq_printf(seq, " ");
|
||||||
|
Loading…
Reference in New Issue
Block a user