* [PATCH v2] net/sunrpc: Fix return value for sysctl sunrpc.transports
@ 2020-10-11 22:00 Artur Molchanov
2020-10-12 14:18 ` J. Bruce Fields
0 siblings, 1 reply; 2+ messages in thread
From: Artur Molchanov @ 2020-10-11 22:00 UTC (permalink / raw)
To: bfields, chuck.lever; +Cc: linux-nfs
Fix returning value for sysctl sunrpc.transports.
Return error code from sysctl proc_handler function proc_do_xprt instead of number of the written bytes.
Otherwise sysctl returns random garbage for this key.
Since v1:
- Handle negative returned value from memory_read_from_buffer as an error
Signed-off-by: Artur Molchanov <arturmolchanov@gmail.com>
Cc: stable@vger.kernel.org
---
net/sunrpc/sysctl.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c
index 999eee1ed61c..e81a28f30f1d 100644
--- a/net/sunrpc/sysctl.c
+++ b/net/sunrpc/sysctl.c
@@ -70,7 +70,13 @@ static int proc_do_xprt(struct ctl_table *table, int write,
return 0;
}
len = svc_print_xprts(tmpbuf, sizeof(tmpbuf));
- return memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len);
+ *lenp = memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len);
+
+ if (*lenp < 0) {
+ *lenp = 0;
+ return -EINVAL;
+ }
+ return 0;
}
static int
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] net/sunrpc: Fix return value for sysctl sunrpc.transports
2020-10-11 22:00 [PATCH v2] net/sunrpc: Fix return value for sysctl sunrpc.transports Artur Molchanov
@ 2020-10-12 14:18 ` J. Bruce Fields
0 siblings, 0 replies; 2+ messages in thread
From: J. Bruce Fields @ 2020-10-12 14:18 UTC (permalink / raw)
To: Artur Molchanov; +Cc: chuck.lever, linux-nfs
On Mon, Oct 12, 2020 at 01:00:45AM +0300, Artur Molchanov wrote:
> Fix returning value for sysctl sunrpc.transports.
> Return error code from sysctl proc_handler function proc_do_xprt instead of number of the written bytes.
> Otherwise sysctl returns random garbage for this key.
>
> Since v1:
> - Handle negative returned value from memory_read_from_buffer as an error
Thanks, applying for 5.10.--b.
>
>
> Signed-off-by: Artur Molchanov <arturmolchanov@gmail.com>
> Cc: stable@vger.kernel.org
> ---
> net/sunrpc/sysctl.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c
> index 999eee1ed61c..e81a28f30f1d 100644
> --- a/net/sunrpc/sysctl.c
> +++ b/net/sunrpc/sysctl.c
> @@ -70,7 +70,13 @@ static int proc_do_xprt(struct ctl_table *table, int write,
> return 0;
> }
> len = svc_print_xprts(tmpbuf, sizeof(tmpbuf));
> - return memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len);
> + *lenp = memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len);
> +
> + if (*lenp < 0) {
> + *lenp = 0;
> + return -EINVAL;
> + }
> + return 0;
> }
>
> static int
> --
> 2.20.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-12 14:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-11 22:00 [PATCH v2] net/sunrpc: Fix return value for sysctl sunrpc.transports Artur Molchanov
2020-10-12 14:18 ` J. Bruce Fields
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).