netlink: kill eff_cap from struct netlink_skb_parms
commit 8ff259625f0ab295fa085b0718eed13093813fbc
Author: Patrick McHardy <kaber@trash.net>
Date: Thu Mar 3 10:17:31 2011 +0100
netlink: kill eff_cap from struct netlink_skb_parms
Netlink message processing in the kernel is synchronous these days,
capabilities can be checked directly in security_netlink_recv() from
the current process.
- /* What can I do? Netlink is asynchronous, so that
- we will have to save current capabilities to
- check them, when this message will be delivered
- to corresponding kernel module. --ANK (980802)
- */
-
err = -EFAULT;
if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) {
kfree_skb(skb);
diff --git a/security/commoncap.c b/security/commoncap.c
index 64c2ed9..a83e607 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -52,13 +52,12 @@ static void warn_setuid_and_fcaps_mixed(const char *fname)
int cap_netlink_recv(struct sk_buff *skb, int cap)
{
- if (!cap_raised(NETLINK_CB(skb).eff_cap, cap))
+ if (!cap_raised(current_cap(), cap))
return -EPERM;
return 0;
}
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
03-03-2011, 04:32 PM
Chris Wright
netlink: kill eff_cap from struct netlink_skb_parms
* Patrick McHardy (kaber@trash.net) wrote:
> commit 8ff259625f0ab295fa085b0718eed13093813fbc
> Author: Patrick McHardy <kaber@trash.net>
> Date: Thu Mar 3 10:17:31 2011 +0100
>
> netlink: kill eff_cap from struct netlink_skb_parms
>
> Netlink message processing in the kernel is synchronous these days,
> capabilities can be checked directly in security_netlink_recv() from
> the current process.
>
> Signed-off-by: Patrick McHardy <kaber@trash.net>
Thanks for doing that Patrick. I looked at this earlier and thought
there was still an async path, but I guess that's just to another
userspace process.
BTW, I think you missed a couple connector based callers:
drivers/staging/pohmelfs/config.c: if (!cap_raised(nsp->eff_cap, CAP_SYS_AD
drivers/video/uvesafb.c: if (!cap_raised(nsp->eff_cap, CAP_SYS_ADMIN))
Fix those and:
Acked-by: Chris Wright <chrisw@sous-sol.org>
Ideally, we'd consolidate those into a variant of security_netlink_recv().
However the issue is with types. Inside connector callback we only have
netlink_skb_params (seems inapproriate to cast back out to skb).
We could change the lsm hook to only pass nsp, but SELinux actually
cares about the netlink type. Any ideas?
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
03-03-2011, 05:56 PM
David Miller
netlink: kill eff_cap from struct netlink_skb_parms
From: Chris Wright <chrisw@sous-sol.org>
Date: Thu, 3 Mar 2011 09:32:30 -0800
> * Patrick McHardy (kaber@trash.net) wrote:
>
>> commit 8ff259625f0ab295fa085b0718eed13093813fbc
>> Author: Patrick McHardy <kaber@trash.net>
>> Date: Thu Mar 3 10:17:31 2011 +0100
>>
>> netlink: kill eff_cap from struct netlink_skb_parms
>>
>> Netlink message processing in the kernel is synchronous these days,
>> capabilities can be checked directly in security_netlink_recv() from
>> the current process.
>>
>> Signed-off-by: Patrick McHardy <kaber@trash.net>
>
> Thanks for doing that Patrick. I looked at this earlier and thought
> there was still an async path, but I guess that's just to another
> userspace process.
>
> BTW, I think you missed a couple connector based callers:
>
> drivers/staging/pohmelfs/config.c: if (!cap_raised(nsp->eff_cap, CAP_SYS_AD
> drivers/video/uvesafb.c: if (!cap_raised(nsp->eff_cap, CAP_SYS_ADMIN))
>
> Fix those and:
>
> Acked-by: Chris Wright <chrisw@sous-sol.org>
Patrick, I'll apply your first patch, please respin this second patch with
the changes mentioned here.
Thanks!
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
03-03-2011, 07:15 PM
Chris Wright
netlink: kill eff_cap from struct netlink_skb_parms
* David Miller (davem@davemloft.net) wrote:
> From: Chris Wright <chrisw@sous-sol.org>
> Date: Thu, 3 Mar 2011 09:32:30 -0800
>
> > * Patrick McHardy (kaber@trash.net) wrote:
> >
> >> commit 8ff259625f0ab295fa085b0718eed13093813fbc
> >> Author: Patrick McHardy <kaber@trash.net>
> >> Date: Thu Mar 3 10:17:31 2011 +0100
> >>
> >> netlink: kill eff_cap from struct netlink_skb_parms
> >>
> >> Netlink message processing in the kernel is synchronous these days,
> >> capabilities can be checked directly in security_netlink_recv() from
> >> the current process.
> >>
> >> Signed-off-by: Patrick McHardy <kaber@trash.net>
> >
> > Thanks for doing that Patrick. I looked at this earlier and thought
> > there was still an async path, but I guess that's just to another
> > userspace process.
> >
> > BTW, I think you missed a couple connector based callers:
> >
> > drivers/staging/pohmelfs/config.c: if (!cap_raised(nsp->eff_cap, CAP_SYS_AD
> > drivers/video/uvesafb.c: if (!cap_raised(nsp->eff_cap, CAP_SYS_ADMIN))
> >
> > Fix those and:
> >
> > Acked-by: Chris Wright <chrisw@sous-sol.org>
>
> Patrick, I'll apply your first patch, please respin this second patch with
> the changes mentioned here.
Here, I respun it so I could work on top of it
thanks,
-chris
---
From: Patrick McHardy <kaber@trash.net>
Subject: [PATCH 2/2 v2] netlink: kill eff_cap from struct netlink_skb_parms
Netlink message processing in the kernel is synchronous these days,
capabilities can be checked directly in security_netlink_recv() from
the current process.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Reviewed-by: James Morris <jmorris@namei.org>
[chrisw: update to include pohmelfs and uvesafb]
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
---
- /* What can I do? Netlink is asynchronous, so that
- we will have to save current capabilities to
- check them, when this message will be delivered
- to corresponding kernel module. --ANK (980802)
- */
-
err = -EFAULT;
if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) {
kfree_skb(skb);
diff --git a/security/commoncap.c b/security/commoncap.c
index 64c2ed9..a83e607 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -52,13 +52,12 @@ static void warn_setuid_and_fcaps_mixed(const char *fname)
int cap_netlink_recv(struct sk_buff *skb, int cap)
{
- if (!cap_raised(NETLINK_CB(skb).eff_cap, cap))
+ if (!cap_raised(current_cap(), cap))
return -EPERM;
return 0;
}
--
1.7.1
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
03-03-2011, 07:17 PM
Chris Wright
netlink: kill eff_cap from struct netlink_skb_parms
* Chris Wright (chrisw@sous-sol.org) wrote:
> Ideally, we'd consolidate those into a variant of security_netlink_recv().
> However the issue is with types. Inside connector callback we only have
> netlink_skb_params (seems inapproriate to cast back out to skb).
>
> We could change the lsm hook to only pass nsp, but SELinux actually
> cares about the netlink type. Any ideas?
Actually I misremembered, it only cares on the send path.
We could completely drop skb from recv lsm hook, will send an RFC
momentarily with example.
thanks,
-chris
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel