From 0f413062132d9e95b7e4236c87b051c10806bef7 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 13 Feb 2019 16:02:06 +0100 Subject: [PATCH] 4.19-stable patches added patches: sunrpc-always-drop-the-xprt_lock-on-xprt_close_wait.patch xfrm-make-set-mark-default-behavior-backward-compatible.patch --- queue-4.19/series | 2 + ...rop-the-xprt_lock-on-xprt_close_wait.patch | 103 ++++++++++++++++++ ...default-behavior-backward-compatible.patch | 48 ++++++++ 3 files changed, 153 insertions(+) create mode 100644 queue-4.19/sunrpc-always-drop-the-xprt_lock-on-xprt_close_wait.patch create mode 100644 queue-4.19/xfrm-make-set-mark-default-behavior-backward-compatible.patch diff --git a/queue-4.19/series b/queue-4.19/series index 6913d5c9f5b..d63b8d063bb 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -33,3 +33,5 @@ drm-amd-powerplay-fix-missing-break-in-switch.patch drm-i915-always-return-something-on-ddi-clock-selection.patch drm-vmwgfx-fix-setting-of-dma-masks.patch drm-vmwgfx-return-error-code-from-vmw_execbuf_copy_fence_user.patch +sunrpc-always-drop-the-xprt_lock-on-xprt_close_wait.patch +xfrm-make-set-mark-default-behavior-backward-compatible.patch diff --git a/queue-4.19/sunrpc-always-drop-the-xprt_lock-on-xprt_close_wait.patch b/queue-4.19/sunrpc-always-drop-the-xprt_lock-on-xprt_close_wait.patch new file mode 100644 index 00000000000..26ba10e195d --- /dev/null +++ b/queue-4.19/sunrpc-always-drop-the-xprt_lock-on-xprt_close_wait.patch @@ -0,0 +1,103 @@ +From bcodding@redhat.com Wed Feb 13 15:24:58 2019 +From: Benjamin Coddington +Date: Wed, 6 Feb 2019 06:42:15 -0500 +Subject: [STABLE PATCH] SUNRPC: Always drop the XPRT_LOCK on XPRT_CLOSE_WAIT +To: stable@vger.kernel.org +Cc: dwysocha@redhat.com, linux-nfs@vger.kernel.org, smayhew@redhat.com, trondmy@hammerspace.com +Message-ID: + +From: Benjamin Coddington + +This patch is only appropriate for stable kernels v4.16 - v4.19 + +Since commit 9b30889c548a ("SUNRPC: Ensure we always close the socket after +a connection shuts down"), and until commit c544577daddb ("SUNRPC: Clean up +transport write space handling"), it is possible for the NFS client to spin +in the following tight loop: + +269.964083: rpc_task_run_action: task:43@0 flags=5a81 state=0005 status=0 action=call_bind [sunrpc] +269.964083: rpc_task_run_action: task:43@0 flags=5a81 state=0005 status=0 action=call_connect [sunrpc] +269.964083: rpc_task_run_action: task:43@0 flags=5a81 state=0005 status=0 action=call_transmit [sunrpc] +269.964085: xprt_transmit: peer=[10.0.1.82]:2049 xid=0x761d3f77 status=-32 +269.964085: rpc_task_run_action: task:43@0 flags=5a81 state=0005 status=-32 action=call_transmit_status [sunrpc] +269.964085: rpc_task_run_action: task:43@0 flags=5a81 state=0005 status=-32 action=call_status [sunrpc] +269.964085: rpc_call_status: task:43@0 status=-32 + +The issue is that the path through call_transmit_status does not release +the XPRT_LOCK when the transmit result is -EPIPE, so the socket cannot be +properly shut down. + +The below commit fixed things up in mainline by unconditionally calling +xprt_end_transmit() and releasing the XPRT_LOCK after every pass through +call_transmit. However, the entirety of this commit is not appropriate for +stable kernels because its original inclusion was part of a series that +modifies the sunrpc code to use a different queueing model. As a result, +there are machinations within this patch that are not needed for a stable +fix and will not make sense without a larger backport of the mainline +series. + +In this patch, we take the slightly modified bit of the mainline patch +below, which is to release the XPRT_LOCK on transmission error should we +detect that the transport is waiting to close. + +commit c544577daddb618c7dd5fa7fb98d6a41782f020e upstream +Author: Trond Myklebust +Date: Mon Sep 3 23:39:27 2018 -0400 + + SUNRPC: Clean up transport write space handling + + Treat socket write space handling in the same way we now treat transport + congestion: by denying the XPRT_LOCK until the transport signals that it + has free buffer space. + + Signed-off-by: Trond Myklebust + +The original discussion of the problem is here: + + https://lore.kernel.org/linux-nfs/20181212135157.4489-1-dwysocha@redhat.com/T/#t + +This passes my usual cthon and xfstests on NFS as applied on v4.19 mainline. + +Reported-by: Dave Wysochanski +Suggested-by: Trond Myklebust +Signed-off-by: Benjamin Coddington +Signed-off-by: Greg Kroah-Hartman +--- + include/linux/sunrpc/xprt.h | 5 +++++ + net/sunrpc/clnt.c | 6 ++++-- + 2 files changed, 9 insertions(+), 2 deletions(-) + +--- a/include/linux/sunrpc/xprt.h ++++ b/include/linux/sunrpc/xprt.h +@@ -443,6 +443,11 @@ static inline int xprt_test_and_set_conn + return test_and_set_bit(XPRT_CONNECTING, &xprt->state); + } + ++static inline int xprt_close_wait(struct rpc_xprt *xprt) ++{ ++ return test_bit(XPRT_CLOSE_WAIT, &xprt->state); ++} ++ + static inline void xprt_set_bound(struct rpc_xprt *xprt) + { + test_and_set_bit(XPRT_BOUND, &xprt->state); +--- a/net/sunrpc/clnt.c ++++ b/net/sunrpc/clnt.c +@@ -1992,13 +1992,15 @@ call_transmit(struct rpc_task *task) + static void + call_transmit_status(struct rpc_task *task) + { ++ struct rpc_xprt *xprt = task->tk_rqstp->rq_xprt; + task->tk_action = call_status; + + /* + * Common case: success. Force the compiler to put this +- * test first. ++ * test first. Or, if any error and xprt_close_wait, ++ * release the xprt lock so the socket can close. + */ +- if (task->tk_status == 0) { ++ if (task->tk_status == 0 || xprt_close_wait(xprt)) { + xprt_end_transmit(task); + rpc_task_force_reencode(task); + return; diff --git a/queue-4.19/xfrm-make-set-mark-default-behavior-backward-compatible.patch b/queue-4.19/xfrm-make-set-mark-default-behavior-backward-compatible.patch new file mode 100644 index 00000000000..7c58f0c63e4 --- /dev/null +++ b/queue-4.19/xfrm-make-set-mark-default-behavior-backward-compatible.patch @@ -0,0 +1,48 @@ +From e2612cd496e7b465711d219ea6118893d7253f52 Mon Sep 17 00:00:00 2001 +From: Benedict Wong +Date: Mon, 14 Jan 2019 11:24:38 -0800 +Subject: xfrm: Make set-mark default behavior backward compatible +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Benedict Wong + +commit e2612cd496e7b465711d219ea6118893d7253f52 upstream. + +Fixes 9b42c1f179a6, which changed the default route lookup behavior for +tunnel mode SAs in the outbound direction to use the skb mark, whereas +previously mark=0 was used if the output mark was unspecified. In +mark-based routing schemes such as Android’s, this change in default +behavior causes routing loops or lookup failures. + +This patch restores the default behavior of using a 0 mark while still +incorporating the skb mark if the SET_MARK (and SET_MARK_MASK) is +specified. + +Tested with additions to Android's kernel unit test suite: +https://android-review.googlesource.com/c/kernel/tests/+/860150 + +Fixes: 9b42c1f179a6 ("xfrm: Extend the output_mark to support input direction and masking") +Signed-off-by: Benedict Wong +Signed-off-by: Steffen Klassert +Signed-off-by: Greg Kroah-Hartman + +--- + net/xfrm/xfrm_policy.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +--- a/net/xfrm/xfrm_policy.c ++++ b/net/xfrm/xfrm_policy.c +@@ -1628,7 +1628,10 @@ static struct dst_entry *xfrm_bundle_cre + dst_copy_metrics(dst1, dst); + + if (xfrm[i]->props.mode != XFRM_MODE_TRANSPORT) { +- __u32 mark = xfrm_smark_get(fl->flowi_mark, xfrm[i]); ++ __u32 mark = 0; ++ ++ if (xfrm[i]->props.smark.v || xfrm[i]->props.smark.m) ++ mark = xfrm_smark_get(fl->flowi_mark, xfrm[i]); + + family = xfrm[i]->props.family; + dst = xfrm_dst_lookup(xfrm[i], tos, fl->flowi_oif, -- 2.47.3