lkml.org 
[lkml]   [2021]   [Jan]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.4 70/76] net: sunrpc: interpret the return value of kstrtou32 correctly
    Date
    From: j.nixdorf@avm.de <j.nixdorf@avm.de>

    commit 86b53fbf08f48d353a86a06aef537e78e82ba721 upstream.

    A return value of 0 means success. This is documented in lib/kstrtox.c.

    This was found by trying to mount an NFS share from a link-local IPv6
    address with the interface specified by its index:

    mount("[fe80::1%1]:/srv/nfs", "/mnt", "nfs", 0, "nolock,addr=fe80::1%1")

    Before this commit this failed with EINVAL and also caused the following
    message in dmesg:

    [...] NFS: bad IP address specified: addr=fe80::1%1

    The syscall using the same address based on the interface name instead
    of its index succeeds.

    Credits for this patch go to my colleague Christian Speich, who traced
    the origin of this bug to this line of code.

    Signed-off-by: Johannes Nixdorf <j.nixdorf@avm.de>
    Fixes: 00cfaa943ec3 ("replace strict_strto calls")
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    net/sunrpc/addr.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    --- a/net/sunrpc/addr.c
    +++ b/net/sunrpc/addr.c
    @@ -185,7 +185,7 @@ static int rpc_parse_scope_id(struct net
    scope_id = dev->ifindex;
    dev_put(dev);
    } else {
    - if (kstrtou32(p, 10, &scope_id) == 0) {
    + if (kstrtou32(p, 10, &scope_id) != 0) {
    kfree(p);
    return 0;
    }

    \
     
     \ /
      Last update: 2021-01-18 12:53    [W:4.270 / U:0.092 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site