From patchwork Thu Sep 21 07:03:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 142839 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5071072vqi; Thu, 21 Sep 2023 12:02:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF+M+m9itB8BCp/zZqrY7r6mC1lObNm+MWszF2oJ7x6NYJRCCtMKFJOoldI6REpRkMVXK4/ X-Received: by 2002:a17:90a:72c6:b0:273:dfb1:2439 with SMTP id l6-20020a17090a72c600b00273dfb12439mr663152pjk.21.1695322920758; Thu, 21 Sep 2023 12:02:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695322920; cv=none; d=google.com; s=arc-20160816; b=DqeC9ENeVZyPOpc/4dGTOnupKNNbfyqyMpDTqR3clkvjfFH7Fjm3z9LXOyFp8oSp+H 893Fif3eLNxCQUbE6DHzTaj+qu9qXbgpUlTJUlYC7dmgQBJYEhBe1hSCp0R9Cf2qKE4e Bkpyq87tqQXc6icIh+1c7Fe3rzsuVSFUCOgupLr8GXOQ2uHSJpmvBwmBelYsR2CelA58 HoPyuGarM0FgFGYjkoR5ny3xvFJyRbH6Fiqq3DLsHwj8TYae5iSOlnfQH7b/7Ciid55h j/z8uF50O3Kp8cVZIdi4dXlwD6O3HCkYgZY+30/xW3UeIw90P82AziYOKdpwSUV74/kn QxXg== 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; bh=qhU7APQS7+fYRQgdTyxJIyooTIsBKgxyxhOtgyTAZYE=; fh=Vd00GRLUNDtgftEBzBaifz0ZIGFRdtawsvTRUw5VTu8=; b=CLkRF/2bS0nH04MTN/Sw1otJmXwWIV6D9nig+hgqaYqfOaFFBu7NDbYXn2M5GhClo8 Y4GS65J5sjZ4Lozm7bKKWntIjSoBI7Ddy8sIYkOvcHocE0F5i6lljb0XpCfVQz4GlRp1 Pnc5nbJrPTMqi0ly4K3lzeTWeB1Pzmmxn7wrUFjZnon0/yL1C/Fe6OFegfZe7V/zLJcA C5tFi2yNIzKGi4TWM7JPCh0LU0u9j7DmUxu1g0NMY2eGXkHbz1vvehrJ3Uv6CTV7m0u9 FzDA6ZXKjDRB35Y60AWLa5kyPPHdrVdhU0t4vH0hVbWLLBg+PoYGg56l0aiz10sfBNyx DW4A== ARC-Authentication-Results: i=1; mx.google.com; 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 x18-20020a63b212000000b00578d71ef3d7si1917142pge.733.2023.09.21.12.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 12:02:00 -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; 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 8502180A90EB; Thu, 21 Sep 2023 11:57:49 -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 S230453AbjIUS5U (ORCPT + 28 others); Thu, 21 Sep 2023 14:57:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229593AbjIUS46 (ORCPT ); Thu, 21 Sep 2023 14:56:58 -0400 X-Greylist: delayed 60 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 21 Sep 2023 11:51:05 PDT Received: from smtp01.aussiebb.com.au (smtp01.aussiebb.com.au [IPv6:2403:5800:3:25::1001]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D006E8D9FB; Thu, 21 Sep 2023 11:51:05 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp01.aussiebb.com.au (Postfix) with ESMTP id 1D1AF100572; Thu, 21 Sep 2023 17:03:35 +1000 (AEST) X-Virus-Scanned: Debian amavisd-new at smtp01.aussiebb.com.au Received: from smtp01.aussiebb.com.au ([127.0.0.1]) by localhost (smtp01.aussiebb.com.au [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rnrQDSauchoq; Thu, 21 Sep 2023 17:03:35 +1000 (AEST) Received: by smtp01.aussiebb.com.au (Postfix, from userid 116) id 133D5100544; Thu, 21 Sep 2023 17:03:35 +1000 (AEST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from donald.themaw.net (180-150-90-198.b4965a.per.nbn.aussiebb.net [180.150.90.198]) by smtp01.aussiebb.com.au (Postfix) with ESMTP id 7F4CA100223; Thu, 21 Sep 2023 17:03:33 +1000 (AEST) Subject: [PATCH 1/8] autofs: refactor autofs_prepare_pipe() From: Ian Kent To: Al Viro , Christian Brauner Cc: autofs mailing list , linux-fsdevel , Kernel Mailing List , Bill O'Donnell , Miklos Szeredi , David Howells Date: Thu, 21 Sep 2023 15:03:33 +0800 Message-ID: <169527981274.27328.17552761781465494402.stgit@donald.themaw.net> In-Reply-To: <169527971702.27328.16272807830250040704.stgit@donald.themaw.net> References: <169527971702.27328.16272807830250040704.stgit@donald.themaw.net> User-Agent: StGit/1.5 MIME-Version: 1.0 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 11:57:49 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777674926684676157 X-GMAIL-MSGID: 1777674926684676157 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 Thu Sep 21 07:03:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 142840 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5071076vqi; Thu, 21 Sep 2023 12:02:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEh4UXXDl7NjTY59J38h8OK8Y90oU6fdv3Yo0fcjIxW1ZiVe5DMZD0kV3cVliv6GRssJeG X-Received: by 2002:a17:902:c211:b0:1c5:64aa:b97a with SMTP id 17-20020a170902c21100b001c564aab97amr5645922pll.38.1695322920974; Thu, 21 Sep 2023 12:02:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695322920; cv=none; d=google.com; s=arc-20160816; b=WovFBKpkUaGEwc9HcrHR0dBFXkYIQiDoLPzIx6QyEOSbJYvzuZfn80SqOoYJspNnK9 KJYcbXgu3J7ACtJhlDVYBjtemLnV6/QQMI6aVyrHmqUGg8QQxZeEZrBp1sUmCpuzP7oT OH0RMnION1y9uuVSCsHQ1MFqgGGnq6PzW4f++PRse5gSkbaWotQNl8e9gH7i1MoE68Vb uY3jWA3XjqqSejPdRCtyPtPNa2CnSMVW0rI6zramEBYAKpQlOpAtMrW7jWmPREPhPs5/ BnBNz5iRpfsak3yY2Vjhjzh5fqhDe6MKJKFWGoyPttfAfa4Ky2uT1+jw5lAunDCeBlt+ 4pKg== 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; bh=TilKPE80wE2QqhUWBtHW/6QHdOup1I94px7hcoTlf7A=; fh=Vd00GRLUNDtgftEBzBaifz0ZIGFRdtawsvTRUw5VTu8=; b=CyscepAOQGVTg13eGvgDhOcxFX8QDn2G20ka33Zx62BcLV+We4Be0Lq6UCCFnjE3ff Hwd2GvhCxzB7O2bmIYN3meESQd72LckriffyEWsAvMjxvOZaHnF3/Mfe7+GOGbxCB87g PdwLcSH4E37IIsJ+vkBA1BTdU6wVsSejrwZzGaazHWL4qqe3uuUotUJbj3UOQdi5hcwC WP86/fqxTarQ0nUpRRNX63AMQRmIZGj9AkH3PbrsK6Y1sUA6cbPCXYuw2FfipumirM2q thw06RigpLyEoH+Hlu4yZm+JQMob3xB/0BAlnOdMnavUinAFpX1jUDe9GqIV21Fir5t4 8q1g== ARC-Authentication-Results: i=1; mx.google.com; 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 ju22-20020a170903429600b001c5a8815fd7si1917769plb.150.2023.09.21.12.02.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 12:02:00 -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; 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 964F080427AF; Thu, 21 Sep 2023 11:57:49 -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 S230491AbjIUS5Y (ORCPT + 28 others); Thu, 21 Sep 2023 14:57:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229513AbjIUS5A (ORCPT ); Thu, 21 Sep 2023 14:57:00 -0400 Received: from smtp01.aussiebb.com.au (smtp01.aussiebb.com.au [IPv6:2403:5800:3:25::1001]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F1258DEFE; Thu, 21 Sep 2023 11:51:05 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp01.aussiebb.com.au (Postfix) with ESMTP id 70527100580; Thu, 21 Sep 2023 17:03:40 +1000 (AEST) X-Virus-Scanned: Debian amavisd-new at smtp01.aussiebb.com.au Received: from smtp01.aussiebb.com.au ([127.0.0.1]) by localhost (smtp01.aussiebb.com.au [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AAGMtsSZ3NHu; Thu, 21 Sep 2023 17:03:40 +1000 (AEST) Received: by smtp01.aussiebb.com.au (Postfix, from userid 116) id 67A5C10057F; Thu, 21 Sep 2023 17:03:40 +1000 (AEST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from donald.themaw.net (180-150-90-198.b4965a.per.nbn.aussiebb.net [180.150.90.198]) by smtp01.aussiebb.com.au (Postfix) with ESMTP id 8AFA9100265; Thu, 21 Sep 2023 17:03:39 +1000 (AEST) Subject: [PATCH 2/8] autofs: add autofs_parse_fd() From: Ian Kent To: Al Viro , Christian Brauner Cc: autofs mailing list , linux-fsdevel , Kernel Mailing List , Bill O'Donnell , Miklos Szeredi , David Howells Date: Thu, 21 Sep 2023 15:03:39 +0800 Message-ID: <169527981914.27328.15182386732807940466.stgit@donald.themaw.net> In-Reply-To: <169527971702.27328.16272807830250040704.stgit@donald.themaw.net> References: <169527971702.27328.16272807830250040704.stgit@donald.themaw.net> User-Agent: StGit/1.5 MIME-Version: 1.0 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 11:57:49 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777674927133988056 X-GMAIL-MSGID: 1777674927133988056 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 Thu Sep 21 07:03:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 142850 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5078726vqi; Thu, 21 Sep 2023 12:13:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IETZ8OTiKXeCUePhdpIeL/xiz8PrAi69qdyRVSdu+UEQq9plewwNen/zlKmrR6Bc8ydPEmL X-Received: by 2002:a05:6a20:729b:b0:15a:6733:24e2 with SMTP id o27-20020a056a20729b00b0015a673324e2mr808117pzk.25.1695323604930; Thu, 21 Sep 2023 12:13:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695323604; cv=none; d=google.com; s=arc-20160816; b=ANUgsq8QPdobsXSArSfnlra1sCRNVk7/enn8Ar+Carx+IKMbTPm7o1OlY/iinXOjPq u7xAWXOifH4m+mEMUIIO2dADsV5eNJT9kl2C+hj4KCm0MpEhINNlLioLLH9/J29tZc0A AADDvDvLtJ/q+RCWNF/CHTUeChkg3q8E+HTO2AO3JzhvSX4WcPK0UmKc1pO8MXr5nUS4 QKjRdcYo8/XnTisAESpn1MP2vv6qNGepS3JG5KrA0pP8i0wm5JRmp1RFDJa1mrnthD0V /Y7G7m9hMJeYmEw6PuKweNLCVY25c7lHKGnfcdV+tuG+fiiYFh+NjotuQOh3lTgKivIP ltbQ== 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; bh=cG/9BQFlv/L4jyOo38H5cZPQdh9yQlVijN6aCcoHRnk=; fh=Vd00GRLUNDtgftEBzBaifz0ZIGFRdtawsvTRUw5VTu8=; b=STMJkHch7M+0V/DdgDGdDzL2IGBcINP2iJpk3ihj2EOt9LXilabJygxRSqSiHTdto0 p6vVh2bmTx1EoUBg8rIieKHqZLQ30tkI7NSretv45a7JgloxhWybLSA/jb0ecEPNcgDy 7G9AQnE4om2Vzj30aihbddVlQXPWi0zko2C0fr3Qgf5XSEDBzSAqA8ROraKEBXE9LS8k eo55IUo3mdfXXYRnvkp3d2rz1YEt4TjxkSXQgIrdzfP+/D8zZnXSs+YR00KFPQeq6zTq Hut3NmA7IKVvJhjjue9Eo9SuPmymtjN/Go0YCB+uj71bfFpZbqC3OJSykLnKpr4aIKq8 MlSA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id k33-20020a634b61000000b00578c9144919si2070681pgl.254.2023.09.21.12.13.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 12:13:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id E65A48059892; Thu, 21 Sep 2023 11:57:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229493AbjIUS5b (ORCPT + 28 others); Thu, 21 Sep 2023 14:57:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230036AbjIUS5A (ORCPT ); Thu, 21 Sep 2023 14:57:00 -0400 Received: from smtp01.aussiebb.com.au (smtp01.aussiebb.com.au [IPv6:2403:5800:3:25::1001]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 431708FB3E; Thu, 21 Sep 2023 11:51:05 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp01.aussiebb.com.au (Postfix) with ESMTP id 7F837100321; Thu, 21 Sep 2023 17:03:46 +1000 (AEST) X-Virus-Scanned: Debian amavisd-new at smtp01.aussiebb.com.au Received: from smtp01.aussiebb.com.au ([127.0.0.1]) by localhost (smtp01.aussiebb.com.au [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cS9HrQngyQhG; Thu, 21 Sep 2023 17:03:46 +1000 (AEST) Received: by smtp01.aussiebb.com.au (Postfix, from userid 116) id 7620310056B; Thu, 21 Sep 2023 17:03:46 +1000 (AEST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from donald.themaw.net (180-150-90-198.b4965a.per.nbn.aussiebb.net [180.150.90.198]) by smtp01.aussiebb.com.au (Postfix) with ESMTP id A40B81002AE; Thu, 21 Sep 2023 17:03:45 +1000 (AEST) Subject: [PATCH 3/8] autofs - refactor super block info init From: Ian Kent To: Al Viro , Christian Brauner Cc: autofs mailing list , linux-fsdevel , Kernel Mailing List , Bill O'Donnell , Miklos Szeredi , David Howells Date: Thu, 21 Sep 2023 15:03:45 +0800 Message-ID: <169527982522.27328.18413711550740966247.stgit@donald.themaw.net> In-Reply-To: <169527971702.27328.16272807830250040704.stgit@donald.themaw.net> References: <169527971702.27328.16272807830250040704.stgit@donald.themaw.net> User-Agent: StGit/1.5 MIME-Version: 1.0 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 (fry.vger.email [0.0.0.0]); Thu, 21 Sep 2023 11:57:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777675644237622779 X-GMAIL-MSGID: 1777675644237622779 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 Thu Sep 21 07:03:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 142847 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5075894vqi; Thu, 21 Sep 2023 12:08:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJNZ39lNNUttSYyo4VhtUYRm0dI7z0Wiv/nfi2z8IcdEeFHOOenhf/M1Dw79riAzZ95RDV X-Received: by 2002:a05:6a00:1596:b0:68f:bb16:d16a with SMTP id u22-20020a056a00159600b0068fbb16d16amr776097pfk.5.1695323319632; Thu, 21 Sep 2023 12:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695323319; cv=none; d=google.com; s=arc-20160816; b=MZ+y+/uTwyaJjFGlxDmZiI/KRLtma5PLRIeB0gr3QHn2SQKFaE+alPY+gPP8UTu24J ih4i4joJbx1o5cC0gvRq8iiMgm8PofrHhGAdPaq5f+fIVakFv/z/3epRuRwPcEOpLwui 0yX4OHDjr4hB9SahRJEXKDEf9gjlTgD9QwtXf5AcWl4cSMhM5/pll6mUmKDDYab/qlyX kv5XqA2rJ+BSj6po9PnhsZDMcbjVlBuv5i413EaKmLG1zcgBHbxvDd+Y3nb6B9j2Ds7o /RrV0+Ud12jFMQpXZrtNf+Gr6Q3UKY/sxAiMZ4K92w1Fs3zSKW8q5jbEJlpY6+Ov9ioM 2nCA== 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; bh=yIq2XtPs0w6cZlrpIyYOiyevEDEQCJutT8+OVpJpvoo=; fh=Vd00GRLUNDtgftEBzBaifz0ZIGFRdtawsvTRUw5VTu8=; b=kaV+S4SeWgHAR4XrbIsoWdxhGsWHrlerWqw44pOM+ms3PAjLEwsESLmviV5P+ar0V8 jP90cLCmIFdDvFKQBxaHZvJzEXatm6FqCW6/mHhPgr44/w16wlWp8Jnyr2ccRHdi2FyS 3jFnKG6Iy7ZuPCXbqPMnKUWcPdYLMjPrrE1rV+rgkRlobobP27H2Td3hzlCbnQ/ufZTe vMKhdJhV2tOpYR63L0YKZm9+gvOFYkZ0YNAM44AIXoe/A6W9GmunTj9qaw+gX9ecSqEs c0konHGUYPLZ4JvZAxl6uXnbzwIfWTQF38fkaJYSD2rgRMOYmYbhz5zTwW9ftBTXJote uUtg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id s18-20020a62e712000000b0068bc4337051si1861439pfh.359.2023.09.21.12.08.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 12:08:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 43946802588D; Thu, 21 Sep 2023 11:57:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229899AbjIUS52 (ORCPT + 28 others); Thu, 21 Sep 2023 14:57:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230370AbjIUS5B (ORCPT ); Thu, 21 Sep 2023 14:57:01 -0400 Received: from smtp01.aussiebb.com.au (smtp01.aussiebb.com.au [IPv6:2403:5800:3:25::1001]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F8938ED43; Thu, 21 Sep 2023 11:51:05 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp01.aussiebb.com.au (Postfix) with ESMTP id 8F65910057C; Thu, 21 Sep 2023 17:03:52 +1000 (AEST) X-Virus-Scanned: Debian amavisd-new at smtp01.aussiebb.com.au Received: from smtp01.aussiebb.com.au ([127.0.0.1]) by localhost (smtp01.aussiebb.com.au [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eCRW0MMXS3Y8; Thu, 21 Sep 2023 17:03:52 +1000 (AEST) Received: by smtp01.aussiebb.com.au (Postfix, from userid 116) id 8835810057F; Thu, 21 Sep 2023 17:03:52 +1000 (AEST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from donald.themaw.net (180-150-90-198.b4965a.per.nbn.aussiebb.net [180.150.90.198]) by smtp01.aussiebb.com.au (Postfix) with ESMTP id BC87F100265; Thu, 21 Sep 2023 17:03:51 +1000 (AEST) Subject: [PATCH 4/8] autofs: reformat 0pt enum declaration From: Ian Kent To: Al Viro , Christian Brauner Cc: autofs mailing list , linux-fsdevel , Kernel Mailing List , Bill O'Donnell , Miklos Szeredi , David Howells Date: Thu, 21 Sep 2023 15:03:51 +0800 Message-ID: <169527983132.27328.10535655381168506781.stgit@donald.themaw.net> In-Reply-To: <169527971702.27328.16272807830250040704.stgit@donald.themaw.net> References: <169527971702.27328.16272807830250040704.stgit@donald.themaw.net> User-Agent: StGit/1.5 MIME-Version: 1.0 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 (agentk.vger.email [0.0.0.0]); Thu, 21 Sep 2023 11:57:38 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777675345305247358 X-GMAIL-MSGID: 1777675345305247358 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"},