@@ -113,14 +113,16 @@ static int sk_diag_show_rqlen(struct sock *sk, struct sk_buff *nlskb)
113
113
return nla_put (nlskb , UNIX_DIAG_RQLEN , sizeof (rql ), & rql );
114
114
}
115
115
116
- static int sk_diag_dump_uid (struct sock * sk , struct sk_buff * nlskb )
116
+ static int sk_diag_dump_uid (struct sock * sk , struct sk_buff * nlskb ,
117
+ struct user_namespace * user_ns )
117
118
{
118
- uid_t uid = from_kuid_munged (sk_user_ns ( nlskb -> sk ) , sock_i_uid (sk ));
119
+ uid_t uid = from_kuid_munged (user_ns , sock_i_uid (sk ));
119
120
return nla_put (nlskb , UNIX_DIAG_UID , sizeof (uid_t ), & uid );
120
121
}
121
122
122
123
static int sk_diag_fill (struct sock * sk , struct sk_buff * skb , struct unix_diag_req * req ,
123
- u32 portid , u32 seq , u32 flags , int sk_ino )
124
+ struct user_namespace * user_ns ,
125
+ u32 portid , u32 seq , u32 flags , int sk_ino )
124
126
{
125
127
struct nlmsghdr * nlh ;
126
128
struct unix_diag_msg * rep ;
@@ -166,7 +168,7 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_r
166
168
goto out_nlmsg_trim ;
167
169
168
170
if ((req -> udiag_show & UDIAG_SHOW_UID ) &&
169
- sk_diag_dump_uid (sk , skb ))
171
+ sk_diag_dump_uid (sk , skb , user_ns ))
170
172
goto out_nlmsg_trim ;
171
173
172
174
nlmsg_end (skb , nlh );
@@ -178,7 +180,8 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_r
178
180
}
179
181
180
182
static int sk_diag_dump (struct sock * sk , struct sk_buff * skb , struct unix_diag_req * req ,
181
- u32 portid , u32 seq , u32 flags )
183
+ struct user_namespace * user_ns ,
184
+ u32 portid , u32 seq , u32 flags )
182
185
{
183
186
int sk_ino ;
184
187
@@ -189,7 +192,7 @@ static int sk_diag_dump(struct sock *sk, struct sk_buff *skb, struct unix_diag_r
189
192
if (!sk_ino )
190
193
return 0 ;
191
194
192
- return sk_diag_fill (sk , skb , req , portid , seq , flags , sk_ino );
195
+ return sk_diag_fill (sk , skb , req , user_ns , portid , seq , flags , sk_ino );
193
196
}
194
197
195
198
static int unix_diag_dump (struct sk_buff * skb , struct netlink_callback * cb )
@@ -217,7 +220,7 @@ static int unix_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
217
220
goto next ;
218
221
if (!(req -> udiag_states & (1 << sk -> sk_state )))
219
222
goto next ;
220
- if (sk_diag_dump (sk , skb , req ,
223
+ if (sk_diag_dump (sk , skb , req , sk_user_ns ( skb -> sk ),
221
224
NETLINK_CB (cb -> skb ).portid ,
222
225
cb -> nlh -> nlmsg_seq ,
223
226
NLM_F_MULTI ) < 0 )
@@ -285,7 +288,8 @@ static int unix_diag_get_exact(struct sk_buff *in_skb,
285
288
if (!rep )
286
289
goto out ;
287
290
288
- err = sk_diag_fill (sk , rep , req , NETLINK_CB (in_skb ).portid ,
291
+ err = sk_diag_fill (sk , rep , req , sk_user_ns (NETLINK_CB (in_skb ).sk ),
292
+ NETLINK_CB (in_skb ).portid ,
289
293
nlh -> nlmsg_seq , 0 , req -> udiag_ino );
290
294
if (err < 0 ) {
291
295
nlmsg_free (rep );
0 commit comments