]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net/sunrpc: Fix return value for sysctl sunrpc.transports
authorArtur Molchanov <arturmolchanov@gmail.com>
Sun, 11 Oct 2020 22:00:45 +0000 (01:00 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Nov 2020 10:51:50 +0000 (11:51 +0100)
commit c09f56b8f68d4d536bff518227aea323b835b2ce upstream.

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
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/sunrpc/sysctl.c

index 999eee1ed61c9c0b694a03bbf3bc6b7ea1e53274..e81a28f30f1d24239cdd10cda0a63563cf4620c9 100644 (file)
@@ -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