From patchwork Fri Sep 22 04:12:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 143172 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5323366vqi; Thu, 21 Sep 2023 21:49:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqCd884qPIlsaDd7Kj2HccgFiRVmAKUkg9Bxrtif4ILISUVPaFnEXCrGIjTEzBTZ8Ck5Mu X-Received: by 2002:a17:90a:bd06:b0:263:4305:4e82 with SMTP id y6-20020a17090abd0600b0026343054e82mr7193955pjr.6.1695358172681; Thu, 21 Sep 2023 21:49:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695358172; cv=none; d=google.com; s=arc-20160816; b=Ff557uySqAEnIWrwhQizqzB0tKES+PtFmyUUDA3kT394v/6L54v8VGzcPnU5CMyztO jJ2HECaKSQxxeq++2flxvgvZcAg4V/Pj3vZ7Bqla6cPTxLoyyP1woYSLThW/MhYKBQuS JrWrxB9hIZOJ8fzICWZYSzgmFQiFECUGC6ep+6JhyVPDYjkdJ6prMosubLAFtbk+6iY/ VePe/h3FIQu+r29SSDyBA2p6aFtd6GIBNTZMiCbZ4kJ1Mg7PZt+adwdZ539f/7+fDHln HZYAUsEyoWD9z61rf5IyoA6ryaDldOOtbG23MZBn8UsHutLDl3M7fOpmn0RUWuMxkDU+ MaUg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=Orfn+zsuM68FHIsSvumK/hPQ+xdBHw1ePrGBE2OK2hE=; fh=tOzwWtfY/Ihw0ZG9uDufqX7N1fYPvJMmg28cxm4BgX4=; b=iQH5aEID5m3cR4Z66xqknpL/6cMk+dfsuaTEj/cv6JIzUYeOzLDjjjoADovJ3OnZ1v n6u7tjxjg6NE1I+f1GceZm3WG5Q0ee8AspxQcsiykLUgkQVqAgTxiYG5FLgPWw20Ja9V q7z06lvspEs7Job+SdcGEltY0tmmPhy2KILkaR+s6NAq6waGC05RA+Xei82GHIYMU9dO 55eRQvIIPhjH+OhgX9b8yP/dMMV1NFmOK5uvEZ4GPaNf7KfDU0y91iS/0TlzTswciAXX sptqSYr4Grg2cBURKGwOY0+zi1txTQX3iM8sEaGkladnvwKCC/3CRlfzqOhIQeF6uf6Z Hpzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@themaw.net header.s=fm1 header.b=NKYYXYpo; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=jGrLgkJV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id bf18-20020a17090b0b1200b0026b6a7d9e43si3033787pjb.14.2023.09.21.21.49.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 21:49:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@themaw.net header.s=fm1 header.b=NKYYXYpo; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=jGrLgkJV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 645EF8370877; Thu, 21 Sep 2023 21:12:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229476AbjIVEMr (ORCPT + 30 others); Fri, 22 Sep 2023 00:12:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbjIVEMm (ORCPT ); Fri, 22 Sep 2023 00:12:42 -0400 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D93FE197; Thu, 21 Sep 2023 21:12:36 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 4996C5C0222; Fri, 22 Sep 2023 00:12:36 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Fri, 22 Sep 2023 00:12:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=themaw.net; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1695355956; x= 1695442356; bh=Orfn+zsuM68FHIsSvumK/hPQ+xdBHw1ePrGBE2OK2hE=; b=N KYYXYpo+MooxRerSaDOtajao5gkfFD5+zVqKlWdG3i+MqOgNeleLoTf1ioTDWBt4 cLK1j77m9Kdl7lANkCB3XjzMkkHgs09hQO/JcgM90sLFjwyU7mtDsKZLH57y5Biw S6M6OJNKHwveFhh96Ldm3jtawickWqkZGzyb25UMboFLQyvKGmy9qFXNw7y8G8xQ pZc9iH5X8mFKGedwMfqVULjHjP7YgQ0MLLViGAlNvs5lhTLbQcE+zYA3F/J8s0xC L0aZz9Is7EoVd3l1bVMU8XAn5m317X6B3IDcWz7hvR+K3ERjrZ4y8pBXJTMqrvak SSbHhFScEWBauYveVkzEA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1695355956; x= 1695442356; bh=Orfn+zsuM68FHIsSvumK/hPQ+xdBHw1ePrGBE2OK2hE=; b=j GrLgkJVgl2gjOoYSv+olMjthDTifVDgMhEIPQfQkiLjFFb8IxesvOpYBcxAZVMiM GB42oY5qR29b72Y2Dd0sCXznDYB/HZhR5iHa4jbm2miBpHAd47H9L13hm+2zJK79 zRdeZepjDLFBErFzI41QiDO1eM7Qw5QVZDiI7koHTQgV4Mgdavz65OzIm6+IakC6 NeTeJcC0p5qJHfMjvDvJVpDk6zlSaKWGY0ISbetiIepW4GBWFRmYkslVDdU0qcXC Z0y1LhPPO5h9pIEp0b/O28CAXW5qJ0GMToFK4u6vy1jenpuuoLNQLCQMXnHFkyY4 vQWUoXvdMry/wUy5IP/nQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudekjedgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepkfgrnhcu mfgvnhhtuceorhgrvhgvnhesthhhvghmrgifrdhnvghtqeenucggtffrrghtthgvrhhnpe duleegueffgfehudeufedtffeiudfghfejgeehvdffgefgjeetvdfffeeihfdvveenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrrghvvghnse hthhgvmhgrfidrnhgvth X-ME-Proxy: Feedback-ID: i31e841b0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 22 Sep 2023 00:12:32 -0400 (EDT) From: Ian Kent To: Al Viro , Christian Brauner Cc: autofs mailing list , linux-fsdevel , Kernel Mailing List , Bill O'Donnell , Miklos Szeredi , David Howells , Ian Kent Subject: [PATCH 1/8] autofs: refactor autofs_prepare_pipe() Date: Fri, 22 Sep 2023 12:12:08 +0800 Message-ID: <20230922041215.13675-2-raven@themaw.net> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230922041215.13675-1-raven@themaw.net> References: <20230922041215.13675-1-raven@themaw.net> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 21 Sep 2023 21:12:50 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777711890803933921 X-GMAIL-MSGID: 1777711890803933921 Refactor autofs_prepare_pipe() by seperating out a check function to be used later. Signed-off-by: Ian Kent --- fs/autofs/autofs_i.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h index d5a44fa88acf..c24d32be7937 100644 --- a/fs/autofs/autofs_i.h +++ b/fs/autofs/autofs_i.h @@ -209,12 +209,20 @@ int autofs_fill_super(struct super_block *, void *, int); struct autofs_info *autofs_new_ino(struct autofs_sb_info *); void autofs_clean_ino(struct autofs_info *); -static inline int autofs_prepare_pipe(struct file *pipe) +static inline int autofs_check_pipe(struct file *pipe) { if (!(pipe->f_mode & FMODE_CAN_WRITE)) return -EINVAL; if (!S_ISFIFO(file_inode(pipe)->i_mode)) return -EINVAL; + return 0; +} + +static inline int autofs_prepare_pipe(struct file *pipe) +{ + int ret = autofs_check_pipe(pipe); + if (ret < 0) + return ret; /* We want a packet pipe */ pipe->f_flags |= O_DIRECT; /* We don't expect -EAGAIN */ From patchwork Fri Sep 22 04:12:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 143546 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5745977vqi; Fri, 22 Sep 2023 10:17:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGyF+w4wsLw1h4WU9eBfm7gLm/TjljzW7CjQiPnB+D0mIpCkKNX6YqcOzx0YGUX8+IPu44B X-Received: by 2002:a17:90a:aa92:b0:274:945b:6979 with SMTP id l18-20020a17090aaa9200b00274945b6979mr349970pjq.16.1695403066186; Fri, 22 Sep 2023 10:17:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695403066; cv=none; d=google.com; s=arc-20160816; b=aNeyL24u+/f513BF2s3gV3oh3WYSBjlFpHp2CAtvdGWNkgaNrRUSCvg3b/2EMvpOQf dNOGl58ovSfPgCJmnCvAHMNXs9d9Yu8fQZb742xxfHqVa4cLKgShO1evNroqENWtPceg nrcntG5/ee5ojjDFR9MD/fr4AxaQeEcYN/DsBQC4EvdRSdsmlgGI9+V5yiElEqhr7BQh B+YtrKUdP5oimUk7fhz9jeD+1CwFzLiDEpssC6IoIGHDHAxA4CFb81PqnMpS58eQpdif rSyx98OYuymI5wXqRqbZtfUo79OQK8dpu1UakeKBD0VxvJMGiagQWAC9++Yfjh0bvcQ0 f/AQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=TEE4wPYbAGeMVO1QHy+prEbJ3Oufz9n/qsrCMLuDzgw=; fh=tOzwWtfY/Ihw0ZG9uDufqX7N1fYPvJMmg28cxm4BgX4=; b=Id9mu4Hk7unUdhRVz/ylBcoRXyQQC4NCJWzva99KB0RYnCHgrXT+zba6yaV3YuYboZ wzmKEpI/ZwCNbpbL3l+IU29FrwDoYIzfu6UDS5zHcSLsJvmlw2AJu7XODRKlNrBL7gzX hur6Wtyg+nbDd/87U2cd2xKNYafuQ3c6U4Frdv3cR3eiL9RPSzzYXxpDVBsWvoZxrZKW veZDfoeBnVcmgyHTZW0Km78oBbQ+4R6tCrd+xoyqNUATcrcOJYaAvdBAOhp20xPlHR7c oAYe7r/GDONF1NTgR+Qz57saUa3DiPn51pMSjeyeN3idBfPVnUNFJw3kKX7dRSFLv2km sfcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@themaw.net header.s=fm1 header.b=cgl5DbRL; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=WO4KsBNG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id b19-20020a656693000000b005775e2f160fsi4091759pgw.667.2023.09.22.10.17.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:17:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@themaw.net header.s=fm1 header.b=cgl5DbRL; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=WO4KsBNG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 983B1826C0F3; Thu, 21 Sep 2023 21:12:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230036AbjIVEMu (ORCPT + 30 others); Fri, 22 Sep 2023 00:12:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229914AbjIVEMr (ORCPT ); Fri, 22 Sep 2023 00:12:47 -0400 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F5E5F1; Thu, 21 Sep 2023 21:12:41 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 9C9EE5C0220; Fri, 22 Sep 2023 00:12:40 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Fri, 22 Sep 2023 00:12:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=themaw.net; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1695355960; x= 1695442360; bh=TEE4wPYbAGeMVO1QHy+prEbJ3Oufz9n/qsrCMLuDzgw=; b=c gl5DbRL6MzFd65XO5QYfnFPKUxVhYJneFCKqnKkbCgy+oufi7CNdBNDWhDVuTWzK GH/1Kvhsm3B/4QLd6bSiaabSvfTmi4b61m5/hJ+HNbRJ20sXka1A18qdHF5ivcIB SwzYtWjvwC2NkX5+DS0iErFVV4/Ylu33AqlOJPCUaQEH7r7T8iDCU3hAccc6xnhi 72I2PvOYtIqIJ3Gy2Mm2bt3IlE8C9zJjTr1X3LcpDktBSmze2cJLgwUJ7pDTsG4F /DK42b6UNeDH10nD+bp5wpTd+wXDE0YLPxuzYIzcOjgcWXOCqj4qeP7Pb1mKhgrf 9L0Uv+WmbxxTgKCXNBvfw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1695355960; x= 1695442360; bh=TEE4wPYbAGeMVO1QHy+prEbJ3Oufz9n/qsrCMLuDzgw=; b=W O4KsBNGZS2HbK4nP/Kd1PJJiTM36U4rwr9q+u1unOLCrSqsrBvEnEIwsnt7M8InY vk5IY0trPh/D9iatU62R4yaG5a87ywiDUhHTbOK3VjzEl6DT2XexvGgm3tVQYymC VsAfwTog55ymgMcftYI24tfCMrG2tYqP48Zv4GHF/PsKUXudSv8BmV0Vt3JroAzx idb7HIUbbCaDUbrpxRITnHMhPPAquTW7NNX384HKtEl5zRs/09/1RTQbh/2KVylL DlRBZ4PDdY89AzuUWS1ZgN3FNNbioiX4ClVEQQjwMR5+pIOHdpvVpQ8Jw0qX+YlB x4UAnB+bC+Vp/IF/cezfw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudekjedgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepkfgrnhcu mfgvnhhtuceorhgrvhgvnhesthhhvghmrgifrdhnvghtqeenucggtffrrghtthgvrhhnpe duleegueffgfehudeufedtffeiudfghfejgeehvdffgefgjeetvdfffeeihfdvveenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrrghvvghnse hthhgvmhgrfidrnhgvth X-ME-Proxy: Feedback-ID: i31e841b0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 22 Sep 2023 00:12:36 -0400 (EDT) From: Ian Kent To: Al Viro , Christian Brauner Cc: autofs mailing list , linux-fsdevel , Kernel Mailing List , Bill O'Donnell , Miklos Szeredi , David Howells , Ian Kent Subject: [PATCH 2/8] autofs: add autofs_parse_fd() Date: Fri, 22 Sep 2023 12:12:09 +0800 Message-ID: <20230922041215.13675-3-raven@themaw.net> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230922041215.13675-1-raven@themaw.net> References: <20230922041215.13675-1-raven@themaw.net> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE, 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-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 21 Sep 2023 21:12:55 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777758965228507990 X-GMAIL-MSGID: 1777758965228507990 Factor out the fd mount option handling. Signed-off-by: Ian Kent --- fs/autofs/inode.c | 48 ++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index 2b49662ed237..e279e275b0a5 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c @@ -129,6 +129,33 @@ static const match_table_t tokens = { {Opt_err, NULL} }; +static int autofs_parse_fd(struct autofs_sb_info *sbi, int fd) +{ + struct file *pipe; + int ret; + + pipe = fget(fd); + if (!pipe) { + pr_err("could not open pipe file descriptor\n"); + return -EBADF; + } + + ret = autofs_check_pipe(pipe); + if (ret < 0) { + pr_err("Invalid/unusable pipe\n"); + fput(pipe); + return -EBADF; + } + + if (sbi->pipe) + fput(sbi->pipe); + + sbi->pipefd = fd; + sbi->pipe = pipe; + + return 0; +} + static int parse_options(char *options, struct inode *root, int *pgrp, bool *pgrp_set, struct autofs_sb_info *sbi) @@ -139,6 +166,7 @@ static int parse_options(char *options, int pipefd = -1; kuid_t uid; kgid_t gid; + int ret; root->i_uid = current_uid(); root->i_gid = current_gid(); @@ -162,7 +190,9 @@ static int parse_options(char *options, case Opt_fd: if (match_int(args, &pipefd)) return 1; - sbi->pipefd = pipefd; + ret = autofs_parse_fd(sbi, pipefd); + if (ret) + return 1; break; case Opt_uid: if (match_int(args, &option)) @@ -222,7 +252,6 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) { struct inode *root_inode; struct dentry *root; - struct file *pipe; struct autofs_sb_info *sbi; struct autofs_info *ino; int pgrp = 0; @@ -275,7 +304,6 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) ret = -ENOMEM; goto fail_ino; } - pipe = NULL; root->d_fsdata = ino; @@ -321,16 +349,7 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) pr_debug("pipe fd = %d, pgrp = %u\n", sbi->pipefd, pid_nr(sbi->oz_pgrp)); - pipe = fget(sbi->pipefd); - if (!pipe) { - pr_err("could not open pipe file descriptor\n"); - goto fail_put_pid; - } - ret = autofs_prepare_pipe(pipe); - if (ret < 0) - goto fail_fput; - sbi->pipe = pipe; sbi->flags &= ~AUTOFS_SBI_CATATONIC; /* @@ -342,11 +361,6 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) /* * Failure ... clean up. */ -fail_fput: - pr_err("pipe file descriptor does not contain proper ops\n"); - fput(pipe); -fail_put_pid: - put_pid(sbi->oz_pgrp); fail_dput: dput(root); goto fail_free; From patchwork Fri Sep 22 04:12:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 143192 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5338306vqi; Thu, 21 Sep 2023 22:33:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF82TCKUh7xKu3csL7cvgOUwKnBAQXGf/DvzkqVrhjoIs5q456kfj4+Xn7W+2nFxyQo3kiw X-Received: by 2002:a05:6a00:18a9:b0:68f:cdf3:dd54 with SMTP id x41-20020a056a0018a900b0068fcdf3dd54mr7792003pfh.9.1695360816162; Thu, 21 Sep 2023 22:33:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695360816; cv=none; d=google.com; s=arc-20160816; b=hC0ofaCou3iwN+BwMvUjaKv5MHE3LFjA/IoZY16F+H6FOjYf3HvvVYanUO/tBrrcCZ AMMmMUK/UEHbZtkL6WEytTKCO2Ss63JAdrYrWWk0LXWKaLhZHKK1h7eRAt+PT1fkBDfL 8E52n/wu9aNf9Lizib3MUW6U+yorPPeGfln6y/X0YPWjdmGH0Hmm1+SRH8rUJp2eB3v0 YKKp8/p5A5sNxfdolgcH8imUw1UFPVb7RvMVzX8a0vtEPQOnayGMyA9aCZzlEPs/2P0p cr//t+PBdOHQCXlbiDmPNNZvflZ820/s89OolvMxZ+P4mVymasRIJ8g9OvQYK3ZWH3M+ aH9A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=WbaN132An1pGGYu2OwYGx9AA8K508D+ik2jKmw/3K8c=; fh=tOzwWtfY/Ihw0ZG9uDufqX7N1fYPvJMmg28cxm4BgX4=; b=V3K6syhzS4MgssQ8ghYotw+IiYIeFVE7PF3G2Dn6ykK8zZ0KAqu65Fh+DHvn70LpQ2 fOKAu9xTKiiRdmGqjsjuva6zyp+da8DVyVz1umPelvbsIQJialTkhSxKrlqZgRZ7ChCm GiMFO1TPkoBGEndU+PIKQBEmz6gxPXrUyX7CaRGBKkKYuAjJbL4hmk+F89v5KjmiC35R JvbzViNwGXvCBoqWT650kji3yKbhJx08scFtb6SRTqFgro86jkM93knSKOcfRpstIZVX kQWxb7GETAloTQJgQdiuqLnSLMpO13GGQeGMZ2khbLPjHJUyMXJ9FcxMRiBsP2rRXvMf EiNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@themaw.net header.s=fm1 header.b=HzqjPsEF; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=jGUPW12f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id x7-20020a634847000000b0056c297d163csi2973305pgk.530.2023.09.21.22.33.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 22:33:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@themaw.net header.s=fm1 header.b=HzqjPsEF; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=jGUPW12f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id A99B480990EC; Thu, 21 Sep 2023 21:13:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230300AbjIVENG (ORCPT + 30 others); Fri, 22 Sep 2023 00:13:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230124AbjIVENA (ORCPT ); Fri, 22 Sep 2023 00:13:00 -0400 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D22F1A6; Thu, 21 Sep 2023 21:12:45 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 0151E5C0248; Fri, 22 Sep 2023 00:12:45 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Fri, 22 Sep 2023 00:12:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=themaw.net; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1695355964; x= 1695442364; bh=WbaN132An1pGGYu2OwYGx9AA8K508D+ik2jKmw/3K8c=; b=H zqjPsEFgQsMTX3cvZZnq+iJv81m9Iylso4uVo3DYw+7CsmpWoQeikVHmJ+MYFviM yNEzHomcixzheNwaOrfjI8StGrH919B3vYtn1lW+PyfWkKNguO+xSVUuFy9XnSbl Yumd/WneTgFjRCsG2hdWwCM6YXE5nestLNapL2kcenSpu4KHYDMSqEjj9Zjm57vw DeONTCe/oxjeS3w2klJybE1Isb/EMTLWzwQOtn5Bg2XfvStMixF4Sm6OyMO586zu n5pEuuvr3w8xJSAsk/LbMAWyzAXmr8IsmFjPHA62B3a1r0ats8X+YWYx1xCmE1fx 1cAGsdb3HzMhD/ETVWGfg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1695355964; x= 1695442364; bh=WbaN132An1pGGYu2OwYGx9AA8K508D+ik2jKmw/3K8c=; b=j GUPW12fWIFz2HJTEDeSYUuNkXycA4F5WxRqNKWC7gmrWuzTTTcffEo+bqQ6YAOaf M/0VuiAy2/BhbnCt83LfvYeIq+w7jdx3pArHokr1CWy1Uj+/axVzNn50q/1rbu6D nxvqi1wCXpa8y6r1PtIGAtlpb5cloJMAtWIVHFtqt6bL9A2aTn9DTGxeVtOVpVKY G8LHk0Q4FU6HWm+n7jDzzKHjg3KK21D8whA0KVSHXikZ8lVc2NsBh8NdHUR+lL+c Ilvto5gZANoD4l06PZuJ4ouIYKbI2hNgJF8/SwVhikM8mQmyiPZAfALmuZmVq27u I3qwwCdWIla2gA6KtO0Fw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudekjedgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepkfgrnhcu mfgvnhhtuceorhgrvhgvnhesthhhvghmrgifrdhnvghtqeenucggtffrrghtthgvrhhnpe duleegueffgfehudeufedtffeiudfghfejgeehvdffgefgjeetvdfffeeihfdvveenucev lhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpehrrghvvghnse hthhgvmhgrfidrnhgvth X-ME-Proxy: Feedback-ID: i31e841b0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 22 Sep 2023 00:12:40 -0400 (EDT) From: Ian Kent To: Al Viro , Christian Brauner Cc: autofs mailing list , linux-fsdevel , Kernel Mailing List , Bill O'Donnell , Miklos Szeredi , David Howells , Ian Kent Subject: [PATCH 3/8] autofs: refactor super block info init Date: Fri, 22 Sep 2023 12:12:10 +0800 Message-ID: <20230922041215.13675-4-raven@themaw.net> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230922041215.13675-1-raven@themaw.net> References: <20230922041215.13675-1-raven@themaw.net> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 21 Sep 2023 21:13:25 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777714663397257340 X-GMAIL-MSGID: 1777714663397257340 Move the allocation and initialisation of the super block info struct to its own function. Signed-off-by: Ian Kent --- fs/autofs/inode.c | 53 +++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index e279e275b0a5..992d6cb29707 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c @@ -171,11 +171,6 @@ static int parse_options(char *options, root->i_uid = current_uid(); root->i_gid = current_gid(); - sbi->min_proto = AUTOFS_MIN_PROTO_VERSION; - sbi->max_proto = AUTOFS_MAX_PROTO_VERSION; - - sbi->pipefd = -1; - if (!options) return 1; @@ -248,41 +243,49 @@ static int parse_options(char *options, return (sbi->pipefd < 0); } -int autofs_fill_super(struct super_block *s, void *data, int silent) +static struct autofs_sb_info *autofs_alloc_sbi(void) { - struct inode *root_inode; - struct dentry *root; struct autofs_sb_info *sbi; - struct autofs_info *ino; - int pgrp = 0; - bool pgrp_set = false; - int ret = -EINVAL; sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); if (!sbi) - return -ENOMEM; - pr_debug("starting up, sbi = %p\n", sbi); + return NULL; - s->s_fs_info = sbi; sbi->magic = AUTOFS_SBI_MAGIC; - sbi->pipefd = -1; - sbi->pipe = NULL; - sbi->exp_timeout = 0; - sbi->oz_pgrp = NULL; - sbi->sb = s; - sbi->version = 0; - sbi->sub_version = 0; sbi->flags = AUTOFS_SBI_CATATONIC; + sbi->min_proto = AUTOFS_MIN_PROTO_VERSION; + sbi->max_proto = AUTOFS_MAX_PROTO_VERSION; + sbi->pipefd = -1; + set_autofs_type_indirect(&sbi->type); - sbi->min_proto = 0; - sbi->max_proto = 0; mutex_init(&sbi->wq_mutex); mutex_init(&sbi->pipe_mutex); spin_lock_init(&sbi->fs_lock); - sbi->queues = NULL; spin_lock_init(&sbi->lookup_lock); INIT_LIST_HEAD(&sbi->active_list); INIT_LIST_HEAD(&sbi->expiring_list); + + return sbi; +} + +int autofs_fill_super(struct super_block *s, void *data, int silent) +{ + struct inode *root_inode; + struct dentry *root; + struct autofs_sb_info *sbi; + struct autofs_info *ino; + int pgrp = 0; + bool pgrp_set = false; + int ret = -EINVAL; + + sbi = autofs_alloc_sbi(); + if (!sbi) + return -ENOMEM; + + pr_debug("starting up, sbi = %p\n", sbi); + + sbi->sb = s; + s->s_fs_info = sbi; s->s_blocksize = 1024; s->s_blocksize_bits = 10; s->s_magic = AUTOFS_SUPER_MAGIC; From patchwork Fri Sep 22 04:12:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 143817 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:910f:0:b0:403:3b70:6f57 with SMTP id r15csp93813vqg; Fri, 22 Sep 2023 22:21:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGW2M+8uWkiCobtzoBv05CHrUyHzqu88y+B/jGsWWss0GPm12YVU+Utnt0tETbAu6ctKcrv X-Received: by 2002:a05:6e02:1088:b0:34c:a166:9866 with SMTP id r8-20020a056e02108800b0034ca1669866mr1614610ilj.4.1695446512573; Fri, 22 Sep 2023 22:21:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695446512; cv=none; d=google.com; s=arc-20160816; b=bJVQ4ujr0HJWzzqP/B0aSjiuNx8xxPSNf+sUlrnq17ElqNWFdgtiniOnxy6zSCU1lV Yp8+g9TfVbdGwC7Uga8g4EZ5Hj1xxwjuL6ELdr6m0OmfCwBdW4l65QklqGK4K3ucmKy/ d5Z7zC9ixnWOPiP6Utfzd1dSnsYod2/wQk/vZfbS7VDvRB+D5tVH3MdH1g0rbmXy6eXx 4IBFX/CR4aDhxak91HNigohjsE0u+1ULbXUImd/pdaWmEmSvupS/lyqb9VqaPWRfawg5 A0uMW+npzf+Zc8cVibmz9d/q+P4j306yrtLkTzpBJaaVU2avXeeisHWo++yY0VpENv+s 8vaA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=ryCXqbIXzg6S6gQUjvoPfXhRLeM6IuhwCFN5VCJzJFc=; fh=tOzwWtfY/Ihw0ZG9uDufqX7N1fYPvJMmg28cxm4BgX4=; b=eBBoG4suajCnYjQmvvdbm6lf+aMIEuBeVjXPPEviLd7XI181Lxnb3RsvSW8x2odNEo m9PUoeC8/1cngQsdv9MB3fEvMPPuMsIlJqK+prNvltb2gtLbdEq3u54OCZYeMs+IMxNR 9HlU9lHGYVf/0jAEQahumzB1aJBUElqXGyr8cPDfc/VFCvDLqQY2jIkSoPFUNYFvOBmd sYQfEVyrQXF2LMXAOlZo2KUvWITcHbnfofG0esUJ8tOFsrYhqFiG7VdCpudKxRQjy44h ez/uBmD8aJkxxyepoUopPZa1YARzlLZqygiJU6Mh4LE1wJgcEugFJ6r62gcOrO24xh3B 7NMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (expired) header.i=@themaw.net header.s=fm1 header.b=AQJ22VOo; dkim=neutral (expired) header.i=@messagingengine.com header.s=fm2 header.b=XzPj8XBt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id t185-20020a6381c2000000b0057744bb67dcsi5054083pgd.455.2023.09.22.22.21.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 22:21:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=neutral (expired) header.i=@themaw.net header.s=fm1 header.b=AQJ22VOo; dkim=neutral (expired) header.i=@messagingengine.com header.s=fm2 header.b=XzPj8XBt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B1133837309A; Thu, 21 Sep 2023 21:13:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229935AbjIVENL (ORCPT + 30 others); Fri, 22 Sep 2023 00:13:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbjIVEND (ORCPT ); Fri, 22 Sep 2023 00:13:03 -0400 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 450ACCC3; Thu, 21 Sep 2023 21:12:49 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 49AB95C0251; Fri, 22 Sep 2023 00:12:49 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Fri, 22 Sep 2023 00:12:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=themaw.net; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1695355969; x= 1695442369; bh=ryCXqbIXzg6S6gQUjvoPfXhRLeM6IuhwCFN5VCJzJFc=; b=A QJ22VOomJC0WZVbO0CwEOPShSyigDPVMPrsRKLnaEDOcf3JSYevhn0tGuLgL9TvP EQQvYm5xA0MKGgoFyc4MNdmyBkXT9ssgx5Gz61Om//QySzFtwPQBs7J4Vq+TQGKE 9BfX3tZE7ubgRZSvo/GL+tJNcfz8ZiW5/DiifY6caxitzl55pMGwb/oSeW6vF99W iFQogkGgkb8OvdaDicWU15foke8vUcI8zFJPkWVPSvJMGmUhD93QRK4XKUIbj4kY qk9bMa3j5Arg15+NSyJMmF99e3/tikxwzTk1ypXobQ1MzXhpMHsE+XF+bEIEkEcy vawxBu5ILeLXOS5H8WfgA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1695355969; x= 1695442369; bh=ryCXqbIXzg6S6gQUjvoPfXhRLeM6IuhwCFN5VCJzJFc=; b=X zPj8XBtqSEcH359KhBDLDTJ4lr3B+eObBDUY4RUL1LwWdn53BwlNUQiGwpN2cFi/ EUIQ52MR5QF92UdJSxySibGePcy/xyIplfL6PLgJMOijM+z9AyG+k1mF+N72wTvp BZKd4cyUiuJtBUPfujAyEhVQR7RLeM5peY+HyXpYIVQ4lPHnjDlrZcw7nnYvxIpd JbiGc3Ps50s6akEdr7YBwyb1x0UbVuZe1s9l8aIEmCpK9nde/clAWW/GqyNFbPJT rIiy01WYrp5YzcaofTaolKrXhaDOnCZQ3TLBrE7+Q1Ba2ceMNyHQo8IhEQFLcal6 v3FlSzloinL89kPzGFrBA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudekjedgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepkfgrnhcu mfgvnhhtuceorhgrvhgvnhesthhhvghmrgifrdhnvghtqeenucggtffrrghtthgvrhhnpe duleegueffgfehudeufedtffeiudfghfejgeehvdffgefgjeetvdfffeeihfdvveenucev lhhushhtvghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrrghvvghnse hthhgvmhgrfidrnhgvth X-ME-Proxy: Feedback-ID: i31e841b0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 22 Sep 2023 00:12:45 -0400 (EDT) From: Ian Kent To: Al Viro , Christian Brauner Cc: autofs mailing list , linux-fsdevel , Kernel Mailing List , Bill O'Donnell , Miklos Szeredi , David Howells , Ian Kent Subject: [PATCH 4/8] autofs: reformat 0pt enum declaration Date: Fri, 22 Sep 2023 12:12:11 +0800 Message-ID: <20230922041215.13675-5-raven@themaw.net> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230922041215.13675-1-raven@themaw.net> References: <20230922041215.13675-1-raven@themaw.net> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 21 Sep 2023 21:13:24 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777804522134700663 X-GMAIL-MSGID: 1777804522134700663 The enum of options is only reformated in the patch to convert autofs to use the mount API so do that now to simplify the conversion patch. Signed-off-by: Ian Kent --- fs/autofs/inode.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index 992d6cb29707..d2b333c0682a 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c @@ -110,9 +110,20 @@ static const struct super_operations autofs_sops = { .evict_inode = autofs_evict_inode, }; -enum {Opt_err, Opt_fd, Opt_uid, Opt_gid, Opt_pgrp, Opt_minproto, Opt_maxproto, - Opt_indirect, Opt_direct, Opt_offset, Opt_strictexpire, - Opt_ignore}; +enum { + Opt_err, + Opt_direct, + Opt_fd, + Opt_gid, + Opt_ignore, + Opt_indirect, + Opt_maxproto, + Opt_minproto, + Opt_offset, + Opt_pgrp, + Opt_strictexpire, + Opt_uid, +}; static const match_table_t tokens = { {Opt_fd, "fd=%u"}, From patchwork Fri Sep 22 04:12:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 143315 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5446376vqi; Fri, 22 Sep 2023 03:02:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHe9UdNKMxG6aZ1s6c5Sh11SZhdyStI46w1Tl0zmfYyqXN9HI911Z80XK8mXwOVQCdWHFUm X-Received: by 2002:a05:6808:1304:b0:3ae:2850:b481 with SMTP id y4-20020a056808130400b003ae2850b481mr164737oiv.17.1695376960269; Fri, 22 Sep 2023 03:02:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695376960; cv=none; d=google.com; s=arc-20160816; b=XLLtGS89PjFIiiXB3PB8x9l6saM8EuPx6tplb2Kx1/Eo1w4LNYY49bYJ51tsrQr8Nl npIJ0CL2orGvkn4uHxtwwbtwPOkQ0bVF6tpVk6ciHjfJ0T52Sm7ll4BJmCKfUHrYh8Yb UKofCVrRjiL8olKhzwAtypsi+NUTjsWJvurHLc5SAclwvYhbyXVhpJKqqg91hkD/L80Z lXuTSpgHAnsd+XOiyycGVQEYGH9jP+PfqjYH8Sstl/jg4lrCHBcAqSfSbMfaI2u4x/d+ r1Qwd8OMUTVOPm6NnRvS4dgcSyAJh4hhQxj1H7r8Tww9jWt9zXwfy1aQeMii3dF3lPf8 dtpA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=F3KK0azHrvJ3S4DAAH+Vjr5j2tc3bC5JP4rnLJ/SSuQ=; fh=tOzwWtfY/Ihw0ZG9uDufqX7N1fYPvJMmg28cxm4BgX4=; b=AhUprIF152Pnai72DuPo6Z8scXX+lrGQWX2L+BflOKY5ZAYgUqDIrk6m4EWUEWxDEy 4rw+JyExu8r4M4Ergtg54OQmTFeRBhDbkPiiqwia08/1v/rMLc4aBxjlZXMnR75QMB1M AtQYeCJsgLaK53M4a1rjOaQhJnsKaRkZdxhtnH9mtnjZm+IKyVzw0/np1cbf9regqklb 4ndwnO0Mmd010JEOlQuYv32Pi3w3eS6tQgdSlrf7+VPdn/jymp7BwCBrpM0bY5ya2UBK H6SEroJEs13EB4+TWHS2HHs5WedEUBIKQm5fc7V5eICj8pvqhKuXND67LpeAexyE6mUN cT5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@themaw.net header.s=fm1 header.b=H81IOwlm; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=QB6lMBWA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id e191-20020a6369c8000000b00578b9314261si3310167pgc.437.2023.09.22.03.02.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 03:02:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@themaw.net header.s=fm1 header.b=H81IOwlm; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=QB6lMBWA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id CAAB682DDF93; Thu, 21 Sep 2023 21:13:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231129AbjIVENd (ORCPT + 30 others); Fri, 22 Sep 2023 00:13:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230330AbjIVENG (ORCPT ); Fri, 22 Sep 2023 00:13:06 -0400 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47CA2100; Thu, 21 Sep 2023 21:12:54 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 979565C0232; Fri, 22 Sep 2023 00:12:53 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 22 Sep 2023 00:12:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=themaw.net; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1695355973; x= 1695442373; bh=F3KK0azHrvJ3S4DAAH+Vjr5j2tc3bC5JP4rnLJ/SSuQ=; b=H 81IOwlmkYtrJv8vDJiJPq3FUWLzvvHTxbiNPTDq0W7MLhClHzD0FDTF97QQ/hEa6 t6oMaretIz/pM5ahS1WPK6VzGXSnDaAd5qWKzvbxAUDqMGo9/abhpfkk8DGha1Vn zxQOY9wjBTWqt0ADZ2aXskleKXZkFaHHKRQb/zMvSstd1GFpskOjHQA786wCw3VE 4p0B+0tYXcYZF69lni/XJgfRMAFnSYkMpXAu69uxz3Do1G0jZp2AjV8hDfWKQ7fn D/DYYA06n/kasIUl/tkaY/xgdqWs5RuVEiNbs6/Sgz9V/gdAhq42UV17PZ5eGcZ2 WIdgwLiX5eW8NmkWlyG+g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1695355973; x= 1695442373; bh=F3KK0azHrvJ3S4DAAH+Vjr5j2tc3bC5JP4rnLJ/SSuQ=; b=Q B6lMBWAVWbjSzSoaiiNPaalZYj62ulHn2Gxy2ayy0kW2PC1HKCEWiEXSYpl14UwQ hi+UChcd8IwnANXXsdUzYjnwyQv9iO/iAsgg2jDnxbLTzzja+n34VqPK3MNw1z5w 5mhkiAhiwL/UneFstCgPUH9hs86mh8F55ycx1ZAi2IEr8cAy1o0k2GugWSEOFO5I QmjRXGazQifIWXCGvu9S+S35PoFi1uStX8ATCEsX0DYcOnj0k+BS7xXcI0thN3LG avN1oowNGbdzTEuKGUnX9xXbJaztzBkwT2XLBoFboUfSjiejLgxKOzyMa5t5j4AV hDH0vhsA85vakhjTEzX3Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudekjedgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepkfgrnhcu mfgvnhhtuceorhgrvhgvnhesthhhvghmrgifrdhnvghtqeenucggtffrrghtthgvrhhnpe duleegueffgfehudeufedtffeiudfghfejgeehvdffgefgjeetvdfffeeihfdvveenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrrghvvghnse hthhgvmhgrfidrnhgvth X-ME-Proxy: Feedback-ID: i31e841b0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 22 Sep 2023 00:12:49 -0400 (EDT) From: Ian Kent To: Al Viro , Christian Brauner Cc: autofs mailing list , linux-fsdevel , Kernel Mailing List , Bill O'Donnell , Miklos Szeredi , David Howells , Ian Kent Subject: [PATCH 5/8] autofs: refactor parse_options() Date: Fri, 22 Sep 2023 12:12:12 +0800 Message-ID: <20230922041215.13675-6-raven@themaw.net> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230922041215.13675-1-raven@themaw.net> References: <20230922041215.13675-1-raven@themaw.net> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 21 Sep 2023 21:13:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777731591558385790 X-GMAIL-MSGID: 1777731591558385790 Seperate out parts of parse_options() that will match better the individual option processing used in the mount API to further simplify the upcoming conversion. Signed-off-by: Ian Kent --- fs/autofs/inode.c | 136 ++++++++++++++++++++++++---------------------- 1 file changed, 72 insertions(+), 64 deletions(-) diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index d2b333c0682a..5e061ce3ab8d 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c @@ -167,18 +167,84 @@ static int autofs_parse_fd(struct autofs_sb_info *sbi, int fd) return 0; } -static int parse_options(char *options, - struct inode *root, int *pgrp, bool *pgrp_set, - struct autofs_sb_info *sbi) +static int autofs_parse_param(char *optstr, struct inode *root, + int *pgrp, bool *pgrp_set, + struct autofs_sb_info *sbi) { - char *p; substring_t args[MAX_OPT_ARGS]; int option; int pipefd = -1; kuid_t uid; kgid_t gid; + int token; int ret; + token = match_token(optstr, tokens, args); + switch (token) { + case Opt_fd: + if (match_int(args, &pipefd)) + return 1; + ret = autofs_parse_fd(sbi, pipefd); + if (ret) + return 1; + break; + case Opt_uid: + if (match_int(args, &option)) + return 1; + uid = make_kuid(current_user_ns(), option); + if (!uid_valid(uid)) + return 1; + root->i_uid = uid; + break; + case Opt_gid: + if (match_int(args, &option)) + return 1; + gid = make_kgid(current_user_ns(), option); + if (!gid_valid(gid)) + return 1; + root->i_gid = gid; + break; + case Opt_pgrp: + if (match_int(args, &option)) + return 1; + *pgrp = option; + *pgrp_set = true; + break; + case Opt_minproto: + if (match_int(args, &option)) + return 1; + sbi->min_proto = option; + break; + case Opt_maxproto: + if (match_int(args, &option)) + return 1; + sbi->max_proto = option; + break; + case Opt_indirect: + set_autofs_type_indirect(&sbi->type); + break; + case Opt_direct: + set_autofs_type_direct(&sbi->type); + break; + case Opt_offset: + set_autofs_type_offset(&sbi->type); + break; + case Opt_strictexpire: + sbi->flags |= AUTOFS_SBI_STRICTEXPIRE; + break; + case Opt_ignore: + sbi->flags |= AUTOFS_SBI_IGNORE; + } + + return 0; +} + +static int parse_options(char *options, + struct inode *root, int *pgrp, bool *pgrp_set, + struct autofs_sb_info *sbi) +{ + char *p; + root->i_uid = current_uid(); root->i_gid = current_gid(); @@ -186,71 +252,13 @@ static int parse_options(char *options, return 1; while ((p = strsep(&options, ",")) != NULL) { - int token; - if (!*p) continue; - token = match_token(p, tokens, args); - switch (token) { - case Opt_fd: - if (match_int(args, &pipefd)) - return 1; - ret = autofs_parse_fd(sbi, pipefd); - if (ret) - return 1; - break; - case Opt_uid: - if (match_int(args, &option)) - return 1; - uid = make_kuid(current_user_ns(), option); - if (!uid_valid(uid)) - return 1; - root->i_uid = uid; - break; - case Opt_gid: - if (match_int(args, &option)) - return 1; - gid = make_kgid(current_user_ns(), option); - if (!gid_valid(gid)) - return 1; - root->i_gid = gid; - break; - case Opt_pgrp: - if (match_int(args, &option)) - return 1; - *pgrp = option; - *pgrp_set = true; - break; - case Opt_minproto: - if (match_int(args, &option)) - return 1; - sbi->min_proto = option; - break; - case Opt_maxproto: - if (match_int(args, &option)) - return 1; - sbi->max_proto = option; - break; - case Opt_indirect: - set_autofs_type_indirect(&sbi->type); - break; - case Opt_direct: - set_autofs_type_direct(&sbi->type); - break; - case Opt_offset: - set_autofs_type_offset(&sbi->type); - break; - case Opt_strictexpire: - sbi->flags |= AUTOFS_SBI_STRICTEXPIRE; - break; - case Opt_ignore: - sbi->flags |= AUTOFS_SBI_IGNORE; - break; - default: + if (autofs_parse_param(p, root, pgrp, pgrp_set, sbi)) return 1; - } } + return (sbi->pipefd < 0); } From patchwork Fri Sep 22 04:12:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 143193 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5341624vqi; Thu, 21 Sep 2023 22:43:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGpZjHakv/iBpMdDzIFGV3vfVCav+H6SCj7XUOWbbOjuW0K2Fl+LaRoSObS0HNM8xZNg49t X-Received: by 2002:a0d:cd85:0:b0:59c:aea:d877 with SMTP id p127-20020a0dcd85000000b0059c0aead877mr7291340ywd.40.1695361383286; Thu, 21 Sep 2023 22:43:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695361383; cv=none; d=google.com; s=arc-20160816; b=zlfa4SW8dt1Y2suEQLTBdiTJ4q2lM2dS4Hpi9Kvp0jmFCrEcktAy0w7J8h9/eCaJOj DwZmwAZV3GbF0oj45fOWxg+Owts7E8FWitlkrTUS3UhMqj2kv+Sm50okAO4MLVBMp4Vu q5tnU4z3givaPO536CFAgs2eytHiiJ1Z7bXFto/xEsSk3ZJDEUBUsmW3A8hnVSuxegxt D2C98dbbHlim3ND6GcdRVltu0BNSElbj/aeQvCKod4Ll45j7HSVmLfP81VMjydDd+q7M 6nePjOzcKZchMPhRk1lqY3sGFDMHJhVdrMIpRSOoy1Zq3cLqfx6tcXLVr1djWhpAHdVA PK/w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=1rBf/tENa8Po/M99DgSqwjUd7A6nMFydxVLGoW1DBxw=; fh=tOzwWtfY/Ihw0ZG9uDufqX7N1fYPvJMmg28cxm4BgX4=; b=i6TqkhyxcGm7Je5eaSnKhFOLN+W0sdnXC1K1+La7n0kupWvFNPcmd4yqAkaNRb+gA2 CrKnls7f7bCzGoX15sK8HBeuslN96o7zqguXYKsEJYBr6hwybPvowOZWQrbWmzLNvhkT MZiD5Fo3r6QFwIHISXc1TBnZanAyR/n97Z/BFIrIm0kLEefpwn4kaLBolbyhvlfBxZfN IlXDQBhZMZ7hoOkdoTNm1gCzCErj7BguCXRQOT6olcSzJ1V4BF66fO7MZtcaUhkhEV2v QxXMZmHPn2pWMtVsenM2GWVTssoX4O7E3W7cNUaPTGMqlsTJndMG78LhsoCBb7xEnO95 H2EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@themaw.net header.s=fm1 header.b=mZr0GwKd; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=LCj7AFu6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id l63-20020a638842000000b00578a9529cfasi2987369pgd.87.2023.09.21.22.43.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 22:43:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@themaw.net header.s=fm1 header.b=mZr0GwKd; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=LCj7AFu6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 5C74A83D4A78; Thu, 21 Sep 2023 21:14:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229802AbjIVENq (ORCPT + 30 others); Fri, 22 Sep 2023 00:13:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230461AbjIVENX (ORCPT ); Fri, 22 Sep 2023 00:13:23 -0400 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90BA41A3; Thu, 21 Sep 2023 21:12:58 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 061345C0222; Fri, 22 Sep 2023 00:12:58 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 22 Sep 2023 00:12:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=themaw.net; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1695355978; x= 1695442378; bh=1rBf/tENa8Po/M99DgSqwjUd7A6nMFydxVLGoW1DBxw=; b=m Zr0GwKdhkpe1LLNAYPe/pVq2UTvLZ0nFT4U5r4Rkk8bcpkT3T+aYfSEnMrk008uQ PLanhuWeVexXiwIzYYEpL9mQk0alBM6Y38DxJyGeisbJVsWYdA4FNqAQ9SqdM3Rb BDXnL6abA37CcV0xLnUnNZI3vcYV4pmvzWnBvGOwcyi5qKlh5whKhRMYZEGUMMXI TEz/cwbwvwN4gFvE1RLYR2j2vO5McwXkhifYpqJIm70+jgnKoecpNe2gIuCSCxnt xjhgM3yZ0cPJHvAQzzuzh/zgsevzGLuJcwSpVzBtDHrOFABM+yXKsMgMTukVubjQ dh3u6ZyF2FuShML9Ns2lQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1695355978; x= 1695442378; bh=1rBf/tENa8Po/M99DgSqwjUd7A6nMFydxVLGoW1DBxw=; b=L Cj7AFu6VB8QYslobSLTvwCkrvIZn6n4zN60yexHUeBwRJcTn/Cf2hU/9M/k2/heD iw3mM/gsCFV8R+N85xcR47mbtU4lwe38WyDcyCLIdLnH/UVzh3w58Kuvs4EDAPAh f9t0wM3lDIiZ7TV5sAHi++UP308NgjqknXOEbdjZfNUI0GutCRFHXcFs7oG/WzGv TkE1VLhnz4O/ETOD0YD02x94Nzxg+RZylN+blTowT67Z6kOkvO/RyjYqpWIlAzGb YtfLbfABQcLyfZlZdFLsDv9ZDQldAqh+u905kGMlHMfTFsC1Svoe3r268mO2Z0QV rAXZpurAlvt1zck2HuNlw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudekjedgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepkfgrnhcu mfgvnhhtuceorhgrvhgvnhesthhhvghmrgifrdhnvghtqeenucggtffrrghtthgvrhhnpe duleegueffgfehudeufedtffeiudfghfejgeehvdffgefgjeetvdfffeeihfdvveenucev lhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpehrrghvvghnse hthhgvmhgrfidrnhgvth X-ME-Proxy: Feedback-ID: i31e841b0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 22 Sep 2023 00:12:53 -0400 (EDT) From: Ian Kent To: Al Viro , Christian Brauner Cc: autofs mailing list , linux-fsdevel , Kernel Mailing List , Bill O'Donnell , Miklos Szeredi , David Howells , Ian Kent Subject: [PATCH 6/8] autofs: validate protocol version Date: Fri, 22 Sep 2023 12:12:13 +0800 Message-ID: <20230922041215.13675-7-raven@themaw.net> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230922041215.13675-1-raven@themaw.net> References: <20230922041215.13675-1-raven@themaw.net> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 21 Sep 2023 21:14:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777715257893273569 X-GMAIL-MSGID: 1777715257893273569 Move the protocol parameter validation into a seperate function. Signed-off-by: Ian Kent --- fs/autofs/inode.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index 5e061ce3ab8d..e2026e063d8c 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c @@ -287,6 +287,28 @@ static struct autofs_sb_info *autofs_alloc_sbi(void) return sbi; } +static int autofs_validate_protocol(struct autofs_sb_info *sbi) +{ + /* Test versions first */ + if (sbi->max_proto < AUTOFS_MIN_PROTO_VERSION || + sbi->min_proto > AUTOFS_MAX_PROTO_VERSION) { + pr_err("kernel does not match daemon version " + "daemon (%d, %d) kernel (%d, %d)\n", + sbi->min_proto, sbi->max_proto, + AUTOFS_MIN_PROTO_VERSION, AUTOFS_MAX_PROTO_VERSION); + return -EINVAL; + } + + /* Establish highest kernel protocol version */ + if (sbi->max_proto > AUTOFS_MAX_PROTO_VERSION) + sbi->version = AUTOFS_MAX_PROTO_VERSION; + else + sbi->version = sbi->max_proto; + sbi->sub_version = AUTOFS_PROTO_SUBVERSION; + + return 0; +} + int autofs_fill_super(struct super_block *s, void *data, int silent) { struct inode *root_inode; @@ -335,22 +357,8 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) goto fail_dput; } - /* Test versions first */ - if (sbi->max_proto < AUTOFS_MIN_PROTO_VERSION || - sbi->min_proto > AUTOFS_MAX_PROTO_VERSION) { - pr_err("kernel does not match daemon version " - "daemon (%d, %d) kernel (%d, %d)\n", - sbi->min_proto, sbi->max_proto, - AUTOFS_MIN_PROTO_VERSION, AUTOFS_MAX_PROTO_VERSION); + if (autofs_validate_protocol(sbi)) goto fail_dput; - } - - /* Establish highest kernel protocol version */ - if (sbi->max_proto > AUTOFS_MAX_PROTO_VERSION) - sbi->version = AUTOFS_MAX_PROTO_VERSION; - else - sbi->version = sbi->max_proto; - sbi->sub_version = AUTOFS_PROTO_SUBVERSION; if (pgrp_set) { sbi->oz_pgrp = find_get_pid(pgrp); From patchwork Fri Sep 22 04:12:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 143260 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5409396vqi; Fri, 22 Sep 2023 01:35:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqYsUB8rK6o4Llav3gyS4FPvBz2TxehtGYAoKgccXapVk8FsqAlrWZJ0evzf7I2FQa66FH X-Received: by 2002:a17:902:a9c6:b0:1bd:f69e:6630 with SMTP id b6-20020a170902a9c600b001bdf69e6630mr5747859plr.65.1695371707333; Fri, 22 Sep 2023 01:35:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695371707; cv=none; d=google.com; s=arc-20160816; b=B98SzoF5d045BZVN9BdfjEgZ5USrdhOi4afjgVEN51b/N6lrqqMxqrFzFCILUUYw4O JhKTk/EOVkuSXI6Bg91S+EQZU8IT8Z6+i7icsLXxM93YXpcpf8UqParPZGP+aHT7uWfS mURx5EMU8VY+Sesxg+by4YiJY7wnqMIX52REHf2OY+HmFhj0dDTM1JJkF7Agy7f2hf07 dGBzgVJs3Ko+JAf1j8E5AlYvprvx0BrMAPaQ165mKA9+70u2vg/wfBi0WEnR98VNxf8z 3Qn2mp/0hQtHbhhIqeMSv1vWzSOV2y4wH/5givCyhWv09LhN8Qg2ORkBvvazxcnJts6R 4iBg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=z60NMvoJr4KjeXqAhchaD4oFMo/nesmqYn0ND9WNzEI=; fh=tOzwWtfY/Ihw0ZG9uDufqX7N1fYPvJMmg28cxm4BgX4=; b=RIpzwOSQe/1RaYWe8RLEPJDwdvp8ZAN2VYcO3n0ccMkmhyY0OJxWcgYyyQvBKYUOWq 9wf46M9GMgqLBuFOuhkXXlP4lYpBxhmP8d8SKY7FnqQuusXluyQsiwMsrX0tRuau94ES uXEHIlEJWT/ZCAyjJIT/8SfLg+ePt7fmkIbjSrEakO3PfLmcSyi8nAU8PkS/0kJzkUBh XSgxFjtgd8hZbPuIA3WVycnMPE3VOUBQ94YdqE0qmlwgNCUMaxLPA58nQHywj1cBNnvg fPR8r8krQogg6n2qE+9/WaPEGIw4xbwNPcwhJMncKGusLFHmmUql/6NqBr9LhsamDKPl 5mrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@themaw.net header.s=fm1 header.b=TVH6kS1U; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="SMwt/K+2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id s17-20020a170902c65100b001b3d27ca12fsi3061918pls.207.2023.09.22.01.35.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 01:35:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@themaw.net header.s=fm1 header.b=TVH6kS1U; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="SMwt/K+2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 411E1832DCCB; Thu, 21 Sep 2023 21:14:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230500AbjIVEN5 (ORCPT + 30 others); Fri, 22 Sep 2023 00:13:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230321AbjIVENb (ORCPT ); Fri, 22 Sep 2023 00:13:31 -0400 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 117AA1B6; Thu, 21 Sep 2023 21:13:03 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 772025C023C; Fri, 22 Sep 2023 00:13:02 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Fri, 22 Sep 2023 00:13:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=themaw.net; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1695355982; x= 1695442382; bh=z60NMvoJr4KjeXqAhchaD4oFMo/nesmqYn0ND9WNzEI=; b=T VH6kS1UQ3Ztz6Vkf80AUUNO4hIUh1SdEm6iDT9iKv+3fMMarCtzey+btHFSDlaTF f4gBY9tHBxWxOfuu+916Mr1GOHnI7O5lGWOuoXqfpGsWALl6jsyvlaTcdkOylu/H 94mdwodhBLvjXaYPRsjJBQAGaDyV6TIeIRj67rWiJTwETeJ+WVrJ8c3AlWCCwkTB YZeaPa2k3wTGzzb+xoYPwnLFwOy8QUNIIOI7v0SY5yoSvDecMnrs30m87XYxnPlK rg77BDkjYqZhiUFovFKOxeOEesUsUAyeNqH+oDsb+rkV3IkKaenUr3of3yL7XwPK 3xCCQgN3PW1hLDch1NIdg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1695355982; x= 1695442382; bh=z60NMvoJr4KjeXqAhchaD4oFMo/nesmqYn0ND9WNzEI=; b=S Mwt/K+2KucqeUvKxCmkh0NaGdp/Oug+YJwMOfG9UIk0U5TptNPmYBrwrdARRhODJ /0HDFqu1Kx/tS7X7KyRdvs106sqWVP3GhVBGlX4Fdaf6w/jM2CCA8zACFvDy1sXo /gHDHt0DVUYOZ2O80DonHILedefEvwQAYU93OhvDS43/UZ0xtPsHsCchPiJAQXhF auSXhvLLmfulxNfldoHFmi1NGHOLAOgqBtltyJNJ7QsMzz1Nm3zQ6bifiOUclK/K 4hyNqKSlvhRJnCs8eBQ8UN2S3RzNAG5cWQ9gA9rh74jCNBpOkLs+hj8MnmUidCTq uXnLjLD6FuoGsUBHD3E+Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudekjedgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepkfgrnhcu mfgvnhhtuceorhgrvhgvnhesthhhvghmrgifrdhnvghtqeenucggtffrrghtthgvrhhnpe duleegueffgfehudeufedtffeiudfghfejgeehvdffgefgjeetvdfffeeihfdvveenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrrghvvghnse hthhgvmhgrfidrnhgvth X-ME-Proxy: Feedback-ID: i31e841b0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 22 Sep 2023 00:12:58 -0400 (EDT) From: Ian Kent To: Al Viro , Christian Brauner Cc: autofs mailing list , linux-fsdevel , Kernel Mailing List , Bill O'Donnell , Miklos Szeredi , David Howells , Ian Kent Subject: [PATCH 7/8] autofs: convert autofs to use the new mount api Date: Fri, 22 Sep 2023 12:12:14 +0800 Message-ID: <20230922041215.13675-8-raven@themaw.net> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230922041215.13675-1-raven@themaw.net> References: <20230922041215.13675-1-raven@themaw.net> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 21 Sep 2023 21:14:37 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777726083268492043 X-GMAIL-MSGID: 1777726083268492043 Convert the autofs filesystem to use the mount API. The conversion patch was originally written by David Howells. I have taken that patch and broken it into several patches in an effort to make the change easier to review. Signed-off-by: Ian Kent Signed-off-by: Christian Brauner --- fs/autofs/autofs_i.h | 5 +- fs/autofs/init.c | 9 +- fs/autofs/inode.c | 247 ++++++++++++++++++++++++------------------- 3 files changed, 142 insertions(+), 119 deletions(-) diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h index c24d32be7937..244f18cdf23c 100644 --- a/fs/autofs/autofs_i.h +++ b/fs/autofs/autofs_i.h @@ -25,6 +25,8 @@ #include #include #include +#include +#include /* This is the range of ioctl() numbers we claim as ours */ #define AUTOFS_IOC_FIRST AUTOFS_IOC_READY @@ -205,7 +207,8 @@ static inline void managed_dentry_clear_managed(struct dentry *dentry) /* Initializing function */ -int autofs_fill_super(struct super_block *, void *, int); +extern const struct fs_parameter_spec autofs_param_specs[]; +int autofs_init_fs_context(struct fs_context *fc); struct autofs_info *autofs_new_ino(struct autofs_sb_info *); void autofs_clean_ino(struct autofs_info *); diff --git a/fs/autofs/init.c b/fs/autofs/init.c index d3f55e874338..b5e4dfa04ed0 100644 --- a/fs/autofs/init.c +++ b/fs/autofs/init.c @@ -7,16 +7,11 @@ #include #include "autofs_i.h" -static struct dentry *autofs_mount(struct file_system_type *fs_type, - int flags, const char *dev_name, void *data) -{ - return mount_nodev(fs_type, flags, data, autofs_fill_super); -} - struct file_system_type autofs_fs_type = { .owner = THIS_MODULE, .name = "autofs", - .mount = autofs_mount, + .init_fs_context = autofs_init_fs_context, + .parameters = autofs_param_specs, .kill_sb = autofs_kill_sb, }; MODULE_ALIAS_FS("autofs"); diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index e2026e063d8c..3f2dfed428f9 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c @@ -6,7 +6,6 @@ #include #include -#include #include "autofs_i.h" @@ -111,7 +110,6 @@ static const struct super_operations autofs_sops = { }; enum { - Opt_err, Opt_direct, Opt_fd, Opt_gid, @@ -125,35 +123,48 @@ enum { Opt_uid, }; -static const match_table_t tokens = { - {Opt_fd, "fd=%u"}, - {Opt_uid, "uid=%u"}, - {Opt_gid, "gid=%u"}, - {Opt_pgrp, "pgrp=%u"}, - {Opt_minproto, "minproto=%u"}, - {Opt_maxproto, "maxproto=%u"}, - {Opt_indirect, "indirect"}, - {Opt_direct, "direct"}, - {Opt_offset, "offset"}, - {Opt_strictexpire, "strictexpire"}, - {Opt_ignore, "ignore"}, - {Opt_err, NULL} +const struct fs_parameter_spec autofs_param_specs[] = { + fsparam_flag ("direct", Opt_direct), + fsparam_fd ("fd", Opt_fd), + fsparam_u32 ("gid", Opt_gid), + fsparam_flag ("ignore", Opt_ignore), + fsparam_flag ("indirect", Opt_indirect), + fsparam_u32 ("maxproto", Opt_maxproto), + fsparam_u32 ("minproto", Opt_minproto), + fsparam_flag ("offset", Opt_offset), + fsparam_u32 ("pgrp", Opt_pgrp), + fsparam_flag ("strictexpire", Opt_strictexpire), + fsparam_u32 ("uid", Opt_uid), + {} }; -static int autofs_parse_fd(struct autofs_sb_info *sbi, int fd) +struct autofs_fs_context { + kuid_t uid; + kgid_t gid; + int pgrp; + bool pgrp_set; +}; + +/* + * Open the fd. We do it here rather than in get_tree so that it's done in the + * context of the system call that passed the data and not the one that + * triggered the superblock creation, lest the fd gets reassigned. + */ +static int autofs_parse_fd(struct fs_context *fc, int fd) { + struct autofs_sb_info *sbi = fc->s_fs_info; struct file *pipe; int ret; pipe = fget(fd); if (!pipe) { - pr_err("could not open pipe file descriptor\n"); + errorf(fc, "could not open pipe file descriptor"); return -EBADF; } ret = autofs_check_pipe(pipe); if (ret < 0) { - pr_err("Invalid/unusable pipe\n"); + errorf(fc, "Invalid/unusable pipe"); fput(pipe); return -EBADF; } @@ -167,58 +178,43 @@ static int autofs_parse_fd(struct autofs_sb_info *sbi, int fd) return 0; } -static int autofs_parse_param(char *optstr, struct inode *root, - int *pgrp, bool *pgrp_set, - struct autofs_sb_info *sbi) +static int autofs_parse_param(struct fs_context *fc, struct fs_parameter *param) { - substring_t args[MAX_OPT_ARGS]; - int option; - int pipefd = -1; + struct autofs_fs_context *ctx = fc->fs_private; + struct autofs_sb_info *sbi = fc->s_fs_info; + struct fs_parse_result result; kuid_t uid; kgid_t gid; - int token; - int ret; + int opt; - token = match_token(optstr, tokens, args); - switch (token) { + opt = fs_parse(fc, autofs_param_specs, param, &result); + if (opt < 0) + return opt; + + switch (opt) { case Opt_fd: - if (match_int(args, &pipefd)) - return 1; - ret = autofs_parse_fd(sbi, pipefd); - if (ret) - return 1; - break; + return autofs_parse_fd(fc, result.int_32); case Opt_uid: - if (match_int(args, &option)) - return 1; - uid = make_kuid(current_user_ns(), option); + uid = make_kuid(current_user_ns(), result.uint_32); if (!uid_valid(uid)) return 1; - root->i_uid = uid; + ctx->uid = uid; break; case Opt_gid: - if (match_int(args, &option)) - return 1; - gid = make_kgid(current_user_ns(), option); + gid = make_kgid(current_user_ns(), result.uint_32); if (!gid_valid(gid)) return 1; - root->i_gid = gid; + ctx->gid = gid; break; case Opt_pgrp: - if (match_int(args, &option)) - return 1; - *pgrp = option; - *pgrp_set = true; + ctx->pgrp = result.uint_32; + ctx->pgrp_set = true; break; case Opt_minproto: - if (match_int(args, &option)) - return 1; - sbi->min_proto = option; + sbi->min_proto = result.uint_32; break; case Opt_maxproto: - if (match_int(args, &option)) - return 1; - sbi->max_proto = option; + sbi->max_proto = result.uint_32; break; case Opt_indirect: set_autofs_type_indirect(&sbi->type); @@ -239,29 +235,6 @@ static int autofs_parse_param(char *optstr, struct inode *root, return 0; } -static int parse_options(char *options, - struct inode *root, int *pgrp, bool *pgrp_set, - struct autofs_sb_info *sbi) -{ - char *p; - - root->i_uid = current_uid(); - root->i_gid = current_gid(); - - if (!options) - return 1; - - while ((p = strsep(&options, ",")) != NULL) { - if (!*p) - continue; - - if (autofs_parse_param(p, root, pgrp, pgrp_set, sbi)) - return 1; - } - - return (sbi->pipefd < 0); -} - static struct autofs_sb_info *autofs_alloc_sbi(void) { struct autofs_sb_info *sbi; @@ -287,12 +260,14 @@ static struct autofs_sb_info *autofs_alloc_sbi(void) return sbi; } -static int autofs_validate_protocol(struct autofs_sb_info *sbi) +static int autofs_validate_protocol(struct fs_context *fc) { + struct autofs_sb_info *sbi = fc->s_fs_info; + /* Test versions first */ if (sbi->max_proto < AUTOFS_MIN_PROTO_VERSION || sbi->min_proto > AUTOFS_MAX_PROTO_VERSION) { - pr_err("kernel does not match daemon version " + errorf(fc, "kernel does not match daemon version " "daemon (%d, %d) kernel (%d, %d)\n", sbi->min_proto, sbi->max_proto, AUTOFS_MIN_PROTO_VERSION, AUTOFS_MAX_PROTO_VERSION); @@ -309,24 +284,18 @@ static int autofs_validate_protocol(struct autofs_sb_info *sbi) return 0; } -int autofs_fill_super(struct super_block *s, void *data, int silent) +static int autofs_fill_super(struct super_block *s, struct fs_context *fc) { + struct autofs_fs_context *ctx = fc->fs_private; + struct autofs_sb_info *sbi = s->s_fs_info; struct inode *root_inode; struct dentry *root; - struct autofs_sb_info *sbi; struct autofs_info *ino; - int pgrp = 0; - bool pgrp_set = false; - int ret = -EINVAL; - - sbi = autofs_alloc_sbi(); - if (!sbi) - return -ENOMEM; + int ret = -ENOMEM; pr_debug("starting up, sbi = %p\n", sbi); sbi->sb = s; - s->s_fs_info = sbi; s->s_blocksize = 1024; s->s_blocksize_bits = 10; s->s_magic = AUTOFS_SUPER_MAGIC; @@ -338,33 +307,24 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) * Get the root inode and dentry, but defer checking for errors. */ ino = autofs_new_ino(sbi); - if (!ino) { - ret = -ENOMEM; - goto fail_free; - } + if (!ino) + goto fail; + root_inode = autofs_get_inode(s, S_IFDIR | 0755); + root_inode->i_uid = ctx->uid; + root_inode->i_gid = ctx->gid; + root = d_make_root(root_inode); - if (!root) { - ret = -ENOMEM; + if (!root) goto fail_ino; - } root->d_fsdata = ino; - /* Can this call block? */ - if (parse_options(data, root_inode, &pgrp, &pgrp_set, sbi)) { - pr_err("called with bogus options\n"); - goto fail_dput; - } - - if (autofs_validate_protocol(sbi)) - goto fail_dput; - - if (pgrp_set) { - sbi->oz_pgrp = find_get_pid(pgrp); + if (ctx->pgrp_set) { + sbi->oz_pgrp = find_get_pid(ctx->pgrp); if (!sbi->oz_pgrp) { - pr_err("could not find process group %d\n", - pgrp); + ret = invalf(fc, "Could not find process group %d", + ctx->pgrp); goto fail_dput; } } else { @@ -393,15 +353,80 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) */ fail_dput: dput(root); - goto fail_free; + goto fail; fail_ino: autofs_free_ino(ino); -fail_free: - kfree(sbi); - s->s_fs_info = NULL; +fail: return ret; } +/* + * Validate the parameters and then request a superblock. + */ +static int autofs_get_tree(struct fs_context *fc) +{ + struct autofs_sb_info *sbi = fc->s_fs_info; + int ret; + + ret = autofs_validate_protocol(fc); + if (ret) + return ret; + + if (sbi->pipefd < 0) + return invalf(fc, "No control pipe specified"); + + return get_tree_nodev(fc, autofs_fill_super); +} + +static void autofs_free_fc(struct fs_context *fc) +{ + struct autofs_fs_context *ctx = fc->fs_private; + struct autofs_sb_info *sbi = fc->s_fs_info; + + if (sbi) { + if (sbi->pipe) + fput(sbi->pipe); + kfree(sbi); + } + kfree(ctx); +} + +static const struct fs_context_operations autofs_context_ops = { + .free = autofs_free_fc, + .parse_param = autofs_parse_param, + .get_tree = autofs_get_tree, +}; + +/* + * Set up the filesystem mount context. + */ +int autofs_init_fs_context(struct fs_context *fc) +{ + struct autofs_fs_context *ctx; + struct autofs_sb_info *sbi; + + ctx = kzalloc(sizeof(struct autofs_fs_context), GFP_KERNEL); + if (!ctx) + goto nomem; + + ctx->uid = current_uid(); + ctx->gid = current_gid(); + + sbi = autofs_alloc_sbi(); + if (!sbi) + goto nomem_ctx; + + fc->fs_private = ctx; + fc->s_fs_info = sbi; + fc->ops = &autofs_context_ops; + return 0; + +nomem_ctx: + kfree(ctx); +nomem: + return -ENOMEM; +} + struct inode *autofs_get_inode(struct super_block *sb, umode_t mode) { struct inode *inode = new_inode(sb); From patchwork Fri Sep 22 04:12:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 143258 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5407456vqi; Fri, 22 Sep 2023 01:30:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFfpxPP5pG5+3G2S2jiwc8iMUBfPzzR+pJR1Gpj+OskqFwhAbQ8zq752XPhA1tDQLsrll7L X-Received: by 2002:a17:90a:bb13:b0:277:1070:7490 with SMTP id u19-20020a17090abb1300b0027710707490mr766551pjr.44.1695371441259; Fri, 22 Sep 2023 01:30:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695371441; cv=none; d=google.com; s=arc-20160816; b=ZzU8kiqXw9o2jvIsH/vpBWkr9lczXndmCJXskC0Rn3ZkSpB7yXHiQRXjRLtjjnHS79 qiATN5h2CK4PeV5HoOIaOlgpqDca1P8WQL3Y4ooRhXmtXKsoMhmkR88pm3i+g5toZY0W 9LXpqEfIICku3xJ7N1OvGbmYcRRWgCAp68/85oRZ3BoIbhVUFM/mxefutN8IstPIoUou xRyNneK4jjB3YV/SYU1SNq3a9b3RxB91k4K6rUqSwtA4456WmHzDgv0pssoBPByf7iqM X1bXEojB2Tf5migsLMltJ+pMLQN2V/D3PfgOKOrbgskggQwb8uyb7FljMUFrXtxwcs9R lO7g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=TVdA8h0DNl8QhVA+dGkTgVhkAap2oNQG0MwE5XL5kpw=; fh=tOzwWtfY/Ihw0ZG9uDufqX7N1fYPvJMmg28cxm4BgX4=; b=mbZf5voqDfCsdD49244xQmkfSHLlgpH0T8JE6xTvBoAtDIkycoPSwEIfHxUJ0ifhHd 8B9BWlTwA8EDBgukjiyOruwpr7r3cZo7QFHLk/BCaRmOS1FpuGSvP+SABoKkkBrNLQ+W PzO4waZfNqnuCYjRuBnHWk0CsTLLo2daWiG3FG+29ioh6dF8XWOaIMuJIxGJM3PlI2E1 nR3hS6AvgTWq4lyrJnoulIjutXOBuO6dQW2pPWmm4Kykrn0L/3mci4JYbh1hKUjkqMl7 qEF8w0CcTN9o5VlGJJaKNOv4ScycoITNi93LVWqsp9HtGwO3PzPUKz5OZ+NctzwYAqxJ NfzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@themaw.net header.s=fm1 header.b=iKyjMpSd; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=L7OBvXe8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id lp15-20020a17090b4a8f00b002634977e6e5si6194088pjb.142.2023.09.22.01.30.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 01:30:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@themaw.net header.s=fm1 header.b=iKyjMpSd; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=L7OBvXe8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 0EE4A83D4A6C; Thu, 21 Sep 2023 21:14:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230389AbjIVEOH (ORCPT + 30 others); Fri, 22 Sep 2023 00:14:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230084AbjIVENc (ORCPT ); Fri, 22 Sep 2023 00:13:32 -0400 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D6C3E5C; Thu, 21 Sep 2023 21:13:07 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id D51735C026A; Fri, 22 Sep 2023 00:13:06 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Fri, 22 Sep 2023 00:13:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=themaw.net; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1695355986; x= 1695442386; bh=TVdA8h0DNl8QhVA+dGkTgVhkAap2oNQG0MwE5XL5kpw=; b=i KyjMpSdhrt3uQsxr6T6UxoeYCbayRCf6SkJDZKUT4DjCRR4XZI7A4vp6vVa7IWY2 iAlx/Z5r7iLqsma8ChIdZ0uHbC6hqEiGT/J1VYhxYkNNsvNnRIPgkWk0gKhsIDFY WtgUstVwu6J+U17BBmdF06sF2Pr9eCAEbdMGKuA5YupM4mj7WfP9lz7h29e4/9Na +B2kmRJo1xVJ9ygM6cmPc2LT4bNSqqh9Y6BKwROZfdep7y87BBdKrPW6OTdFRRbQ iRE+MQi//Uy3JQhSGl/sLN0+4R06QVi0eVulUtvzfmVGOoEWmU/ZNJ87zlOmYE5V g3+OU2puQL+OQocE6EgZg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1695355986; x= 1695442386; bh=TVdA8h0DNl8QhVA+dGkTgVhkAap2oNQG0MwE5XL5kpw=; b=L 7OBvXe8GQHWpMoWy0wgEbjaCZ212zowRiQ+RXQILK5CTv+qTNNaMNV3LMpx2ZncF jcH4elhoAb8due9ZEchpzGG0xafIPAKpgC31HpEZFHO/ASLmmanGazJslyE/WI5n pvXZ0OuFQyrOS8IjBkEJQOO5EP43Q9g9zzW5Q6bKwIzKOS406f4Q3WDVv+vTRuVq AGPpUhHDDoqaauZLdG3SxtmsGpOyog7/Zvc7YGXstxk0v+loWIjiLoviaLido0ft aOOR5cQmcvvdJhcqoD0M87w4DOvu5Gd+cavaQG8nXyEaQC936trU16dw+7H4ofvP 1nUnDIL5R22VvFGLFSWQw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudekjedgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepkfgrnhcu mfgvnhhtuceorhgrvhgvnhesthhhvghmrgifrdhnvghtqeenucggtffrrghtthgvrhhnpe duleegueffgfehudeufedtffeiudfghfejgeehvdffgefgjeetvdfffeeihfdvveenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrrghvvghnse hthhgvmhgrfidrnhgvth X-ME-Proxy: Feedback-ID: i31e841b0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 22 Sep 2023 00:13:02 -0400 (EDT) From: Ian Kent To: Al Viro , Christian Brauner Cc: autofs mailing list , linux-fsdevel , Kernel Mailing List , Bill O'Donnell , Miklos Szeredi , David Howells , Ian Kent Subject: [PATCH 8/8] autofs: fix protocol sub version setting Date: Fri, 22 Sep 2023 12:12:15 +0800 Message-ID: <20230922041215.13675-9-raven@themaw.net> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230922041215.13675-1-raven@themaw.net> References: <20230922041215.13675-1-raven@themaw.net> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 21 Sep 2023 21:14:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777725804469087834 X-GMAIL-MSGID: 1777725804469087834 There were a number of updates to protocol version 4, take account of that when setting the super block info sub version field. Signed-off-by: Ian Kent --- fs/autofs/inode.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index 3f2dfed428f9..53c0df354206 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c @@ -279,7 +279,17 @@ static int autofs_validate_protocol(struct fs_context *fc) sbi->version = AUTOFS_MAX_PROTO_VERSION; else sbi->version = sbi->max_proto; - sbi->sub_version = AUTOFS_PROTO_SUBVERSION; + + switch (sbi->version) { + case 4: + sbi->sub_version = 7; + break; + case 5: + sbi->sub_version = AUTOFS_PROTO_SUBVERSION; + break; + default: + sbi->sub_version = 0; + } return 0; }