Skip to content

Commit 3f378b6

Browse files
eparisdavem330
authored andcommitted
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. Signed-off-by: Eric Paris <eparis@redhat.com> Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 13f18aa commit 3f378b6

37 files changed

Lines changed: 80 additions & 43 deletions

File tree

‎drivers/isdn/mISDN/socket.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ base_sock_create(struct net *net, struct socket *sock, int protocol)
779779
}
780780

781781
static int
782-
mISDN_sock_create(struct net *net, struct socket *sock, int proto)
782+
mISDN_sock_create(struct net *net, struct socket *sock, int proto, int kern)
783783
{
784784
int err = -EPROTONOSUPPORT;
785785

‎drivers/net/pppox.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
104104

105105
EXPORT_SYMBOL(pppox_ioctl);
106106

107-
static int pppox_create(struct net *net, struct socket *sock, int protocol)
107+
static int pppox_create(struct net *net, struct socket *sock, int protocol,
108+
int kern)
108109
{
109110
int rc = -EPROTOTYPE;
110111

‎include/linux/net.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ struct proto_ops {
204204

205205
struct net_proto_family {
206206
int family;
207-
int (*create)(struct net *net, struct socket *sock, int protocol);
207+
int (*create)(struct net *net, struct socket *sock,
208+
int protocol, int kern);
208209
struct module *owner;
209210
};
210211

‎net/appletalk/ddp.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,8 @@ static struct proto ddp_proto = {
10211021
* Create a socket. Initialise the socket, blank the addresses
10221022
* set the state.
10231023
*/
1024-
static int atalk_create(struct net *net, struct socket *sock, int protocol)
1024+
static int atalk_create(struct net *net, struct socket *sock, int protocol,
1025+
int kern)
10251026
{
10261027
struct sock *sk;
10271028
int rc = -ESOCKTNOSUPPORT;

‎net/atm/pvc.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ static const struct proto_ops pvc_proto_ops = {
127127
};
128128

129129

130-
static int pvc_create(struct net *net, struct socket *sock,int protocol)
130+
static int pvc_create(struct net *net, struct socket *sock, int protocol,
131+
int kern)
131132
{
132133
if (net != &init_net)
133134
return -EAFNOSUPPORT;

‎net/atm/svc.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "signaling.h"
2626
#include "addr.h"
2727

28-
static int svc_create(struct net *net, struct socket *sock,int protocol);
28+
static int svc_create(struct net *net, struct socket *sock, int protocol, int kern);
2929

3030
/*
3131
* Note: since all this is still nicely synchronized with the signaling demon,
@@ -330,7 +330,7 @@ static int svc_accept(struct socket *sock,struct socket *newsock,int flags)
330330

331331
lock_sock(sk);
332332

333-
error = svc_create(sock_net(sk), newsock,0);
333+
error = svc_create(sock_net(sk), newsock, 0, 0);
334334
if (error)
335335
goto out;
336336

@@ -650,7 +650,8 @@ static const struct proto_ops svc_proto_ops = {
650650
};
651651

652652

653-
static int svc_create(struct net *net, struct socket *sock,int protocol)
653+
static int svc_create(struct net *net, struct socket *sock, int protocol,
654+
int kern)
654655
{
655656
int error;
656657

‎net/ax25/af_ax25.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,8 @@ static struct proto ax25_proto = {
799799
.obj_size = sizeof(struct sock),
800800
};
801801

802-
static int ax25_create(struct net *net, struct socket *sock, int protocol)
802+
static int ax25_create(struct net *net, struct socket *sock, int protocol,
803+
int kern)
803804
{
804805
struct sock *sk;
805806
ax25_cb *ax25;

‎net/bluetooth/af_bluetooth.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ int bt_sock_unregister(int proto)
126126
}
127127
EXPORT_SYMBOL(bt_sock_unregister);
128128

129-
static int bt_sock_create(struct net *net, struct socket *sock, int proto)
129+
static int bt_sock_create(struct net *net, struct socket *sock, int proto,
130+
int kern)
130131
{
131132
int err;
132133

@@ -144,7 +145,7 @@ static int bt_sock_create(struct net *net, struct socket *sock, int proto)
144145
read_lock(&bt_proto_lock);
145146

146147
if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) {
147-
err = bt_proto[proto]->create(net, sock, proto);
148+
err = bt_proto[proto]->create(net, sock, proto, kern);
148149
bt_sock_reclassify_lock(sock, proto);
149150
module_put(bt_proto[proto]->owner);
150151
}

‎net/bluetooth/bnep/sock.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ static struct proto bnep_proto = {
195195
.obj_size = sizeof(struct bt_sock)
196196
};
197197

198-
static int bnep_sock_create(struct net *net, struct socket *sock, int protocol)
198+
static int bnep_sock_create(struct net *net, struct socket *sock, int protocol,
199+
int kern)
199200
{
200201
struct sock *sk;
201202

‎net/bluetooth/cmtp/sock.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ static struct proto cmtp_proto = {
190190
.obj_size = sizeof(struct bt_sock)
191191
};
192192

193-
static int cmtp_sock_create(struct net *net, struct socket *sock, int protocol)
193+
static int cmtp_sock_create(struct net *net, struct socket *sock, int protocol,
194+
int kern)
194195
{
195196
struct sock *sk;
196197

0 commit comments

Comments
 (0)