Skip to content

Commit 01a16b2

Browse files
kaberdavem330
authored andcommitted
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 <[email protected]> Reviewed-by: James Morris <[email protected]> [chrisw: update to include pohmelfs and uvesafb] Signed-off-by: Chris Wright <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 63f9742 commit 01a16b2

File tree

7 files changed

+5
-13
lines changed

7 files changed

+5
-13
lines changed

drivers/block/drbd/drbd_nl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2177,7 +2177,7 @@ static void drbd_connector_callback(struct cn_msg *req, struct netlink_skb_parms
21772177
return;
21782178
}
21792179

2180-
if (!cap_raised(nsp->eff_cap, CAP_SYS_ADMIN)) {
2180+
if (!cap_raised(current_cap(), CAP_SYS_ADMIN)) {
21812181
retcode = ERR_PERM;
21822182
goto fail;
21832183
}

drivers/md/dm-log-userspace-transfer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static void cn_ulog_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp)
134134
{
135135
struct dm_ulog_request *tfr = (struct dm_ulog_request *)(msg + 1);
136136

137-
if (!cap_raised(nsp->eff_cap, CAP_SYS_ADMIN))
137+
if (!cap_raised(current_cap(), CAP_SYS_ADMIN))
138138
return;
139139

140140
spin_lock(&receiving_list_lock);

drivers/staging/pohmelfs/config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ static void pohmelfs_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *n
525525
{
526526
int err;
527527

528-
if (!cap_raised(nsp->eff_cap, CAP_SYS_ADMIN))
528+
if (!cap_raised(current_cap(), CAP_SYS_ADMIN))
529529
return;
530530

531531
switch (msg->flags) {

drivers/video/uvesafb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static void uvesafb_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *ns
7373
struct uvesafb_task *utask;
7474
struct uvesafb_ktask *task;
7575

76-
if (!cap_raised(nsp->eff_cap, CAP_SYS_ADMIN))
76+
if (!cap_raised(current_cap(), CAP_SYS_ADMIN))
7777
return;
7878

7979
if (msg->seq >= UVESAFB_TASKS_MAX)

include/linux/netlink.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ struct netlink_skb_parms {
160160
struct ucred creds; /* Skb credentials */
161161
__u32 pid;
162162
__u32 dst_group;
163-
kernel_cap_t eff_cap;
164163
};
165164

166165
#define NETLINK_CB(skb) (*(struct netlink_skb_parms*)&((skb)->cb))

net/netlink/af_netlink.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,12 +1364,6 @@ static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock,
13641364
NETLINK_CB(skb).dst_group = dst_group;
13651365
memcpy(NETLINK_CREDS(skb), &siocb->scm->creds, sizeof(struct ucred));
13661366

1367-
/* What can I do? Netlink is asynchronous, so that
1368-
we will have to save current capabilities to
1369-
check them, when this message will be delivered
1370-
to corresponding kernel module. --ANK (980802)
1371-
*/
1372-
13731367
err = -EFAULT;
13741368
if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) {
13751369
kfree_skb(skb);

security/commoncap.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,12 @@ static void warn_setuid_and_fcaps_mixed(const char *fname)
5252

5353
int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
5454
{
55-
NETLINK_CB(skb).eff_cap = current_cap();
5655
return 0;
5756
}
5857

5958
int cap_netlink_recv(struct sk_buff *skb, int cap)
6059
{
61-
if (!cap_raised(NETLINK_CB(skb).eff_cap, cap))
60+
if (!cap_raised(current_cap(), cap))
6261
return -EPERM;
6362
return 0;
6463
}

0 commit comments

Comments
 (0)