aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/uapi/linux/packet_diag.h1
-rw-r--r--net/packet/diag.c19
2 files changed, 15 insertions, 5 deletions
diff --git a/include/uapi/linux/packet_diag.h b/include/uapi/linux/packet_diag.h
index afafd703ad92..84f83a47b6f6 100644
--- a/include/uapi/linux/packet_diag.h
+++ b/include/uapi/linux/packet_diag.h
@@ -32,6 +32,7 @@ enum {
32 PACKET_DIAG_RX_RING, 32 PACKET_DIAG_RX_RING,
33 PACKET_DIAG_TX_RING, 33 PACKET_DIAG_TX_RING,
34 PACKET_DIAG_FANOUT, 34 PACKET_DIAG_FANOUT,
35 PACKET_DIAG_UID,
35 36
36 __PACKET_DIAG_MAX, 37 __PACKET_DIAG_MAX,
37}; 38};
diff --git a/net/packet/diag.c b/net/packet/diag.c
index d3fcd1ebef7e..04c8219a2d06 100644
--- a/net/packet/diag.c
+++ b/net/packet/diag.c
@@ -125,8 +125,10 @@ static int pdiag_put_fanout(struct packet_sock *po, struct sk_buff *nlskb)
125 return ret; 125 return ret;
126} 126}
127 127
128static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct packet_diag_req *req, 128static int sk_diag_fill(struct sock *sk, struct sk_buff *skb,
129 u32 portid, u32 seq, u32 flags, int sk_ino) 129 struct packet_diag_req *req,
130 struct user_namespace *user_ns,
131 u32 portid, u32 seq, u32 flags, int sk_ino)
130{ 132{
131 struct nlmsghdr *nlh; 133 struct nlmsghdr *nlh;
132 struct packet_diag_msg *rp; 134 struct packet_diag_msg *rp;
@@ -147,6 +149,11 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct packet_diag
147 pdiag_put_info(po, skb)) 149 pdiag_put_info(po, skb))
148 goto out_nlmsg_trim; 150 goto out_nlmsg_trim;
149 151
152 if ((req->pdiag_show & PACKET_SHOW_INFO) &&
153 nla_put_u32(skb, PACKET_DIAG_UID,
154 from_kuid_munged(user_ns, sock_i_uid(sk))))
155 goto out_nlmsg_trim;
156
150 if ((req->pdiag_show & PACKET_SHOW_MCLIST) && 157 if ((req->pdiag_show & PACKET_SHOW_MCLIST) &&
151 pdiag_put_mclist(po, skb)) 158 pdiag_put_mclist(po, skb))
152 goto out_nlmsg_trim; 159 goto out_nlmsg_trim;
@@ -183,9 +190,11 @@ static int packet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
183 if (num < s_num) 190 if (num < s_num)
184 goto next; 191 goto next;
185 192
186 if (sk_diag_fill(sk, skb, req, NETLINK_CB(cb->skb).portid, 193 if (sk_diag_fill(sk, skb, req,
187 cb->nlh->nlmsg_seq, NLM_F_MULTI, 194 sk_user_ns(NETLINK_CB(cb->skb).sk),
188 sock_i_ino(sk)) < 0) 195 NETLINK_CB(cb->skb).portid,
196 cb->nlh->nlmsg_seq, NLM_F_MULTI,
197 sock_i_ino(sk)) < 0)
189 goto done; 198 goto done;
190next: 199next:
191 num++; 200 num++;