netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] netlink: fix compilation after memory mapped patches
@ 2013-04-23  8:55 Nicolas Dichtel
  2013-04-23 16:24 ` Ben Hutchings
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Dichtel @ 2013-04-23  8:55 UTC (permalink / raw)
  To: davem; +Cc: netdev, kaber, Nicolas Dichtel

Depending of the kernel configuration (CONFIG_UIDGID_STRICT_TYPE_CHECKS), we can
get the following errors:

net/netlink/af_netlink.c: In function ‘netlink_queue_mmaped_skb’:
net/netlink/af_netlink.c:663:14: error: incompatible types when assigning to type ‘__u32’ from type ‘kuid_t’
net/netlink/af_netlink.c:664:14: error: incompatible types when assigning to type ‘__u32’ from type ‘kgid_t’
net/netlink/af_netlink.c: In function ‘netlink_ring_set_copied’:
net/netlink/af_netlink.c:693:14: error: incompatible types when assigning to type ‘__u32’ from type ‘kuid_t’
net/netlink/af_netlink.c:694:14: error: incompatible types when assigning to type ‘__u32’ from type ‘kgid_t’

We must use the helpers to get the uid and gid.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 net/netlink/af_netlink.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 2a3e9ba..0593a9a 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -660,8 +660,8 @@ static void netlink_queue_mmaped_skb(struct sock *sk, struct sk_buff *skb)
 	hdr->nm_len	= skb->len;
 	hdr->nm_group	= NETLINK_CB(skb).dst_group;
 	hdr->nm_pid	= NETLINK_CB(skb).creds.pid;
-	hdr->nm_uid	= NETLINK_CB(skb).creds.uid;
-	hdr->nm_gid	= NETLINK_CB(skb).creds.gid;
+	hdr->nm_uid	= __kuid_val(NETLINK_CB(skb).creds.uid);
+	hdr->nm_gid	= __kgid_val(NETLINK_CB(skb).creds.gid);
 	netlink_frame_flush_dcache(hdr);
 	netlink_set_status(hdr, NL_MMAP_STATUS_VALID);
 
@@ -690,8 +690,8 @@ static void netlink_ring_set_copied(struct sock *sk, struct sk_buff *skb)
 	hdr->nm_len	= skb->len;
 	hdr->nm_group	= NETLINK_CB(skb).dst_group;
 	hdr->nm_pid	= NETLINK_CB(skb).creds.pid;
-	hdr->nm_uid	= NETLINK_CB(skb).creds.uid;
-	hdr->nm_gid	= NETLINK_CB(skb).creds.gid;
+	hdr->nm_uid	= __kuid_val(NETLINK_CB(skb).creds.uid);
+	hdr->nm_gid	= __kgid_val(NETLINK_CB(skb).creds.gid);
 	netlink_set_status(hdr, NL_MMAP_STATUS_COPY);
 }
 
-- 
1.8.2.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] netlink: fix compilation after memory mapped patches
  2013-04-23  8:55 [PATCH net-next] netlink: fix compilation after memory mapped patches Nicolas Dichtel
@ 2013-04-23 16:24 ` Ben Hutchings
  2013-04-23 16:55   ` Eric W. Biederman
  0 siblings, 1 reply; 5+ messages in thread
From: Ben Hutchings @ 2013-04-23 16:24 UTC (permalink / raw)
  To: Nicolas Dichtel; +Cc: davem, netdev, kaber, Eric W. Biederman

On Tue, 2013-04-23 at 10:55 +0200, Nicolas Dichtel wrote:
> Depending of the kernel configuration (CONFIG_UIDGID_STRICT_TYPE_CHECKS), we can
> get the following errors:
> 
> net/netlink/af_netlink.c: In function ‘netlink_queue_mmaped_skb’:
> net/netlink/af_netlink.c:663:14: error: incompatible types when assigning to type ‘__u32’ from type ‘kuid_t’
> net/netlink/af_netlink.c:664:14: error: incompatible types when assigning to type ‘__u32’ from type ‘kgid_t’
> net/netlink/af_netlink.c: In function ‘netlink_ring_set_copied’:
> net/netlink/af_netlink.c:693:14: error: incompatible types when assigning to type ‘__u32’ from type ‘kuid_t’
> net/netlink/af_netlink.c:694:14: error: incompatible types when assigning to type ‘__u32’ from type ‘kgid_t’
> 
> We must use the helpers to get the uid and gid.
>
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> ---
>  net/netlink/af_netlink.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
> index 2a3e9ba..0593a9a 100644
> --- a/net/netlink/af_netlink.c
> +++ b/net/netlink/af_netlink.c
> @@ -660,8 +660,8 @@ static void netlink_queue_mmaped_skb(struct sock *sk, struct sk_buff *skb)
>  	hdr->nm_len	= skb->len;
>  	hdr->nm_group	= NETLINK_CB(skb).dst_group;
>  	hdr->nm_pid	= NETLINK_CB(skb).creds.pid;
> -	hdr->nm_uid	= NETLINK_CB(skb).creds.uid;
> -	hdr->nm_gid	= NETLINK_CB(skb).creds.gid;
> +	hdr->nm_uid	= __kuid_val(NETLINK_CB(skb).creds.uid);
> +	hdr->nm_gid	= __kgid_val(NETLINK_CB(skb).creds.gid);

Shouldn't these use from_k{u,g}id_munged() like scm_recv() does?

Ben.

>  	netlink_frame_flush_dcache(hdr);
>  	netlink_set_status(hdr, NL_MMAP_STATUS_VALID);
>  
> @@ -690,8 +690,8 @@ static void netlink_ring_set_copied(struct sock *sk, struct sk_buff *skb)
>  	hdr->nm_len	= skb->len;
>  	hdr->nm_group	= NETLINK_CB(skb).dst_group;
>  	hdr->nm_pid	= NETLINK_CB(skb).creds.pid;
> -	hdr->nm_uid	= NETLINK_CB(skb).creds.uid;
> -	hdr->nm_gid	= NETLINK_CB(skb).creds.gid;
> +	hdr->nm_uid	= __kuid_val(NETLINK_CB(skb).creds.uid);
> +	hdr->nm_gid	= __kgid_val(NETLINK_CB(skb).creds.gid);
>  	netlink_set_status(hdr, NL_MMAP_STATUS_COPY);
>  }
>  

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] netlink: fix compilation after memory mapped patches
  2013-04-23 16:24 ` Ben Hutchings
