Skip to content

Commit 11aa9c2

Browse files
ebiedermdavem330
authored andcommitted
net: Pass kern from net_proto_family.create to sk_alloc
In preparation for changing how struct net is refcounted on kernel sockets pass the knowledge that we are creating a kernel socket from sock_create_kern through to sk_alloc. Signed-off-by: "Eric W. Biederman" <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent eeb1bd5 commit 11aa9c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+109
-108
lines changed

crypto/af_alg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ int af_alg_accept(struct sock *sk, struct socket *newsock)
244244
if (!type)
245245
goto unlock;
246246

247-
sk2 = sk_alloc(sock_net(sk), PF_ALG, GFP_KERNEL, &alg_proto);
247+
sk2 = sk_alloc(sock_net(sk), PF_ALG, GFP_KERNEL, &alg_proto, 0);
248248
err = -ENOMEM;
249249
if (!sk2)
250250
goto unlock;
@@ -324,7 +324,7 @@ static int alg_create(struct net *net, struct socket *sock, int protocol,
324324
return -EPROTONOSUPPORT;
325325

326326
err = -ENOMEM;
327-
sk = sk_alloc(net, PF_ALG, GFP_KERNEL, &alg_proto);
327+
sk = sk_alloc(net, PF_ALG, GFP_KERNEL, &alg_proto, kern);
328328
if (!sk)
329329
goto out;
330330

drivers/isdn/mISDN/socket.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -601,14 +601,14 @@ static const struct proto_ops data_sock_ops = {
601601
};
602602

603603
static int
604-
data_sock_create(struct net *net, struct socket *sock, int protocol)
604+
data_sock_create(struct net *net, struct socket *sock, int protocol, int kern)
605605
{
606606
struct sock *sk;
607607

608608
if (sock->type != SOCK_DGRAM)
609609
return -ESOCKTNOSUPPORT;
610610

611-
sk = sk_alloc(net, PF_ISDN, GFP_KERNEL, &mISDN_proto);
611+
sk = sk_alloc(net, PF_ISDN, GFP_KERNEL, &mISDN_proto, kern);
612612
if (!sk)
613613
return -ENOMEM;
614614

@@ -756,14 +756,14 @@ static const struct proto_ops base_sock_ops = {
756756

757757

758758
static int
759-
base_sock_create(struct net *net, struct socket *sock, int protocol)
759+
base_sock_create(struct net *net, struct socket *sock, int protocol, int kern)
760760
{
761761
struct sock *sk;
762762

763763
if (sock->type != SOCK_RAW)
764764
return -ESOCKTNOSUPPORT;
765765

766-
sk = sk_alloc(net, PF_ISDN, GFP_KERNEL, &mISDN_proto);
766+
sk = sk_alloc(net, PF_ISDN, GFP_KERNEL, &mISDN_proto, kern);
767767
if (!sk)
768768
return -ENOMEM;
769769

@@ -785,7 +785,7 @@ mISDN_sock_create(struct net *net, struct socket *sock, int proto, int kern)
785785

786786
switch (proto) {
787787
case ISDN_P_BASE:
788-
err = base_sock_create(net, sock, proto);
788+
err = base_sock_create(net, sock, proto, kern);
789789
break;
790790
case ISDN_P_TE_S0:
791791
case ISDN_P_NT_S0:
@@ -799,7 +799,7 @@ mISDN_sock_create(struct net *net, struct socket *sock, int proto, int kern)
799799
case ISDN_P_B_L2DTMF:
800800
case ISDN_P_B_L2DSP:
801801
case ISDN_P_B_L2DSPHDLC:
802-
err = data_sock_create(net, sock, proto);
802+
err = data_sock_create(net, sock, proto, kern);
803803
break;
804804
default:
805805
return err;

drivers/net/macvtap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ static int macvtap_open(struct inode *inode, struct file *file)
476476

477477
err = -ENOMEM;
478478
q = (struct macvtap_queue *)sk_alloc(net, AF_UNSPEC, GFP_KERNEL,
479-
&macvtap_proto);
479+
&macvtap_proto, 0);
480480
if (!q)
481481
goto out;
482482

drivers/net/ppp/pppoe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,11 +546,11 @@ static struct proto pppoe_sk_proto __read_mostly = {
546546
* Initialize a new struct sock.
547547
*
548548
**********************************************************************/
549-
static int pppoe_create(struct net *net, struct socket *sock)
549+
static int pppoe_create(struct net *net, struct socket *sock, int kern)
550550
{
551551
struct sock *sk;
552552

553-
sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pppoe_sk_proto);
553+
sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pppoe_sk_proto, kern);
554554
if (!sk)
555555
return -ENOMEM;
556556

drivers/net/ppp/pppox.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static int pppox_create(struct net *net, struct socket *sock, int protocol,
118118
!try_module_get(pppox_protos[protocol]->owner))
119119
goto out;
120120

121-
rc = pppox_protos[protocol]->create(net, sock);
121+
rc = pppox_protos[protocol]->create(net, sock, kern);
122122

123123
module_put(pppox_protos[protocol]->owner);
124124
out:

drivers/net/ppp/pptp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,14 +561,14 @@ static void pptp_sock_destruct(struct sock *sk)
561561
skb_queue_purge(&sk->sk_receive_queue);
562562
}
563563

564-
static int pptp_create(struct net *net, struct socket *sock)
564+
static int pptp_create(struct net *net, struct socket *sock, int kern)
565565
{
566566
int error = -ENOMEM;
567567
struct sock *sk;
568568
struct pppox_sock *po;
569569
struct pptp_opt *opt;
570570

571-
sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pptp_sk_proto);
571+
sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pptp_sk_proto, kern);
572572
if (!sk)
573573
goto out;
574574

drivers/net/tun.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2148,7 +2148,7 @@ static int tun_chr_open(struct inode *inode, struct file * file)
21482148
DBG1(KERN_INFO, "tunX: tun_chr_open\n");
21492149

21502150
tfile = (struct tun_file *)sk_alloc(net, AF_UNSPEC, GFP_KERNEL,
2151-
&tun_proto);
2151+
&tun_proto, 0);
21522152
if (!tfile)
21532153
return -ENOMEM;
21542154
RCU_INIT_POINTER(tfile->tun, NULL);

include/linux/if_pppox.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static inline struct sock *sk_pppox(struct pppox_sock *po)
7474
struct module;
7575

7676
struct pppox_proto {
77-
int (*create)(struct net *net, struct socket *sock);
77+
int (*create)(struct net *net, struct socket *sock, int kern);
7878
int (*ioctl)(struct socket *sock, unsigned int cmd,
7979
unsigned long arg);
8080
struct module *owner;

include/net/af_vsock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void vsock_pending_work(struct work_struct *work);
7474
struct sock *__vsock_create(struct net *net,
7575
struct socket *sock,
7676
struct sock *parent,
77-
gfp_t priority, unsigned short type);
77+
gfp_t priority, unsigned short type, int kern);
7878

7979
/**** TRANSPORT ****/
8080

include/net/llc_conn.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static __inline__ char llc_backlog_type(struct sk_buff *skb)
9696
}
9797

