From patchwork Fri Apr 16 09:00:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 12207179 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FC64C4363F for ; Fri, 16 Apr 2021 09:01:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC7DF611AB for ; Fri, 16 Apr 2021 09:01:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240811AbhDPJB2 (ORCPT ); Fri, 16 Apr 2021 05:01:28 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:47315 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240742AbhDPJB2 (ORCPT ); Fri, 16 Apr 2021 05:01:28 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 7EAF35C0091; Fri, 16 Apr 2021 05:00:59 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 16 Apr 2021 05:00:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=date :from:to:cc:subject:message-id:mime-version:content-type; s=fm3; bh=4G80WgmZrbsLqASm8aHcQf2WuAVQOoavTsGWfKDN3yk=; b=jU6jt2ExiDvQ nPE+WGQvl9IioVFiy3faviG50IBqiTC69YPcZBP6FSvLVhCy7NT1pCRNzCy5n09X 0QKma1nPsSLokgARrp8iEGLDrESPFGJICASgpY9GIEuiyvycvp1q0mhnqiba3lOn zyIAF579zCBNgivB+/iP1MHGEQGB3Hnp0hVLBkpC4kGtLJ/VnRzg8uhniVpVDEJW zaOeSn2NT5JJekhDXyqGdAQJziFzVTBYpgirwCjlYZntRKglNuJX0YGks6ja5NHX ZPWfL9Pli+D5n8KNmT0i2fyNC3L2MIWUfcQRk/Kz2Gf/ZzpBKwuRyjyr1sV3ZkAj B58LsDlI/Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=4G80WgmZrbsLqASm8aHcQf2WuAVQO oavTsGWfKDN3yk=; b=tsKzSGoJrffLkr2/D3X8Wy/k8yNGMBiAS8q2AltvU30Ym wU7UtjORbi7daZBsZOfWsZ63oWkn/f3sqkguYsQJQ4FoqlRnCcDi3w/TuA4eaD4U ErmEPv/PibBY2GVR1KVYXFEY1oP3qJAcu4PWwOkhC5R1gsiNYID/koV5ghlUDjQS sbfoFLeyrs1KAr878MKQu8VBMGFgv/S9WT7BTD6pIbuvbdsgBgyltmsr3X4NNM8b ED7xYse0GcZYUt73IkS2HUqJ7k67GArzw9zQYsJOQatcIy1Nsed39ufXqYrd3YXX IwCvlPRbmiwwjcQI8Yo5cNoIqirjnruDLK8XQwW6A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudelhedgudduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggusehgtderredttddvnecuhfhrohhmpefrrghtrhhitghk ucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtthgvrhhnpe ejieefvdeuleffgfejudffvdeghfeigfejgfdvvdefudevffefveffhffgkeeiffenucfk phepkeelrdduvddrfedtrddvfeeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Received: from vm-mail.pks.im (dynamic-089-012-030-238.89.12.pool.telefonica.de [89.12.30.238]) by mail.messagingengine.com (Postfix) with ESMTPA id 9ECDA108005B; Fri, 16 Apr 2021 05:00:58 -0400 (EDT) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id cfb4c39e (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 16 Apr 2021 09:00:50 +0000 (UTC) Date: Fri, 16 Apr 2021 11:00:49 +0200 From: Patrick Steinhardt To: linux-nfs@vger.kernel.org Cc: Trond Myklebust Subject: [PATCH] Fix `statx()` emulation breaking exports Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Ever since commit 76c21e3f (mountd: Check the stat() return values in match_fsid(), 2020-05-08), it wasn't possible to export filesystems on my musl based system anymore. The root cause of this is the innocuous-looking change to decide based on `errno` whether `is_mountpoint()` raised a real error or whether it simply didn't match. The issue is that `is_mountpoint()` transitively calls into our `xlstat()` wrapper, which either executes `statx()` if the system supports it or otherwise falls back to `fstatat()`. But if `statx()` is not supported, then we'll always first set `errno = ENOSYS` before calling `fstatat()`. So effectively, all systems which do not have `statx()` and whose `fstatat()` doesn't reset `errno` will cause us to end up with errno set to `ENOSYS`. Fix the issue by resetting `errno` before calling `fstatat()` in both `xlstat()` and `xstat()`. Fixes: 76c21e3f (mountd: Check the stat() return values in match_fsid(), 2020-05-08) Signed-off-by: Patrick Steinhardt --- support/misc/xstat.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/support/misc/xstat.c b/support/misc/xstat.c index a438fbcc..6f751f7f 100644 --- a/support/misc/xstat.c +++ b/support/misc/xstat.c @@ -85,6 +85,7 @@ int xlstat(const char *pathname, struct stat *statbuf) return 0; else if (errno != ENOSYS) return -1; + errno = 0; return fstatat(AT_FDCWD, pathname, statbuf, AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW); } @@ -95,6 +96,7 @@ int xstat(const char *pathname, struct stat *statbuf) return 0; else if (errno != ENOSYS) return -1; + errno = 0; return fstatat(AT_FDCWD, pathname, statbuf, AT_NO_AUTOMOUNT); }