net: drop capability from protocol definitions
Subsystems (20)
PATCH 1/3 net: drop capability from protocol definitions
struct can_proto had a capability field which wasn't ever used. It is dropped entirely.
struct inet_protosw had a capability field which can be more clearly expressed in the code by just checking if sock->type = SOCK_RAW.
---
include/linux/can/core.h | 2 -- include/net/protocol.h | 4 ---- net/can/af_can.c | 5 ----- net/can/bcm.c | 1 - net/can/raw.c | 1 - net/dccp/ipv4.c | 1 - net/dccp/ipv6.c | 1 - net/ipv4/af_inet.c | 5 +---- net/ipv4/udplite.c | 1 - net/ipv6/af_inet6.c | 2 +- net/ipv6/raw.c | 1 - net/ipv6/tcp_ipv6.c | 1 - net/ipv6/udp.c | 1 - net/ipv6/udplite.c | 1 - net/sctp/ipv6.c | 2 -- net/sctp/protocol.c | 2 -- 16 files changed, 2 insertions(+), 29 deletions(-)
include/linux/can/core.h +0 -2
@@ -32,14 +32,12 @@* struct can_proto - CAN protocol structure * @type: type argument in socket() syscall, e.g. SOCK_DGRAM. * @protocol: protocol number in socket() syscall. -* @capability: capability needed to open the socket, or -1 for no restriction. * @ops: pointer to struct proto_ops for sock->ops. * @prot: pointer to struct proto structure. */ struct can_proto {int type;int protocol; -int capability;struct proto_ops *ops;struct proto *prot; };
include/net/protocol.h +0 -4
@@ -83,10 +83,6 @@ struct inet_protosw {struct proto *prot;const struct proto_ops *ops; -int capability;/* Which (if any) capability do -* we need to use this socket -* interface? -*/ char no_check;/* checksum on rcv/xmit/none? */ unsigned char flags;/* See INET_PROTOSW_* below. */ };
net/can/af_can.c +0 -5
@@ -160,11 +160,6 @@ static int can_create(struct net *net, struct socket *sock, int protocol) goto errout; } -if (cp->capability >=0 && !capable (cp->capability)) { - err = -EPERM ; - goto errout; - } - sock->ops = cp->ops; sk =sk_alloc (net,PF_CAN ,GFP_KERNEL , cp->prot);
net/can/bcm.c +0 -1
@@ -1576,7 +1576,6 @@ static struct proto bcm_proto __read_mostly = {static struct can_proto bcm_can_proto__read_mostly = { .type =SOCK_DGRAM , .protocol =CAN_BCM , - .capability =-1 , .ops = &bcm_ops, .prot = &bcm_proto, };
net/can/raw.c +0 -1
@@ -742,7 +742,6 @@ static struct proto raw_proto __read_mostly = {static struct can_proto raw_can_proto__read_mostly = { .type =SOCK_RAW , .protocol =CAN_RAW , - .capability =-1 , .ops = &raw_ops, .prot = &raw_proto, };
net/dccp/ipv4.c +0 -1
@@ -991,7 +991,6 @@ static struct inet_protosw dccp_v4_protosw = { .protocol = IPPROTO_DCCP, .prot = &dccp_v4_prot, .ops = &inet_dccp_ops, - .capability = -1, .no_check = 0, .flags = INET_PROTOSW_ICSK, };
net/dccp/ipv6.c +0 -1
@@ -1185,7 +1185,6 @@ static struct inet_protosw dccp_v6_protosw = { .protocol = IPPROTO_DCCP, .prot = &dccp_v6_prot, .ops = &inet6_dccp_ops, - .capability = -1, .flags = INET_PROTOSW_ICSK, };
net/ipv4/af_inet.c +1 -4
@@ -325,7 +325,7 @@ lookup_protocol: } err = -EPERM ; -if (answer->capability >0 && !capable (answer->capability)) +if (sock->type ==SOCK_RAW && !capable (CAP_NET_RAW )) goto out_rcu_unlock; err = -EAFNOSUPPORT ;
@@ -947,7 +947,6 @@ static struct inet_protosw inetsw_array[] = .protocol = IPPROTO_TCP, .prot = &tcp_prot, .ops = &inet_stream_ops, - .capability = -1, .no_check = 0, .flags =INET_PROTOSW_PERMANENT | INET_PROTOSW_ICSK,
@@ -958,7 +957,6 @@ static struct inet_protosw inetsw_array[] = .protocol = IPPROTO_UDP, .prot = &udp_prot, .ops = &inet_dgram_ops, - .capability = -1, .no_check = UDP_CSUM_DEFAULT, .flags = INET_PROTOSW_PERMANENT, },
@@ -969,7 +967,6 @@ static struct inet_protosw inetsw_array[] = .protocol = IPPROTO_IP, /* wild card */ .prot = &raw_prot, .ops = &inet_sockraw_ops, - .capability = CAP_NET_RAW, .no_check = UDP_CSUM_DEFAULT, .flags = INET_PROTOSW_REUSE, }
net/ipv4/udplite.c +0 -1
@@ -64,7 +64,6 @@ static struct inet_protosw udplite4_protosw = { .protocol = IPPROTO_UDPLITE, .prot = &udplite_prot, .ops = &inet_dgram_ops, - .capability = -1, .no_check = 0, /* must checksum (RFC 3828) */ .flags = INET_PROTOSW_PERMANENT, };
net/ipv6/af_inet6.c +1 -1
@@ -158,7 +158,7 @@ lookup_protocol: } err = -EPERM ; -if (answer->capability >0 && !capable (answer->capability)) +if (sock->type ==SOCK_RAW && !capable (CAP_NET_RAW )) goto out_rcu_unlock; sock->ops = answer->ops;
net/ipv6/raw.c +0 -1
@@ -1336,7 +1336,6 @@ static struct inet_protosw rawv6_protosw = { .protocol = IPPROTO_IP, /* wild card */ .prot = &rawv6_prot, .ops = &inet6_sockraw_ops, - .capability = CAP_NET_RAW, .no_check = UDP_CSUM_DEFAULT, .flags = INET_PROTOSW_REUSE, };
net/ipv6/tcp_ipv6.c +0 -1
@@ -2112,7 +2112,6 @@ static struct inet_protosw tcpv6_protosw = { .protocol = IPPROTO_TCP, .prot = &tcpv6_prot, .ops = &inet6_stream_ops, - .capability = -1, .no_check = 0, .flags =INET_PROTOSW_PERMANENT | INET_PROTOSW_ICSK,
net/ipv6/udp.c +0 -1
@@ -1284,7 +1284,6 @@ static struct inet_protosw udpv6_protosw = { .protocol = IPPROTO_UDP, .prot = &udpv6_prot, .ops = &inet6_dgram_ops, - .capability =-1, .no_check = UDP_CSUM_DEFAULT, .flags = INET_PROTOSW_PERMANENT, };
net/ipv6/udplite.c +0 -1
@@ -62,7 +62,6 @@ static struct inet_protosw udplite6_protosw = { .protocol = IPPROTO_UDPLITE, .prot = &udplitev6_prot, .ops = &inet6_dgram_ops, - .capability = -1, .no_check = 0, .flags = INET_PROTOSW_PERMANENT, };
net/sctp/ipv6.c +0 -2
@@ -930,7 +930,6 @@ static struct inet_protosw sctpv6_seqpacket_protosw = { .protocol = IPPROTO_SCTP, .prot = &sctpv6_prot, .ops = &inet6_seqpacket_ops, - .capability = -1, .no_check = 0, .flags = SCTP_PROTOSW_FLAG };
@@ -939,7 +938,6 @@ static struct inet_protosw sctpv6_stream_protosw = { .protocol = IPPROTO_SCTP, .prot = &sctpv6_prot, .ops = &inet6_seqpacket_ops, - .capability = -1, .no_check = 0, .flags = SCTP_PROTOSW_FLAG, };
net/sctp/protocol.c +0 -2
@@ -909,7 +909,6 @@ static struct inet_protosw sctp_seqpacket_protosw = { .protocol = IPPROTO_SCTP, .prot = &sctp_prot, .ops = &inet_seqpacket_ops, - .capability = -1, .no_check = 0, .flags = SCTP_PROTOSW_FLAG };
@@ -918,7 +917,6 @@ static struct inet_protosw sctp_stream_protosw = { .protocol = IPPROTO_SCTP, .prot = &sctp_prot, .ops = &inet_seqpacket_ops, - .capability = -1, .no_check = 0, .flags = SCTP_PROTOSW_FLAG };
PATCH 2/3 net: pass kern to net_proto_family create function
The generic __sock_create function has a kern argument which allows the security system to make decisions based on if a socket is being created by the kernel or by userspace. This patch passes that flag to the net_proto_family specific create function, so it can do the same thing.
---
drivers/isdn/mISDN/socket.c | 2 +- drivers/net/pppox.c | 3 ++- include/linux/net.h | 3 ++- net/appletalk/ddp.c | 3 ++- net/atm/pvc.c | 3 ++- net/atm/svc.c | 3 ++- net/ax25/af_ax25.c | 3 ++- net/bluetooth/af_bluetooth.c | 3 ++- net/bluetooth/bnep/sock.c | 3 ++- net/bluetooth/cmtp/sock.c | 3 ++- net/bluetooth/hci_sock.c | 3 ++- net/bluetooth/hidp/sock.c | 3 ++- net/bluetooth/l2cap.c | 3 ++- net/bluetooth/rfcomm/sock.c | 3 ++- net/bluetooth/sco.c | 3 ++- net/can/af_can.c | 3 ++- net/decnet/af_decnet.c | 3 ++- net/econet/af_econet.c | 3 ++- net/ieee802154/af_ieee802154.c | 2 +- net/ipv4/af_inet.c | 3 ++- net/ipv6/af_inet6.c | 3 ++- net/ipx/af_ipx.c | 3 ++- net/irda/af_irda.c | 3 ++- net/iucv/af_iucv.c | 3 ++- net/key/af_key.c | 3 ++- net/llc/af_llc.c | 5 ++++- net/netlink/af_netlink.c | 3 ++- net/netrom/af_netrom.c | 3 ++- net/packet/af_packet.c | 3 ++- net/phonet/af_phonet.c | 3 ++- net/rds/af_rds.c | 3 ++- net/rose/af_rose.c | 3 ++- net/rxrpc/af_rxrpc.c | 3 ++- net/socket.c | 2 +- net/tipc/socket.c | 4 +++- net/unix/af_unix.c | 3 ++- net/x25/af_x25.c | 3 ++- 37 files changed, 74 insertions(+), 37 deletions(-)
drivers/isdn/mISDN/socket.c +1 -1
@@ -779,7 +779,7 @@ base_sock_create(struct net *net, struct socket *sock, int protocol) }static int -mISDN_sock_create (struct net *net,struct socket *sock,int proto) +mISDN_sock_create (struct net *net,struct socket *sock,int proto,int kern) {int err = -EPROTONOSUPPORT ;
drivers/net/pppox.c +2 -1
@@ -104,7 +104,8 @@ int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)EXPORT_SYMBOL (pppox_ioctl); -static int pppox_create (struct net *net,struct socket *sock,int protocol) +static int pppox_create (struct net *net,struct socket *sock,int protocol, +int kern) {int rc = -EPROTOTYPE ;
include/linux/net.h +2 -1
@@ -204,7 +204,8 @@ struct proto_ops {struct net_proto_family {int family; -int (*create)(struct net *net,struct socket *sock,int protocol); +int (*create)(struct net *net,struct socket *sock, +int protocol,int kern);struct module *owner; };
net/appletalk/ddp.c +2 -1
@@ -1021,7 +1021,8 @@ static struct proto ddp_proto = {* Create a socket. Initialise the socket, blank the addresses * set the state. */ -static int atalk_create (struct net *net,struct socket *sock,int protocol) +static int atalk_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct sock *sk;int rc = -ESOCKTNOSUPPORT ;
net/atm/pvc.c +2 -1
@@ -127,7 +127,8 @@ static const struct proto_ops pvc_proto_ops = { }; -static int pvc_create (struct net *net,struct socket *sock,int protocol) +static int pvc_create (struct net *net,struct socket *sock,int protocol, +int kern) {if (net != &init_net)return -EAFNOSUPPORT ;
net/atm/svc.c +2 -1
@@ -650,7 +650,8 @@ static const struct proto_ops svc_proto_ops = { }; -static int svc_create (struct net *net,struct socket *sock,int protocol) +static int svc_create(struct net *net, struct socket *sock, int protocol + int kern) {int error;
net/ax25/af_ax25.c +2 -1
@@ -799,7 +799,8 @@ static struct proto ax25_proto = { .obj_size = sizeof(struct sock), }; -static int ax25_create (struct net *net,struct socket *sock,int protocol) +static int ax25_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct sock *sk;ax25_cb *ax25;
net/bluetooth/af_bluetooth.c +2 -1
@@ -126,7 +126,8 @@ int bt_sock_unregister(int proto) }EXPORT_SYMBOL (bt_sock_unregister); -static int bt_sock_create (struct net *net,struct socket *sock,int proto) +static int bt_sock_create (struct net *net,struct socket *sock,int proto, +int kern) {int err;
net/bluetooth/bnep/sock.c +2 -1
@@ -195,7 +195,8 @@ static struct proto bnep_proto = { .obj_size = sizeof(struct bt_sock) }; -static int bnep_sock_create (struct net *net,struct socket *sock,int protocol) +static int bnep_sock_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct sock *sk;
net/bluetooth/cmtp/sock.c +2 -1
@@ -190,7 +190,8 @@ static struct proto cmtp_proto = { .obj_size = sizeof(struct bt_sock) }; -static int cmtp_sock_create (struct net *net,struct socket *sock,int protocol) +static int cmtp_sock_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct sock *sk;
net/bluetooth/hci_sock.c +2 -1
@@ -621,7 +621,8 @@ static struct proto hci_sk_proto = { .obj_size = sizeof(struct hci_pinfo) }; -static int hci_sock_create (struct net *net,struct socket *sock,int protocol) +static int hci_sock_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct sock *sk;
net/bluetooth/hidp/sock.c +2 -1
@@ -241,7 +241,8 @@ static struct proto hidp_proto = { .obj_size = sizeof(struct bt_sock) }; -static int hidp_sock_create (struct net *net,struct socket *sock,int protocol) +static int hidp_sock_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct sock *sk;
net/bluetooth/l2cap.c +2 -1
@@ -819,7 +819,8 @@ static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int preturn sk; } -static int l2cap_sock_create (struct net *net,struct socket *sock,int protocol) +static int l2cap_sock_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct sock *sk;
net/bluetooth/rfcomm/sock.c +2 -1
@@ -323,7 +323,8 @@ static struct sock *rfcomm_sock_alloc(struct net *net, struct socket *sock, intreturn sk; } -static int rfcomm_sock_create (struct net *net,struct socket *sock,int protocol) +static int rfcomm_sock_create (struct net *net,struct socket *sock, +int protocol,int kern) {struct sock *sk;
net/bluetooth/sco.c +2 -1
@@ -430,7 +430,8 @@ static struct sock *sco_sock_alloc(struct net *net, struct socket *sock, int proreturn sk; } -static int sco_sock_create (struct net *net,struct socket *sock,int protocol) +static int sco_sock_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct sock *sk;
net/can/af_can.c +2 -1
@@ -114,7 +114,8 @@ static void can_sock_destruct(struct sock *sk)skb_queue_purge (&sk->sk_receive_queue); } -static int can_create (struct net *net,struct socket *sock,int protocol) +static int can_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct sock *sk;struct can_proto *cp;
net/decnet/af_decnet.c +2 -1
@@ -675,7 +675,8 @@ char *dn_addr2asc(__u16 addr, char *buf) -static int dn_create (struct net *net,struct socket *sock,int protocol) +static int dn_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct sock *sk;
net/econet/af_econet.c +2 -1
@@ -605,7 +605,8 @@ static struct proto econet_proto = {* Create an Econet socket */ -static int econet_create (struct net *net,struct socket *sock,int protocol) +static int econet_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct sock *sk;struct econet_sock *eo;
net/ieee802154/af_ieee802154.c +1 -1
@@ -234,7 +234,7 @@ static const struct proto_ops ieee802154_dgram_ops = {* set the state. */ static int ieee802154_create (struct net *net,struct socket *sock, -int protocol) +int protocol,int kern) {struct sock *sk;int rc;
net/ipv4/af_inet.c +2 -1
@@ -262,7 +262,8 @@ static inline int inet_netns_ok(struct net *net, int protocol)* Create an inet socket. */ -static int inet_create (struct net *net,struct socket *sock,int protocol) +static int inet_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct sock *sk;struct inet_protosw *answer;
net/ipv6/af_inet6.c +2 -1
@@ -95,7 +95,8 @@ static __inline__ struct ipv6_pinfo *inet6_sk_generic(struct sock *sk)return (struct ipv6_pinfo *)(((u8 *)sk) + offset); } -static int inet6_create (struct net *net,struct socket *sock,int protocol) +static int inet6_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct inet_sock *inet;struct ipv6_pinfo *np;
net/ipx/af_ipx.c +2 -1
@@ -1352,7 +1352,8 @@ static struct proto ipx_proto = { .obj_size = sizeof(struct ipx_sock), }; -static int ipx_create (struct net *net,struct socket *sock,int protocol) +static int ipx_create (struct net *net,struct socket *sock,int protocol, +int kern) {int rc = -ESOCKTNOSUPPORT ;struct sock *sk;
net/irda/af_irda.c +2 -1
@@ -1062,7 +1062,8 @@ static struct proto irda_proto = {* Create IrDA socket * */ -static int irda_create (struct net *net,struct socket *sock,int protocol) +static int irda_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct sock *sk;struct irda_sock *self;
net/iucv/af_iucv.c +2 -1
@@ -481,7 +481,8 @@ static struct sock *iucv_sock_alloc(struct socket *sock, int proto, gfp_t prio) }/* Create an IUCV socket */ -static int iucv_sock_create (struct net *net,struct socket *sock,int protocol) +static int iucv_sock_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct sock *sk;
net/key/af_key.c +2 -1
@@ -177,7 +177,8 @@ static struct proto key_proto = { .obj_size = sizeof(struct pfkey_sock), }; -static int pfkey_create (struct net *net,struct socket *sock,int protocol) +static int pfkey_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct netns_pfkey *net_pfkey =net_generic (net, pfkey_net_id);struct sock *sk;
net/llc/af_llc.c +4 -1
@@ -140,14 +140,17 @@ static struct proto llc_proto = {/** * llc_ui_create - alloc and init a new llc_ui socket +* @net: network namespace (must be default network) * @sock: Socket to initialize and attach allocated sk to. * @protocol: Unused. +* @kern: on behalf of kernel or userspace * * Allocate and initialize a new llc_ui socket, validate the user wants a * socket type we have available. * Returns 0 upon success, negative upon failure. */ -static int llc_ui_create (struct net *net,struct socket *sock,int protocol) +static int llc_ui_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct sock *sk;int rc = -ESOCKTNOSUPPORT ;
net/netlink/af_netlink.c +2 -1
@@ -428,7 +428,8 @@ static int __netlink_create(struct net *net, struct socket *sock,return 0 ; } -static int netlink_create (struct net *net,struct socket *sock,int protocol) +static int netlink_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct module *module =NULL ;struct mutex *cb_mutex;
net/netrom/af_netrom.c +2 -1
@@ -425,7 +425,8 @@ static struct proto nr_proto = { .obj_size = sizeof(struct nr_sock), }; -static int nr_create (struct net *net,struct socket *sock,int protocol) +static int nr_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct sock *sk;struct nr_sock *nr;
net/packet/af_packet.c +2 -1
@@ -1344,7 +1344,8 @@ static struct proto packet_proto = {* Create a packet of type SOCK_PACKET. */ -static int packet_create (struct net *net,struct socket *sock,int protocol) +static int packet_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct sock *sk;struct packet_sock *po;
net/phonet/af_phonet.c +2 -1
@@ -60,7 +60,8 @@ static inline void phonet_proto_put(struct phonet_protocol *pp)/* protocol family functions */ -static int pn_socket_create (struct net *net,struct socket *sock,int protocol) +static int pn_socket_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct sock *sk;struct pn_sock *pn;
net/rds/af_rds.c +2 -1
@@ -410,7 +410,8 @@ static int __rds_create(struct socket *sock, struct sock *sk, int protocol)return 0 ; } -static int rds_create (struct net *net,struct socket *sock,int protocol) +static int rds_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct sock *sk;
net/rose/af_rose.c +2 -1
@@ -512,7 +512,8 @@ static struct proto rose_proto = { .obj_size = sizeof(struct rose_sock), }; -static int rose_create (struct net *net,struct socket *sock,int protocol) +static int rose_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct sock *sk;struct rose_sock *rose;
net/rxrpc/af_rxrpc.c +2 -1
@@ -608,7 +608,8 @@ static unsigned int rxrpc_poll(struct file *file, struct socket *sock,/* * create an RxRPC socket */ -static int rxrpc_create (struct net *net,struct socket *sock,int protocol) +static int rxrpc_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct rxrpc_sock *rx;struct sock *sk;
net/socket.c +1 -1
@@ -1252,7 +1252,7 @@ static int __sock_create(struct net *net, int family, int type, int protocol,/* Now protected by module ref count */ rcu_read_unlock (); - err = pf->create (net, sock, protocol); + err = pf->create (net, sock, protocol, kern);if (err <0 ) goto out_module_put;
net/tipc/socket.c +3 -1
@@ -177,6 +177,7 @@ static void reject_rx_queue(struct sock *sk)* @net: network namespace (must be default network) * @sock: pre-allocated socket structure * @protocol: protocol indicator (must be 0) +* @kern: caused by kernel or by userspace? * * This routine creates additional data structures used by the TIPC socket, * initializes them, and links them together.
@@ -184,7 +185,8 @@ static void reject_rx_queue(struct sock *sk)* Returns 0 on success, errno otherwise */ -static int tipc_create (struct net *net,struct socket *sock,int protocol) +static int tipc_create (struct net *net,struct socket *sock,int protocol, +int kern) {const struct proto_ops *ops;socket_state state;
net/unix/af_unix.c +2 -1
@@ -621,7 +621,8 @@ out:return sk; } -static int unix_create (struct net *net,struct socket *sock,int protocol) +static int unix_create (struct net *net,struct socket *sock,int protocol, +int kern) {if (protocol && protocol !=PF_UNIX )return -EPROTONOSUPPORT ;
net/x25/af_x25.c +2 -1
@@ -501,7 +501,8 @@ out:return sk; } -static int x25_create (struct net *net,struct socket *sock,int protocol) +static int x25_create (struct net *net,struct socket *sock,int protocol, +int kern) {struct sock *sk;struct x25_sock *x25;
PATCH 3/3 net: check kern before calling security subsystem
In reply to Eric ParisBefore calling capable(CAP_NET_RAW) check if this operations is on behalf of the kernel or on behalf of userspace. Do not do the security check if it is on behalf of the kernel.
---
net/bluetooth/l2cap.c | 2 +- net/ipv4/af_inet.c | 2 +- net/ipv6/af_inet6.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
net/bluetooth/l2cap.c +1 -1
@@ -832,7 +832,7 @@ static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol, sock->type != SOCK_DGRAM && sock->type != SOCK_RAW)return -ESOCKTNOSUPPORT ; -if (sock->type ==SOCK_RAW && !capable (CAP_NET_RAW )) +if (sock->type ==SOCK_RAW && !kern && !capable (CAP_NET_RAW ))return -EPERM ; sock->ops = &l2cap_sock_ops;
net/ipv4/af_inet.c +1 -1
@@ -326,7 +326,7 @@ lookup_protocol: } err = -EPERM ; -if (sock->type ==SOCK_RAW && !capable (CAP_NET_RAW )) +if (sock->type ==SOCK_RAW && !kern && !capable (CAP_NET_RAW )) goto out_rcu_unlock; err = -EAFNOSUPPORT ;
net/ipv6/af_inet6.c +1 -1
@@ -159,7 +159,7 @@ lookup_protocol: } err = -EPERM ; -if (sock->type ==SOCK_RAW && !capable (CAP_NET_RAW )) +if (sock->type ==SOCK_RAW && !kern && !capable (CAP_NET_RAW )) goto out_rcu_unlock; sock->ops = answer->ops;
Re: [PATCH 2/3] net: pass kern to net_proto_family create function
In reply to Eric ParisQuoted 4 lines · Eric Paris
The generic
__sock_createfunction has a kern argument which allows the security system to make decisions based on if a socket is being created by the kernel or by userspace. This patch passes that flag to thenet_proto_familyspecific create function, so it can do the same thing.
[]
drivers/net/pppox.c int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) · line 108
Quoted 3 lines
drivers/net/pppox.c +2
-1-static int pppox_create (struct net *net,struct socket *sock,int protocol) +static int pppox_create (struct net *net,struct socket *sock,int protocol, +int kern)
etc...
Perhaps more readable as bool is_kernel?
Em Wed, Nov 04, 2009 at 11:32:11AM -0500, Eric Paris escreveu:
Quoted 7 lines
struct
can_protohad a capability field which wasn't ever used. It is dropped entirely.struct
inet_protoswhad a capability field which can be more clearly expressed in the code by just checking ifsock->type=SOCK_RAW.Signed-off-by Eric Paris <[email protected]>
Re: [PATCH 2/3] net: pass kern to net_proto_family create function
In reply to Eric ParisEm Wed, Nov 04, 2009 at 11:32:17AM -0500, Eric Paris escreveu:
Quoted 6 lines
The generic
__sock_createfunction has a kern argument which allows the security system to make decisions based on if a socket is being created by the kernel or by userspace. This patch passes that flag to thenet_proto_familyspecific create function, so it can do the same thing.Signed-off-by Eric Paris <[email protected]>
Re: [PATCH 3/3] net: check kern before calling security subsystem
In reply to Eric ParisEm Wed, Nov 04, 2009 at 11:32:24AM -0500, Eric Paris escreveu:
Quoted 5 lines
Before calling
capable(CAP_NET_RAW)check if this operations is on behalf of the kernel or on behalf of userspace. Do not do the security check if it is on behalf of the kernel.Signed-off-by Eric Paris <[email protected]>
Re: [PATCH 3/3] net: check kern before calling security subsystem
In reply to Eric ParisReview
Quoted 11 lines · Eric Paris
(quoted diff) +3
-3- if (sock->type == SOCK_RAW && !capable(CAP_NET_RAW)) + if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW)) return -EPERM; - if (sock->type == SOCK_RAW && !capable(CAP_NET_RAW)) + if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW)) goto out_rcu_unlock; - if (sock->type == SOCK_RAW && !capable(CAP_NET_RAW)) + if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW)) goto out_rcu_unlock;
Perhaps make this a static inline.
Signature · 2 lines
James Morris <[email protected]>
From: Arnaldo Carvalho de Melo <[email protected]>
Date: Wed, 4 Nov 2009 15:31:04 -0200
Quoted 10 lines
Em Wed, Nov 04, 2009 at 11:32:11AM -0500, Eric Paris escreveu:
Quoted 7 lines
struct
can_protohad a capability field which wasn't ever used. It is dropped entirely.struct
inet_protoswhad a capability field which can be more clearly expressed in the code by just checking ifsock->type=SOCK_RAW.Signed-off-by Eric Paris <[email protected]>
Applied to net-next-2.6
Re: [PATCH 2/3] net: pass kern to net_proto_family create function
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Date: Wed, 4 Nov 2009 15:31:47 -0200
Quoted 9 lines
Em Wed, Nov 04, 2009 at 11:32:17AM -0500, Eric Paris escreveu:
Quoted 6 lines
The generic
__sock_createfunction has a kern argument which allows the security system to make decisions based on if a socket is being created by the kernel or by userspace. This patch passes that flag to thenet_proto_familyspecific create function, so it can do the same thing.Signed-off-by Eric Paris <[email protected]>
Applied to net-next-2.6
Re: [PATCH 3/3] net: check kern before calling security subsystem
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Date: Wed, 4 Nov 2009 15:32:20 -0200
Quoted 8 lines
Em Wed, Nov 04, 2009 at 11:32:24AM -0500, Eric Paris escreveu:
Quoted 5 lines
Before calling
capable(CAP_NET_RAW)check if this operations is on behalf of the kernel or on behalf of userspace. Do not do the security check if it is on behalf of the kernel.Signed-off-by Eric Paris <[email protected]>
Applied to net-next-2.6
David Miller
maintainerRe: [PATCH 2/3] net: pass kern to net_proto_family create function
In reply to David MillerFrom: David Miller <[email protected]>
Date: Thu, 05 Nov 2009 21:08:00 -0800 (PST)
Quoted 9 lines
From: Arnaldo Carvalho de Melo <[email protected]>
Date: Wed, 4 Nov 2009 15:31:47 -0200Quoted 6 lines
Em Wed, Nov 04, 2009 at 11:32:17AM -0500, Eric Paris escreveu:
Quoted 5 lines
The generic
__sock_createfunction has a kern argument which allows the security system to make decisions based on if a socket is being created by the kernel or by userspace. This patch passes that flag to thenet_proto_familyspecific create function, so it can do the same thing.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Eric Paris <[email protected]>Applied to net-next-2.6
Eric, you missed Bluetooth and ATM in this change, breaking the build.
I'll fix this up, but next time...