Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7937916rwr; Wed, 10 May 2023 15:09:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ZrDzWz5FkHwbgdqKS5vER8JeWHYrQvTu6xur08g3rTudu4iG68qZJa9qFpXlV6au/tzyX X-Received: by 2002:a17:90b:1804:b0:24e:2759:8dbe with SMTP id lw4-20020a17090b180400b0024e27598dbemr23956675pjb.7.1683756552863; Wed, 10 May 2023 15:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683756552; cv=none; d=google.com; s=arc-20160816; b=thakINrjY28Atiq9gTgJflJ9yIeFXZ/uV1D9wfbLTd15LO99g5d41LcKASq+iWVqP8 c9jrgBYQcGU0ilgCSvwssZyRfCa1gAxprEZ7kofwQ0pus0wXexQIepcr1//77RkpV0HC sEET42+WqySye4OIoJnRzKoW0LmNhuzQqLhmf55A+YYTI3k7QlaYthOaEL0xYU8dJFUK dplxBd2DWyJTFicUCo+h/OGeNylcWhhHoavwF0u+ktsBO8smW1O+zXpBtVQPN4tfGRd/ 6QjdLoU8IO6D/NkIosEL92Bk9gCsjWuiblNZBE33gc3TaFrh6Tz2jaG+I/NfSJjcc06I qBOQ== 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:date:cc:to:from :subject:dkim-signature:dkim-signature; bh=J/e3rIshzrYg4pAK0dSAEbWV4SJAQMPKkivuMAu6Qxw=; b=UWE7Y9865OCfRFJt6oRJrxizpZD/ZyRBBj/UG8gqxkmk5lPRLgNTE24V1hdBK23H2U Sif7xa5knDAs/myRZ6174OLLm4CsKpY/Osq/LM0Cl+aonaKrIRW/Pmn4G264tOIT8zvp HEocSuix0Dw7w9+ckQ2JB3crCbPUcOL/KibWonVIomnJHb4uMN8N4ZDDBHQwZ7ozvjaX ZVua6r05Sy6hzdCRX67pp4ilBhVpYUxHzwXBjHtoUT0tANWaCjMXfS7W0g7XFXv0tVon jiMwsGBdGr+OBbVPG8qCMXIrcShWupNNQ7dX/nsNfZbSvKXZJOvLrMCuKKWMo9Xzsn6V 9SmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=qd7DU+Nk; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=Zo8Xls5L; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x7-20020a17090aca0700b0024dd8ed1373si18405972pjt.185.2023.05.10.15.08.59; Wed, 10 May 2023 15:09:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=qd7DU+Nk; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=Zo8Xls5L; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236361AbjEJWIM (ORCPT + 99 others); Wed, 10 May 2023 18:08:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236375AbjEJWIH (ORCPT ); Wed, 10 May 2023 18:08:07 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11E206189 for ; Wed, 10 May 2023 15:08:05 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C04A71FD6B; Wed, 10 May 2023 22:08:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1683756483; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J/e3rIshzrYg4pAK0dSAEbWV4SJAQMPKkivuMAu6Qxw=; b=qd7DU+NkPZ7J0U5viyzukzL2hC95usTnLeAG0+ETe3b5oufZitnUYY+MYciEnjDm7YxoRV 04wjmuoi6hN6Nn5s4WDV2obJoCxj71tRXV8qOnnRSKAIYbQ9QHK4mWpLhv9pSeDV8hiKfd UdJ2tIeBWnMhRaPQqnaa6dj9kx7RHoc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1683756483; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J/e3rIshzrYg4pAK0dSAEbWV4SJAQMPKkivuMAu6Qxw=; b=Zo8Xls5LwZs+tjJ5IJgBndJArwcLDBJxE1kLvc/biBV0k7XTyXHGM3hJ5t5YvauAVjQl/Q nzCRJH4UndQ9l3Ag== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A51C213519; Wed, 10 May 2023 22:08:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id aG6TFsEVXGTqBAAAMHmgww (envelope-from ); Wed, 10 May 2023 22:08:01 +0000 Subject: [PATCH 1/2] SUNRPC: support abstract unix socket addresses From: NeilBrown To: Jeff Layton , Trond Myklebust Cc: linux-nfs@vger.kernel.org, Petr Vorel , Nikita Yushchenko , Steve Dickson Date: Thu, 11 May 2023 08:06:24 +1000 Message-ID: <168375638439.26246.18054236712842151913.stgit@noble.brown> In-Reply-To: <168375610447.26246.3237443941479930060.stgit@noble.brown> References: <168375610447.26246.3237443941479930060.stgit@noble.brown> User-Agent: StGit/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org An "abtract" address for an AF_UNIX socket start with a nul and can contain any bytes for the given length, but traditionally doesn't contain other nuls. When reported, the leading nul is replaced by '@'. sunrpc currently rejects connections to these addresses and reports them as an empty string. To provide support for future use of these addresses, allow them for outgoing connections and report them more usefully. Signed-off-by: NeilBrown --- net/sunrpc/clnt.c | 8 ++++++-- net/sunrpc/xprtsock.c | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index d2ee56634308..18f70854f528 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -565,8 +565,12 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args) servername[0] = '\0'; switch (args->address->sa_family) { case AF_LOCAL: - snprintf(servername, sizeof(servername), "%s", - sun->sun_path); + if (sun->sun_path[0]) + snprintf(servername, sizeof(servername), "%s", + sun->sun_path); + else + snprintf(servername, sizeof(servername), "@%s", + sun->sun_path+1); break; case AF_INET: snprintf(servername, sizeof(servername), "%pI4", diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 5f9030b81c9e..515328a8dafe 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -253,7 +253,12 @@ static void xs_format_common_peer_addresses(struct rpc_xprt *xprt) switch (sap->sa_family) { case AF_LOCAL: sun = xs_addr_un(xprt); - strscpy(buf, sun->sun_path, sizeof(buf)); + if (sun->sun_path[0]) { + strscpy(buf, sun->sun_path, sizeof(buf)); + } else { + buf[0] = '@'; + strscpy(buf+1, sun->sun_path+1, sizeof(buf)-1); + } xprt->address_strings[RPC_DISPLAY_ADDR] = kstrdup(buf, GFP_KERNEL); break; @@ -2858,7 +2863,7 @@ static struct rpc_xprt *xs_setup_local(struct xprt_create *args) switch (sun->sun_family) { case AF_LOCAL: - if (sun->sun_path[0] != '/') { + if (sun->sun_path[0] != '/' && sun->sun_path[0] != '\0') { dprintk("RPC: bad AF_LOCAL address: %s\n", sun->sun_path); ret = ERR_PTR(-EINVAL);