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