mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-05-24 10:39:52 +00:00
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>
This commit is contained in:
parent
0f5162480b
commit
ae0d77708a
1 changed files with 18 additions and 7 deletions
|
@ -1293,27 +1293,38 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv,
|
||||||
struct socket *sock,
|
struct socket *sock,
|
||||||
int flags)
|
int flags)
|
||||||
{
|
{
|
||||||
|
struct file *filp = NULL;
|
||||||
struct svc_sock *svsk;
|
struct svc_sock *svsk;
|
||||||
struct sock *inet;
|
struct sock *inet;
|
||||||
int pmap_register = !(flags & SVC_SOCK_ANONYMOUS);
|
int pmap_register = !(flags & SVC_SOCK_ANONYMOUS);
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
svsk = kzalloc(sizeof(*svsk), GFP_KERNEL);
|
svsk = kzalloc(sizeof(*svsk), GFP_KERNEL);
|
||||||
if (!svsk)
|
if (!svsk)
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
|
if (!sock->file) {
|
||||||
|
filp = sock_alloc_file(sock, O_NONBLOCK, NULL);
|
||||||
|
if (IS_ERR(filp)) {
|
||||||
|
kfree(svsk);
|
||||||
|
return ERR_CAST(filp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inet = sock->sk;
|
inet = sock->sk;
|
||||||
|
|
||||||
/* Register socket with portmapper */
|
if (pmap_register) {
|
||||||
if (pmap_register)
|
int err;
|
||||||
|
|
||||||
err = svc_register(serv, sock_net(sock->sk), inet->sk_family,
|
err = svc_register(serv, sock_net(sock->sk), inet->sk_family,
|
||||||
inet->sk_protocol,
|
inet->sk_protocol,
|
||||||
ntohs(inet_sk(inet)->inet_sport));
|
ntohs(inet_sk(inet)->inet_sport));
|
||||||
|
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
|
if (filp)
|
||||||
|
fput(filp);
|
||||||
kfree(svsk);
|
kfree(svsk);
|
||||||
return ERR_PTR(err);
|
return ERR_PTR(err);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
svsk->sk_sock = sock;
|
svsk->sk_sock = sock;
|
||||||
svsk->sk_sk = inet;
|
svsk->sk_sk = inet;
|
||||||
|
|
Loading…
Add table
Reference in a new issue