9898
struct sock *llc_sk_alloc(struct net *net, int family, gfp_t priority,
99-
struct proto *prot);
99+
struct proto *prot, int kern);
100100
void llc_sk_free(struct sock *sk);
101101

102102
void llc_sk_reset(struct sock *sk);

include/net/sock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,7 @@ static inline void unlock_sock_fast(struct sock *sk, bool slow)
15141514

15151515

15161516
struct sock *sk_alloc(struct net *net, int family, gfp_t priority,
1517-
struct proto *prot);
1517+
struct proto *prot, int kern);
15181518
void sk_free(struct sock *sk);
15191519
void sk_release_kernel(struct sock *sk);
15201520
struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority);

net/appletalk/ddp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ static int atalk_create(struct net *net, struct socket *sock, int protocol,
10301030
if (sock->type != SOCK_RAW && sock->type != SOCK_DGRAM)
10311031
goto out;
10321032
rc = -ENOMEM;
1033-
sk = sk_alloc(net, PF_APPLETALK, GFP_KERNEL, &ddp_proto);
1033+
sk = sk_alloc(net, PF_APPLETALK, GFP_KERNEL, &ddp_proto, kern);
10341034
if (!sk)
10351035
goto out;
10361036
rc = 0;

net/atm/common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,15 @@ static struct proto vcc_proto = {
141141
.release_cb = vcc_release_cb,
142142
};
143143

144-
int vcc_create(struct net *net, struct socket *sock, int protocol, int family)
144+
int vcc_create(struct net *net, struct socket *sock, int protocol, int family, int kern)
145145
{
146146
struct sock *sk;
147147
struct atm_vcc *vcc;
148148

149149
sock->sk = NULL;
150150
if (sock->type == SOCK_STREAM)
151151
return -EINVAL;
152-
sk = sk_alloc(net, family, GFP_KERNEL, &vcc_proto);
152+
sk = sk_alloc(net, family, GFP_KERNEL, &vcc_proto, kern);
153153
if (!sk)
154154
return -ENOMEM;
155155
sock_init_data(sock, sk);

net/atm/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <linux/poll.h> /* for poll_table */
1111

1212

13-
int vcc_create(struct net *net, struct socket *sock, int protocol, int family);
13+
int vcc_create(struct net *net, struct socket *sock, int protocol, int family, int kern);
1414
int vcc_release(struct socket *sock);
1515
int vcc_connect(struct socket *sock, int itf, short vpi, int vci);
1616
int vcc_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,

net/atm/pvc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static int pvc_create(struct net *net, struct socket *sock, int protocol,
136136
return -EAFNOSUPPORT;
137137

138138
sock->ops = &pvc_proto_ops;
139-
return vcc_create(net, sock, protocol, PF_ATMPVC);
139+
return vcc_create(net, sock, protocol, PF_ATMPVC, kern);
140140
}
141141

142142
static const struct net_proto_family pvc_family_ops = {

net/atm/svc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ static int svc_create(struct net *net, struct socket *sock, int protocol,
660660
return -EAFNOSUPPORT;
661661

662662
sock->ops = &svc_proto_ops;
663-
error = vcc_create(net, sock, protocol, AF_ATMSVC);
663+
error = vcc_create(net, sock, protocol, AF_ATMSVC, kern);
664664
if (error)
665665
return error;
666666
ATM_SD(sock)->local.sas_family = AF_ATMSVC;

net/ax25/af_ax25.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ static int ax25_create(struct net *net, struct socket *sock, int protocol,
855855
return -ESOCKTNOSUPPORT;
856856
}
857857

858-
sk = sk_alloc(net, PF_AX25, GFP_ATOMIC, &ax25_proto);
858+
sk = sk_alloc(net, PF_AX25, GFP_ATOMIC, &ax25_proto, kern);
859859
if (sk == NULL)
860860
return -ENOMEM;
861861

@@ -881,7 +881,7 @@ struct sock *ax25_make_new(struct sock *osk, struct ax25_dev *ax25_dev)
881881
struct sock *sk;
882882
ax25_cb *ax25, *oax25;
883883

884-
sk = sk_alloc(sock_net(osk), PF_AX25, GFP_ATOMIC, osk->sk_prot);
884+
sk = sk_alloc(sock_net(osk), PF_AX25, GFP_ATOMIC, osk->sk_prot, 0);
885885
if (sk == NULL)
886886
return NULL;
887887

net/bluetooth/bnep/sock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ static int bnep_sock_create(struct net *net, struct socket *sock, int protocol,
202202
if (sock->type != SOCK_RAW)
203203
return -ESOCKTNOSUPPORT;
204204

205-
sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &bnep_proto);
205+
sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &bnep_proto, kern);
206206
if (!sk)
207207
return -ENOMEM;
208208

net/bluetooth/cmtp/sock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ static int cmtp_sock_create(struct net *net, struct socket *sock, int protocol,
205205
if (sock->type != SOCK_RAW)
206206
return -ESOCKTNOSUPPORT;
207207

208-
sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &cmtp_proto);
208+
sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &cmtp_proto, kern);
209209
if (!sk)
210210
return -ENOMEM;
211211

net/bluetooth/hci_sock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@ static int hci_sock_create(struct net *net, struct socket *sock, int protocol,
13771377

13781378
sock->ops = &hci_sock_ops;
13791379

1380-
sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hci_sk_proto);
1380+
sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hci_sk_proto, kern);
13811381
if (!sk)
13821382
return -ENOMEM;
13831383

net/bluetooth/hidp/sock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static int hidp_sock_create(struct net *net, struct socket *sock, int protocol,
235235
if (sock->type != SOCK_RAW)
236236
return -ESOCKTNOSUPPORT;
237237

238-
sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hidp_proto);
238+
sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hidp_proto, kern);
239239
if (!sk)
240240
return -ENOMEM;
241241

net/bluetooth/l2cap_sock.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static struct bt_sock_list l2cap_sk_list = {
4343
static const struct proto_ops l2cap_sock_ops;
4444
static void l2cap_sock_init(struct sock *sk, struct sock *parent);
4545
static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock,
46-
int proto, gfp_t prio);
46+
int proto, gfp_t prio, int kern);
4747

4848
bool l2cap_is_socket(struct socket *sock)
4949
{
@@ -1193,7 +1193,7 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(struct l2cap_chan *chan)
11931193
}
11941194

11951195
sk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP,
1196-
GFP_ATOMIC);
1196+
GFP_ATOMIC, 0);
11971197
if (!sk) {
11981198
release_sock(parent);
11991199
return NULL;
@@ -1523,12 +1523,12 @@ static struct proto l2cap_proto = {
15231523
};
15241524

15251525
static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock,
1526-
int proto, gfp_t prio)
1526+
int proto, gfp_t prio, int kern)
15271527
{
15281528
struct sock *sk;
15291529
struct l2cap_chan *chan;
15301530

1531-
sk = sk_alloc(net, PF_BLUETOOTH, prio, &l2cap_proto);
1531+
sk = sk_alloc(net, PF_BLUETOOTH, prio, &l2cap_proto, kern);
15321532
if (!sk)
15331533
return NULL;
15341534

@@ -1574,7 +1574,7 @@ static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol,
15741574

15751575
sock->ops = &l2cap_sock_ops;
15761576

1577-
sk = l2cap_sock_alloc(net, sock, protocol, GFP_ATOMIC);
1577+
sk = l2cap_sock_alloc(net, sock, protocol, GFP_ATOMIC, kern);
15781578
if (!sk)
15791579
return -ENOMEM;
15801580

net/bluetooth/rfcomm/sock.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,12 @@ static struct proto rfcomm_proto = {
269269
.obj_size = sizeof(struct rfcomm_pinfo)
270270
};
271271

272-
static struct sock *rfcomm_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio)
272+
static struct sock *rfcomm_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio, int kern)
273273
{
274274
struct rfcomm_dlc *d;
275275
struct sock *sk;
276276

277-
sk = sk_alloc(net, PF_BLUETOOTH, prio, &rfcomm_proto);
277+
sk = sk_alloc(net, PF_BLUETOOTH, prio, &rfcomm_proto, kern);
278278
if (!sk)
279279
return NULL;
280280

@@ -324,7 +324,7 @@ static int rfcomm_sock_create(struct net *net, struct socket *sock,
324324

325325
sock->ops = &rfcomm_sock_ops;
326326

327-
sk = rfcomm_sock_alloc(net, sock, protocol, GFP_ATOMIC);
327+
sk = rfcomm_sock_alloc(net, sock, protocol, GFP_ATOMIC, kern);
328328
if (!sk)
329329
return -ENOMEM;
330330

@@ -969,7 +969,7 @@ int rfcomm_connect_ind(struct rfcomm_session *s, u8 channel, struct rfcomm_dlc *
969969
goto done;
970970
}
971971

972-
sk = rfcomm_sock_alloc(sock_net(parent), NULL, BTPROTO_RFCOMM, GFP_ATOMIC);
972+
sk = rfcomm_sock_alloc(sock_net(parent), NULL, BTPROTO_RFCOMM, GFP_ATOMIC, 0);
973973
if (!sk)
974974
goto done;
975975

net/bluetooth/sco.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -460,11 +460,11 @@ static struct proto sco_proto = {
460460
.obj_size = sizeof(struct sco_pinfo)
461461
};
462462

463-
static struct sock *sco_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio)
463+
static struct sock *sco_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio, int kern)
464464
{
465465
struct sock *sk;
466466

467-
sk = sk_alloc(net, PF_BLUETOOTH, prio, &sco_proto);
467+
sk = sk_alloc(net, PF_BLUETOOTH, prio, &sco_proto, kern);
468468
if (!sk)
469469
return NULL;
470470

@@ -501,7 +501,7 @@ static int sco_sock_create(struct net *net, struct socket *sock, int protocol,
501501

502502
sock->ops = &sco_sock_ops;
503503

504-
sk = sco_sock_alloc(net, sock, protocol, GFP_ATOMIC);
504+
sk = sco_sock_alloc(net, sock, protocol, GFP_ATOMIC, kern);
505505
if (!sk)
506506
return -ENOMEM;
507507

@@ -1026,7 +1026,7 @@ static void sco_conn_ready(struct sco_conn *conn)
10261026
bh_lock_sock(parent);
10271027

10281028
sk = sco_sock_alloc(sock_net(parent), NULL,
1029-
BTPROTO_SCO, GFP_ATOMIC);
1029+
BTPROTO_SCO, GFP_ATOMIC, 0);
10301030
if (!sk) {
10311031
bh_unlock_sock(parent);
10321032
sco_conn_unlock(conn);

net/caif/caif_socket.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ static int caif_create(struct net *net, struct socket *sock, int protocol,
10471047
* is really not used at all in the net/core or socket.c but the
10481048
* initialization makes sure that sock->state is not uninitialized.
10491049
*/
1050-
sk = sk_alloc(net, PF_CAIF, GFP_KERNEL, &prot);
1050+
sk = sk_alloc(net, PF_CAIF, GFP_KERNEL, &prot, kern);
10511051
if (!sk)
10521052
return -ENOMEM;
10531053

net/can/af_can.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ static int can_create(struct net *net, struct socket *sock, int protocol,
179179

180180
sock->ops = cp->ops;
181181

182-
sk = sk_alloc(net, PF_CAN, GFP_KERNEL, cp->prot);
182+
sk = sk_alloc(net, PF_CAN, GFP_KERNEL, cp->prot, kern);
183183
if (!sk) {
184184
err = -ENOMEM;
185185
goto errout;

0 commit comments

Comments
 (0)