@ 2013-04-23 16:55   ` Eric W. Biederman
  2013-04-24  8:36     ` [PATCH net-next v2] " Nicolas Dichtel
  0 siblings, 1 reply; 5+ messages in thread
From: Eric W. Biederman @ 2013-04-23 16:55 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: Nicolas Dichtel, davem, netdev, kaber

Ben Hutchings <bhutchings@solarflare.com> writes:

> On Tue, 2013-04-23 at 10:55 +0200, Nicolas Dichtel wrote:
>> Depending of the kernel configuration (CONFIG_UIDGID_STRICT_TYPE_CHECKS), we can
>> get the following errors:
>> 
>> net/netlink/af_netlink.c: In function ‘netlink_queue_mmaped_skb’:
>> net/netlink/af_netlink.c:663:14: error: incompatible types when assigning to type ‘__u32’ from type ‘kuid_t’
>> net/netlink/af_netlink.c:664:14: error: incompatible types when assigning to type ‘__u32’ from type ‘kgid_t’
>> net/netlink/af_netlink.c: In function ‘netlink_ring_set_copied’:
>> net/netlink/af_netlink.c:693:14: error: incompatible types when assigning to type ‘__u32’ from type ‘kuid_t’
>> net/netlink/af_netlink.c:694:14: error: incompatible types when assigning to type ‘__u32’ from type ‘kgid_t’
>> 
>> We must use the helpers to get the uid and gid.
>>
>> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
>> ---
>>  net/netlink/af_netlink.c | 8 ++++----
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>> 
>> diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
>> index 2a3e9ba..0593a9a 100644
>> --- a/net/netlink/af_netlink.c
>> +++ b/net/netlink/af_netlink.c
>> @@ -660,8 +660,8 @@ static void netlink_queue_mmaped_skb(struct sock *sk, struct sk_buff *skb)
>>  	hdr->nm_len	= skb->len;
>>  	hdr->nm_group	= NETLINK_CB(skb).dst_group;
>>  	hdr->nm_pid	= NETLINK_CB(skb).creds.pid;
>> -	hdr->nm_uid	= NETLINK_CB(skb).creds.uid;
>> -	hdr->nm_gid	= NETLINK_CB(skb).creds.gid;
>> +	hdr->nm_uid	= __kuid_val(NETLINK_CB(skb).creds.uid);
>> +	hdr->nm_gid	= __kgid_val(NETLINK_CB(skb).creds.gid);
>
> Shouldn't these use from_k{u,g}id_munged() like scm_recv() does?

Most definitely.

__kuid_val and __kgid_val are implementation details you probably don't
want to be messing with.

So I think what the code wants to say is:
hdr->nm_uid = from_kuid(sk_user_ns(sk), NETLINK_CB(skb).creds.uid);
hdr->nm_gid = from_kgid(sk_user_ns(sk), NETLINK_CB(skb).creds.gid);

A rather frustrated part of me wonders if anyone uses netlink sockets
between userspace processes.  If not we could just make all of this
credential passing go away.

And there is something more that should be done with pids but netlink
is so twisty I haven't figured out how to make netlink sockets properly
pass pids between pid namespaces.

