From: ebiederm@xmission•com (Eric W. Biederman)
To: Ben Hutchings <bhutchings@solarflare•com>
Cc: Nicolas Dichtel <nicolas.dichtel@6wind•com>,
<davem@davemloft•net>, <netdev@vger•kernel.org>,
<kaber@trash•net>
Subject: Re: [PATCH net-next] netlink: fix compilation after memory mapped patches
Date: Tue, 23 Apr 2013 09:55:49 -0700 [thread overview]
Message-ID: <877gjtuqy2.fsf@xmission.com> (raw)
In-Reply-To: <1366734263.4016.32.camel@bwh-desktop.uk.solarflarecom.com> (Ben Hutchings's message of "Tue, 23 Apr 2013 17:24:23 +0100")
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
next prev parent reply other threads:[~2013-04-23 16:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2013-04-24 8:36 ` [PATCH net-next v2] " Nicolas Dichtel
2013-04-24 18:27 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877gjtuqy2.fsf@xmission.com \
--to=ebiederm@xmission$(echo .)com \
--cc=bhutchings@solarflare$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=kaber@trash$(echo .)net \
--cc=netdev@vger$(echo .)kernel.org \
--cc=nicolas.dichtel@6wind$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox