Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

SUNRPC: Ensure server-side sockets have a sock->file

The TLS handshake upcall mechanism requires a non-NULL sock->file on
the socket it hands to user space. svc_sock_free() already releases
sock->file properly if one exists.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>

+18 -7
+18 -7
net/sunrpc/svcsock.c
··· 1293 1293 struct socket *sock, 1294 1294 int flags) 1295 1295 { 1296 + struct file *filp = NULL; 1296 1297 struct svc_sock *svsk; 1297 1298 struct sock *inet; 1298 1299 int pmap_register = !(flags & SVC_SOCK_ANONYMOUS); 1299 - int err = 0; 1300 1300 1301 1301 svsk = kzalloc(sizeof(*svsk), GFP_KERNEL); 1302 1302 if (!svsk) 1303 1303 return ERR_PTR(-ENOMEM); 1304 1304 1305 + if (!sock->file) { 1306 + filp = sock_alloc_file(sock, O_NONBLOCK, NULL); 1307 + if (IS_ERR(filp)) { 1308 + kfree(svsk); 1309 + return ERR_CAST(filp); 1310 + } 1311 + } 1312 + 1305 1313 inet = sock->sk; 1306 1314 1307 - /* Register socket with portmapper */ 1308 - if (pmap_register) 1315 + if (pmap_register) { 1316 + int err; 1317 + 1309 1318 err = svc_register(serv, sock_net(sock->sk), inet->sk_family, 1310 1319 inet->sk_protocol, 1311 1320 ntohs(inet_sk(inet)->inet_sport)); 1312 - 1313 - if (err < 0) { 1314 - kfree(svsk); 1315 - return ERR_PTR(err); 1321 + if (err < 0) { 1322 + if (filp) 1323 + fput(filp); 1324 + kfree(svsk); 1325 + return ERR_PTR(err); 1326 + } 1316 1327 } 1317 1328 1318 1329 svsk->sk_sock = sock;