Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1634467pxb; Thu, 4 Mar 2021 17:04:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrMfn/ILrG5e57QfeD7VA+M/eB8HyaqSk2GKOgaDf+6YdL0zQhqANuzxlUTQywv3BO79ZS X-Received: by 2002:a92:1a4a:: with SMTP id z10mr6276095ill.284.1614906279637; Thu, 04 Mar 2021 17:04:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614906279; cv=none; d=google.com; s=arc-20160816; b=qcMIwLxeOK4A4l3/oDgleNwYQ2xEHBd731IKraNy18U3nB5xbLHJAMRwg30RavMdYZ i4HKz0PChwIZ7IUs7UkIGzVpMsjgzdajHKf2T1d7ZSNREXE+VKo0bLwTHqAYJbRMp1GK d+v84yQvOnUDKctwblAv0Fy5vrzO3wzC0dMGLYi3kRL4GOKv+8HuUDuoQKf49TzIgJhC vXMRfHol27Kc7/vHDiHEYpT08ql3+WCwaHK0SZd6rRtSsxTpALxV7ckIz7RRYEk+z4Iw EiuXGegIc9hKQ/JVo7J6cbandwS5t0e08pyrwCtCD03uYC/zJXAeLbDNJm8IO0tX3cgZ yfXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:cc:subject:date:to :from; bh=IhXprFTKT89jZDfHlWuPFQooWKPWLEv7kE6orxGJKxE=; b=GNQrppIkPC+M1QJLNYDpBsRi25Rs1xplqKoCizPquO2r3UAJFc3UfV/Yq4bPpF1EUU WaJQFv9fYAi0/UZNCHDUVveFD+ES4aRj7tweM8OPjBiYgXNBLa5kKmSpH2JP2a+vg4j2 QrZflgETB5cU0Svg9e3foYXC4sX1IfBNUeaO7viP2M9NiWjIaQ4Mrwmam3CFISaLr4+H ho8VjUL9tv6pyb1+PQ4n4jSS30ueGbeapSobbIHHpIjSFFn6BXXX516hVZyqOpt93r/I BIlQeb7FdqcjXELghnrSUACaOp1CxLRF+dnWi8nR343A1wpar2QxfSm6IJpTfy3if4iF LX/A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v3si1002792jat.33.2021.03.04.17.04.26; Thu, 04 Mar 2021 17:04:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231359AbhCEAof (ORCPT + 99 others); Thu, 4 Mar 2021 19:44:35 -0500 Received: from mx2.suse.de ([195.135.220.15]:39284 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230408AbhCEAof (ORCPT ); Thu, 4 Mar 2021 19:44:35 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 272E3AEC3; Fri, 5 Mar 2021 00:44:34 +0000 (UTC) From: NeilBrown To: Steve Dickson Date: Fri, 05 Mar 2021 11:43:23 +1100 Subject: [PATCH 1/7] mountd: reject unknown client IP when !use_ipaddr. Cc: Linux NFS Mailing list Message-ID: <161490500398.15291.17202034046729749702.stgit@noble> In-Reply-To: <161490464823.15291.13358214486203434566.stgit@noble> References: <161490464823.15291.13358214486203434566.stgit@noble> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: NeilBrown When use_ipaddr is not in effect, an auth_unix_ip lookup request from the kernel for an unknown client will be rejected. When it IS in effect, these requests are always granted with the IP address being mapped to a string form of the address, preceded by a '$'. This is inconsistent behaviour and could present a small information leak. It means that, for example, a SETCLIENT NFSv4 request may or may not succeed depending on an internal setting in rpc.mountd. This is easily rectified by always checking if the client is known. Signed-off-by: NeilBrown --- support/export/cache.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/support/export/cache.c b/support/export/cache.c index f1569afb558c..156ebfd4087c 100644 --- a/support/export/cache.c +++ b/support/export/cache.c @@ -114,6 +114,7 @@ static void auth_unix_ip(int f) char class[20]; char ipaddr[INET6_ADDRSTRLEN + 1]; char *client = NULL; + struct addrinfo *ai = NULL; struct addrinfo *tmp = NULL; char buf[RPC_CHAN_BUF_SIZE], *bp; int blen; @@ -139,21 +140,17 @@ static void auth_unix_ip(int f) auth_reload(); - /* addr is a valid, interesting address, find the domain name... */ - if (!use_ipaddr) { - struct addrinfo *ai = NULL; - - ai = client_resolve(tmp->ai_addr); - if (ai) { - client = client_compose(ai); - nfs_freeaddrinfo(ai); - } + /* addr is a valid address, find the domain name... */ + ai = client_resolve(tmp->ai_addr); + if (ai) { + client = client_compose(ai); + nfs_freeaddrinfo(ai); } bp = buf; blen = sizeof(buf); qword_add(&bp, &blen, "nfsd"); qword_add(&bp, &blen, ipaddr); qword_adduint(&bp, &blen, time(0) + DEFAULT_TTL); - if (use_ipaddr) { + if (use_ipaddr && client) { memmove(ipaddr + 1, ipaddr, strlen(ipaddr) + 1); ipaddr[0] = '$'; qword_add(&bp, &blen, ipaddr);