security: update security_netlink_recv hook prototype
Subsystems (14)
We no longer need the skb in security_netlink_recv hook because the netlink kernel receive path is synchronous. There is no need to inspect the netlink_skb_params. Eliminating this makes it easy to reuse the security_netlink_recv hook in connector callbacks.
Signed-off-by Chris Wright <[email protected]>
--- drivers/scsi/scsi_netlink.c | 2 +- include/linux/security.h | 14 ++++++-------- kernel/audit.c | 4 ++-- net/core/rtnetlink.c | 2 +- net/decnet/netfilter/dn_rtmsg.c | 2 +- net/ipv4/netfilter/ip_queue.c | 2 +- net/ipv6/netfilter/ip6_queue.c | 2 +- net/netfilter/nfnetlink.c | 2 +- net/netlink/genetlink.c | 2 +- net/xfrm/xfrm_user.c | 2 +- security/commoncap.c | 2 +- security/security.c | 4 ++-- security/selinux/hooks.c | 4 ++-- 13 files changed, 21 insertions(+), 23 deletions(-)
drivers/scsi/scsi_netlink.c +1 -1
@@ -111,7 +111,7 @@ scsi_nl_rcv_msg(struct sk_buff *skb) goto next_msg; } -if (security_netlink_recv (skb,CAP_SYS_ADMIN )) { +if (security_netlink_recv (CAP_SYS_ADMIN )) { err = -EPERM ; goto next_msg; }
include/linux/security.h +6 -8
@@ -93,7 +93,7 @@ struct xfrm_user_sec_ctx;struct seq_file ;extern int cap_netlink_send (struct sock *sk,struct sk_buff *skb); -extern int cap_netlink_recv (struct sk_buff *skb,int cap); +extern int cap_netlink_recv (int cap);void reset_security_ops (void );
@@ -784,9 +784,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)* Return 0 if the information was successfully saved and message * is allowed to be transmitted. * @netlink_recv: -* Check permission before processing the received netlink message in -* @skb. -* @skb contains the sk_buff structure for the netlink message. +* Check permission before processing a received netlink message. * @cap indicates the capability required * Return 0 if permission is granted. *
@@ -1552,7 +1550,7 @@ struct security_operations { struct sembuf *sops, unsigned nsops, int alter);int (*netlink_send) (struct sock *sk,struct sk_buff *skb); -int (*netlink_recv) (struct sk_buff *skb,int cap); +int (*netlink_recv) (int cap);void (*d_instantiate) (struct dentry *dentry,struct inode *inode);
@@ -1798,7 +1796,7 @@ void security_d_instantiate(struct dentry *dentry, struct inode *inode);int security_getprocattr (struct task_struct *p,char *name,char **value);int security_setprocattr (struct task_struct *p,char *name,void *value,size_t size);int security_netlink_send (struct sock *sk,struct sk_buff *skb); -int security_netlink_recv (struct sk_buff *skb,int cap); +int security_netlink_recv (int cap);int security_secid_to_secctx (u32 secid,char **secdata,u32 *seclen);int security_secctx_to_secid (const char *secdata,u32 seclen,u32 *secid);void security_release_secctx (char *secdata,u32 seclen);
@@ -2493,9 +2491,9 @@ static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)return cap_netlink_send (sk, skb); } -static inline int security_netlink_recv (struct sk_buff *skb,int cap) +static inline int security_netlink_recv (int cap) { -return cap_netlink_recv (skb, cap); +return cap_netlink_recv (cap); }static inline int security_secid_to_secctx (u32 secid,char **secdata,u32 *seclen)
kernel/audit.c +2 -2
@@ -596,13 +596,13 @@ static int audit_netlink_ok(struct sk_buff *skb, u16 msg_type)case AUDIT_TTY_SET :case AUDIT_TRIM :case AUDIT_MAKE_EQUIV : -if (security_netlink_recv (skb,CAP_AUDIT_CONTROL )) +if (security_netlink_recv (CAP_AUDIT_CONTROL )) err = -EPERM ;break ;case AUDIT_USER : case AUDIT_FIRST_USER_MSG ... AUDIT_LAST_USER_MSG: case AUDIT_FIRST_USER_MSG2 ... AUDIT_LAST_USER_MSG2: -if (security_netlink_recv (skb,CAP_AUDIT_WRITE )) +if (security_netlink_recv (CAP_AUDIT_WRITE )) err = -EPERM ;break ;default :/* bad msg */
net/core/rtnetlink.c +1 -1
@@ -1819,7 +1819,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) sz_idx = type>>2 ; kind = type&3 ; -if (kind !=2 &&security_netlink_recv (skb,CAP_NET_ADMIN )) +if (kind !=2 &&security_netlink_recv (CAP_NET_ADMIN ))return -EPERM ;if (kind ==2 && nlh->nlmsg_flags&NLM_F_DUMP ) {
net/decnet/netfilter/dn_rtmsg.c +1 -1
@@ -108,7 +108,7 @@ static inline void dnrmg_receive_user_skb(struct sk_buff *skb)if (nlh->nlmsg_len <sizeof (*nlh) || skb->len < nlh->nlmsg_len)return ; -if (security_netlink_recv (skb,CAP_NET_ADMIN )) +if (security_netlink_recv (CAP_NET_ADMIN ))RCV_SKB_FAIL (-EPERM );/* Eventually we might send routing messages too */
net/ipv4/netfilter/ip_queue.c +1 -1
@@ -430,7 +430,7 @@ __ipq_rcv_skb(struct sk_buff *skb)if (type <=IPQM_BASE )return ; -if (security_netlink_recv (skb,CAP_NET_ADMIN )) +if (security_netlink_recv (CAP_NET_ADMIN ))RCV_SKB_FAIL (-EPERM );spin_lock_bh (&queue_lock);
net/ipv6/netfilter/ip6_queue.c +1 -1
@@ -431,7 +431,7 @@ __ipq_rcv_skb(struct sk_buff *skb)if (type <=IPQM_BASE )return ; -if (security_netlink_recv (skb,CAP_NET_ADMIN )) +if (security_netlink_recv (CAP_NET_ADMIN ))RCV_SKB_FAIL (-EPERM );spin_lock_bh (&queue_lock);
net/netfilter/nfnetlink.c +1 -1
@@ -130,7 +130,7 @@ static int nfnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)const struct nfnetlink_subsystem *ss;int type, err; -if (security_netlink_recv (skb,CAP_NET_ADMIN )) +if (security_netlink_recv (CAP_NET_ADMIN ))return -EPERM ;/* All the messages must at least contain nfgenmsg */
net/netlink/genetlink.c +1 -1
@@ -516,7 +516,7 @@ static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)return -EOPNOTSUPP ;if ((ops->flags &GENL_ADMIN_PERM ) && -security_netlink_recv (skb,CAP_NET_ADMIN )) +security_netlink_recv (CAP_NET_ADMIN ))return -EPERM ;if (nlh->nlmsg_flags &NLM_F_DUMP ) {
net/xfrm/xfrm_user.c +1 -1
@@ -2192,7 +2192,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) link = &xfrm_dispatch[type];/* All operations require privileges, even GET */ -if (security_netlink_recv (skb,CAP_NET_ADMIN )) +if (security_netlink_recv (CAP_NET_ADMIN ))return -EPERM ; if ((type == (XFRM_MSG_GETSA - XFRM_MSG_BASE) ||
security/commoncap.c +1 -1
@@ -55,7 +55,7 @@ int cap_netlink_send(struct sock *sk, struct sk_buff *skb)return 0 ; } -int cap_netlink_recv (struct sk_buff *skb,int cap) +int cap_netlink_recv (int cap) {if (!cap_raised (current_cap (), cap))return -EPERM ;
security/security.c +2 -2
@@ -941,9 +941,9 @@ int security_netlink_send(struct sock *sk, struct sk_buff *skb)return security_ops->netlink_send (sk, skb); } -int security_netlink_recv (struct sk_buff *skb,int cap) +int security_netlink_recv (int cap) { -return security_ops->netlink_recv (skb, cap); +return security_ops->netlink_recv (cap); }EXPORT_SYMBOL (security_netlink_recv);
security/selinux/hooks.c +2 -2
@@ -4665,13 +4665,13 @@ static int selinux_netlink_send(struct sock *sk, struct sk_buff *skb)return selinux_nlmsg_perm (sk, skb); } -static int selinux_netlink_recv (struct sk_buff *skb,int capability) +static int selinux_netlink_recv (int capability) {int err;struct common_audit_data ad;u32 sid; - err =cap_netlink_recv (skb, capability); + err =cap_netlink_recv (capability);if (err)return err;
Signature · 1 line
1.7.1
[RFC PATCH 4/2] connector: update callbacks to use security_netlink_recv()
This moves callbacks from a raw capabiliity hook to the generic lsm hook when receiving request from userspace.
Signed-off-by Chris Wright <[email protected]>
--- drivers/block/drbd/drbd_nl.c | 2 +- drivers/md/dm-log-userspace-transfer.c | 2 +- drivers/staging/pohmelfs/config.c | 2 +- drivers/video/uvesafb.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/block/drbd/drbd_nl.c +1 -1
@@ -2177,7 +2177,7 @@ static void drbd_connector_callback(struct cn_msg *req, struct netlink_skb_parmsreturn ; } -if (!cap_raised (current_cap (),CAP_SYS_ADMIN )) { +if (security_netlink_recv (CAP_SYS_ADMIN )) { retcode =ERR_PERM ; goto fail; }
drivers/md/dm-log-userspace-transfer.c +1 -1
@@ -134,7 +134,7 @@ static void cn_ulog_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp) {struct dm_ulog_request *tfr = (struct dm_ulog_request *)(msg +1 ); -if (!cap_raised (current_cap (),CAP_SYS_ADMIN )) +if (security_netlink_recv (CAP_SYS_ADMIN ))return ;spin_lock (&receiving_list_lock);
drivers/staging/pohmelfs/config.c +1 -1
@@ -525,7 +525,7 @@ static void pohmelfs_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *n {int err; -if (!cap_raised (current_cap (),CAP_SYS_ADMIN )) +if (security_netlink_recv (CAP_SYS_ADMIN ))return ;switch (msg->flags) {
drivers/video/uvesafb.c +1 -1
@@ -73,7 +73,7 @@ static void uvesafb_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *nsstruct uvesafb_task *utask;struct uvesafb_ktask *task; -if (!cap_raised (current_cap (),CAP_SYS_ADMIN )) +if (security_netlink_recv (CAP_SYS_ADMIN ))return ;if (msg->seq >=UVESAFB_TASKS_MAX )
Signature · 1 line
1.7.1