Eric

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net-next v2] netlink: fix compilation after memory mapped patches
  2013-04-23 16:55   ` Eric W. Biederman
@ 2013-04-24  8:36     ` Nicolas Dichtel
  2013-04-24 18:27       ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Dichtel @ 2013-04-24  8:36 UTC (permalink / raw)
  To: ebiederm; +Cc: netdev, davem, kaber, bhutchings, Nicolas Dichtel

Depending of the kernel configuration (CONFIG_UIDGID_STRICT_TYPE_CHECKS), we can
get the following errors:

net/netlink/af_netlink.c: In function ‘netlink_queue_mmaped_skb’:
net/netlink/af_netlink.c:663:14: error: incompatible types when assigning to type ‘__u32’ from type ‘kuid_t’
net/netlink/af_netlink.c:664:14: error: incompatible types when assigning to type ‘__u32’ from type ‘kgid_t’
net/netlink/af_netlink.c: In function ‘netlink_ring_set_copied’:
net/netlink/af_netlink.c:693:14: error: incompatible types when assigning to type ‘__u32’ from type ‘kuid_t’
net/netlink/af_netlink.c:694:14: error: incompatible types when assigning to type ‘__u32’ from type ‘kgid_t’

We must use the helpers to get the uid and gid, and also take care of user_ns.

Fix suggested by Eric W. Biederman <ebiederm@xmission.com>.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---

v2: use from_k{p,g}ui() functions to get the right {p,g}ui

 net/netlink/af_netlink.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index da5601d..d9c7869 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -660,8 +660,8 @@ static void netlink_queue_mmaped_skb(struct sock *sk, struct sk_buff *skb)
 	hdr->nm_len	= skb->len;
 	hdr->nm_group	= NETLINK_CB(skb).dst_group;
 	hdr->nm_pid	= NETLINK_CB(skb).creds.pid;
-	hdr->nm_uid	= NETLINK_CB(skb).creds.uid;
-	hdr->nm_gid	= NETLINK_CB(skb).creds.gid;
+	hdr->nm_uid	= from_kuid(sk_user_ns(sk), NETLINK_CB(skb).creds.uid);
+	hdr->nm_gid	= from_kgid(sk_user_ns(sk), NETLINK_CB(skb).creds.gid);
 	netlink_frame_flush_dcache(hdr);
 	netlink_set_status(hdr, NL_MMAP_STATUS_VALID);
 
@@ -690,8 +690,8 @@ static void netlink_ring_set_copied(struct sock *sk, struct sk_buff *skb)
 	hdr->nm_len	= skb->len;
 	hdr->nm_group	= NETLINK_CB(skb).dst_group;
 	hdr->nm_pid	= NETLINK_CB(skb).creds.pid;
-	hdr->nm_uid	= NETLINK_CB(skb).creds.uid;
-	hdr->nm_gid	= NETLINK_CB(skb).creds.gid;
+	hdr->nm_uid	= from_kuid(sk_user_ns(sk), NETLINK_CB(skb).creds.uid);
+	hdr->nm_gid	= from_kgid(sk_user_ns(sk), NETLINK_CB(skb).creds.gid);
 	netlink_set_status(hdr, NL_MMAP_STATUS_COPY);
 }
 
-- 
1.8.2.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next v2] netlink: fix compilation after memory mapped patches
  2013-04-24  8:36     ` [PATCH net-next v2] " Nicolas Dichtel
@ 2013-04-24 18:27       ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2013-04-24 18:27 UTC (permalink / raw)
  To: nicolas.dichtel; +Cc: ebiederm, netdev, kaber, bhutchings

From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Date: Wed, 24 Apr 2013 10:36:23 +0200

> Depending of the kernel configuration (CONFIG_UIDGID_STRICT_TYPE_CHECKS), we can
> get the following errors:
> 
> net/netlink/af_netlink.c: In function ‘netlink_queue_mmaped_skb’:
> net/netlink/af_netlink.c:663:14: error: incompatible types when assigning to type ‘__u32’ from type ‘kuid_t’
> net/netlink/af_netlink.c:664:14: error: incompatible types when assigning to type ‘__u32’ from type ‘kgid_t’
> net/netlink/af_netlink.c: In function ‘netlink_ring_set_copied’:
> net/netlink/af_netlink.c:693:14: error: incompatible types when assigning to type ‘__u32’ from type ‘kuid_t’
> net/netlink/af_netlink.c:694:14: error: incompatible types when assigning to type ‘__u32’ from type ‘kgid_t’
> 
> We must use the helpers to get the uid and gid, and also take care of user_ns.
> 
> Fix suggested by Eric W. Biederman <ebiederm@xmission.com>.
> 
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

Applied, thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-04-24 18:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-23  8:55 [PATCH net-next] netlink: fix compilation after memory mapped patches Nicolas Dichtel
2013-04-23 16:24 ` Ben Hutchings
2013-04-23 16:55   ` Eric W. Biederman
2013-04-24  8:36     ` [PATCH net-next v2] " Nicolas Dichtel
2013-04-24 18:27       ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).