提交 37c00cf3 编写于 作者: T Trond Myklebust 提交者: Yongqiang Liu

SUNRPC: Ensure that the gssproxy client can start in a connected state

mainline inclusion
from mainline-v5.18-rc7
commit fd13359f
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I57MRF
CVE: NA

-------------------------------------------

Ensure that the gssproxy client connects to the server from the gssproxy
daemon process context so that the AF_LOCAL socket connection is done
using the correct path and namespaces.

Fixes: 1d658336 ("SUNRPC: Add RPC based upcall mechanism for RPCGSS auth")
Cc: stable@vger.kernel.org
Signed-off-by: NTrond Myklebust <trond.myklebust@hammerspace.com>

conflicts:
	include/linux/sunrpc/clnt.h
	net/sunrpc/clnt.c
Signed-off-by: NWang Hai <wanghai38@huawei.com>
Reviewed-by: NZhang Xiaoxu <zhangxiaoxu5@huawei.com>
Reviewed-by: NWei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
上级 e10b5170
...@@ -144,6 +144,7 @@ struct rpc_add_xprt_test { ...@@ -144,6 +144,7 @@ struct rpc_add_xprt_test {
#define RPC_CLNT_CREATE_NO_IDLE_TIMEOUT (1UL << 8) #define RPC_CLNT_CREATE_NO_IDLE_TIMEOUT (1UL << 8)
#define RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT (1UL << 9) #define RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT (1UL << 9)
#define RPC_CLNT_CREATE_REUSEPORT (1UL << 11) #define RPC_CLNT_CREATE_REUSEPORT (1UL << 11)
#define RPC_CLNT_CREATE_CONNECTED (1UL << 12)
struct rpc_clnt *rpc_create(struct rpc_create_args *args); struct rpc_clnt *rpc_create(struct rpc_create_args *args);
struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *, struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *,
......
...@@ -111,6 +111,7 @@ static int gssp_rpc_create(struct net *net, struct rpc_clnt **_clnt) ...@@ -111,6 +111,7 @@ static int gssp_rpc_create(struct net *net, struct rpc_clnt **_clnt)
* done without the correct namespace: * done without the correct namespace:
*/ */
.flags = RPC_CLNT_CREATE_NOPING | .flags = RPC_CLNT_CREATE_NOPING |
RPC_CLNT_CREATE_CONNECTED |
RPC_CLNT_CREATE_NO_IDLE_TIMEOUT RPC_CLNT_CREATE_NO_IDLE_TIMEOUT
}; };
struct rpc_clnt *clnt; struct rpc_clnt *clnt;
......
...@@ -79,6 +79,7 @@ static void call_connect_status(struct rpc_task *task); ...@@ -79,6 +79,7 @@ static void call_connect_status(struct rpc_task *task);
static __be32 *rpc_encode_header(struct rpc_task *task); static __be32 *rpc_encode_header(struct rpc_task *task);
static __be32 *rpc_verify_header(struct rpc_task *task); static __be32 *rpc_verify_header(struct rpc_task *task);
static int rpc_ping(struct rpc_clnt *clnt); static int rpc_ping(struct rpc_clnt *clnt);
static int rpc_ping_noreply(struct rpc_clnt *clnt);
static void rpc_register_client(struct rpc_clnt *clnt) static void rpc_register_client(struct rpc_clnt *clnt)
{ {
...@@ -481,6 +482,12 @@ static struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args, ...@@ -481,6 +482,12 @@ static struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args,
rpc_shutdown_client(clnt); rpc_shutdown_client(clnt);
return ERR_PTR(err); return ERR_PTR(err);
} }
} else if (args->flags & RPC_CLNT_CREATE_CONNECTED) {
int err = rpc_ping_noreply(clnt);
if (err != 0) {
rpc_shutdown_client(clnt);
return ERR_PTR(err);
}
} }
clnt->cl_softrtry = 1; clnt->cl_softrtry = 1;
...@@ -2545,6 +2552,10 @@ static const struct rpc_procinfo rpcproc_null = { ...@@ -2545,6 +2552,10 @@ static const struct rpc_procinfo rpcproc_null = {
.p_decode = rpcproc_decode_null, .p_decode = rpcproc_decode_null,
}; };
static const struct rpc_procinfo rpcproc_null_noreply = {
.p_encode = rpcproc_encode_null,
};
static int rpc_ping(struct rpc_clnt *clnt) static int rpc_ping(struct rpc_clnt *clnt)
{ {
struct rpc_message msg = { struct rpc_message msg = {
...@@ -2557,6 +2568,32 @@ static int rpc_ping(struct rpc_clnt *clnt) ...@@ -2557,6 +2568,32 @@ static int rpc_ping(struct rpc_clnt *clnt)
return err; return err;
} }
static int rpc_ping_noreply(struct rpc_clnt *clnt)
{
struct rpc_message msg = {
.rpc_proc = &rpcproc_null_noreply,
};
struct rpc_task_setup task_setup_data = {
.rpc_client = clnt,
.rpc_message = &msg,
.callback_ops = &rpc_default_ops,
.flags = RPC_TASK_SOFT | RPC_TASK_SOFTCONN,
};
struct rpc_task *task;
int status;
msg.rpc_cred = authnull_ops.lookup_cred(NULL, NULL, 0);
task = rpc_run_task(&task_setup_data);
if (IS_ERR(task)) {
put_rpccred(msg.rpc_cred);
return PTR_ERR(task);
}
status = task->tk_status;
rpc_put_task(task);
put_rpccred(msg.rpc_cred);
return status;
}
static static
struct rpc_task *rpc_call_null_helper(struct rpc_clnt *clnt, struct rpc_task *rpc_call_null_helper(struct rpc_clnt *clnt,
struct rpc_xprt *xprt, struct rpc_cred *cred, int flags, struct rpc_xprt *xprt, struct rpc_cred *cred, int flags,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册