Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2942322pxb; Sun, 28 Feb 2021 19:24:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzpznpiobHrih+XW3q+8OyaalsHxbOr5kDIMLIUyPpvFr8K9SFPWl57fKFx7XtMbcgxBhjf X-Received: by 2002:a17:906:384e:: with SMTP id w14mr13836827ejc.285.1614569040134; Sun, 28 Feb 2021 19:24:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614569040; cv=none; d=google.com; s=arc-20160816; b=UTRePwuHKDb4Xi8RgC8oUwv5TMTIz1agSGCgAv9wAvGH7t1bNSuL9vePptR8gbgHL/ 3Gy8Cg2dRCbrQmsNRDtkvqwKTMwGVl1QDhmcSpa2WHN+CbDfFVPSGEmHaHpUpA1cJai0 iulgs+RNCukeCNjUxNJTSaPFjgVldcHfhq0PdqrWU6xIlcrOQYnA0AiP8w1MTyqzlFwy IIWLA7R8jy2iqdq+kSvGldDUAY58xIiTR8parpz0UV0QO/+JTC+P8HYylfFF6yqIpOft ReBMZ0CPBgH+rIhpz3Q6PmhZsRKcbsqePv6RIK3y1vWQ5QoXKF4wAj0F5D02MyoDPFk0 /H8w== 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=M8G2+CN+YMoHfYESjF/k2FmZzE1q849m2KdrYyZfZY/u+6NJuF7XhKsubLPv++Pfmn Yd3qum4xMXRXcF+eF4tw/Hn4IAn17b47EfXmMfiL4Bpc2UautQYEIeqK0jDfsgTc9hpv 6CWWyzodmOkijvb8lexX9BKRBsdHuzgmUmUVchoCjbMENcAlmxwuwJ+Ycen0GjI2cdjI euI0d3TvWOSEayRyMtlkOmfQwHumv33pyBGTYb3THM3Gu/Bw6Xx12XEDbyXLmM+WCWxT eNWXqVt9XCJG2AS4yn13OGXFeqqPI7iuUSJZ7NJ4J24w3MyY86p0BLqdZsJSWGM9xR/O BEew== 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 z3si10347800edp.327.2021.02.28.19.23.25; Sun, 28 Feb 2021 19:24:00 -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 S231804AbhCACSZ (ORCPT + 99 others); Sun, 28 Feb 2021 21:18:25 -0500 Received: from mx2.suse.de ([195.135.220.15]:58470 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231802AbhCACSY (ORCPT ); Sun, 28 Feb 2021 21:18:24 -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 BC4D1AE65; Mon, 1 Mar 2021 02:17:43 +0000 (UTC) From: NeilBrown To: Steve Dickson Date: Mon, 01 Mar 2021 13:17:15 +1100 Subject: [PATCH 1/5] mountd: reject unknown client IP when !use_ipaddr. Cc: Linux NFS Mailing list Message-ID: <161456503507.22801.16112597025827774254.stgit@noble> In-Reply-To: <161456493684.22801.323431390819102360.stgit@noble> References: <161456493684.22801.323431390819102360.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);