Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp985938lqt; Tue, 19 Mar 2024 09:24:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVob8B+Ob4o2EPYzteWW1XIEw7f++oEWYB4LanY5mm8MDl+b611Z/CE7zReog4g/ZdsMMEWSQPvPIVpnGvsAaV3slTYi7rpBT8mQlOnxA== X-Google-Smtp-Source: AGHT+IFa7Qso9YTGRcjCBwPhu3iqcYkVmYb48a0PwMho1TGy0hKU0+/JWt5jjLEvNXn/3oqZxxqz X-Received: by 2002:a17:903:40c1:b0:1de:fbc3:8e59 with SMTP id t1-20020a17090340c100b001defbc38e59mr14536336pld.21.1710865497344; Tue, 19 Mar 2024 09:24:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710865497; cv=pass; d=google.com; s=arc-20160816; b=WwhfST0wCF+bRKvkCG014X2DkT0TJZ0OAPVpfJet4TXk5jdabzJMeZVnl+rUMy0acE IqOF5JFD6bWjEt6VasKuRoBW967pfph8vrSRzXYsEDVPOkGe6D8ediiiYNapHcEup3EZ j8s43LMt30GV1Lee+tCxRJsV083JOyU0ekYUn/HWxF9nhuQt56iPjzbH3abR8+NFBLuu tL6HgoCfAkO2IUZ2Mm0O1EkRCkfPUxUJhp0rqFVtUAUFLPCpiplq/PTWLrZDj41s+v9/ twg44ISCtsfgi2Pm1utd9PVCadpY47O3M+LODfqxAAmQ6OAMGdk/8QXIfp5NcvdtLPvl gkvA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=+AxOY71qEzmmQ8zMGwzo+5V59hp6E6Fk2/lBn2erp3M=; fh=k/ntoYyfhVXlJ6dO7vhvqOSVlhGJ2dvIyOJFv53VJIU=; b=jdddbTBWUTTbiTPcEdl4axepA0Ly9LXngGAeyS1QFRodJx0EoqLJkFx1rrBsL2PNiB WIE6SNZcTWgZ9ATL6GoGijwxL0yZ1JgztYU8ltYOXanhvXyeU6WwG3/tM+kWrzpXI/Ph 3aO8XpmhCxEzMu9VEeDHSMgkBdJGoGC2ZdB6/uBOtvHUtZ+pz3uyGWMoPw19zMoloEuY g+k77pAaI2yCtp1llUb6QU6X0KNJ+fcBecI+VTSXYk5yOkP3+AvIHvnDAXxAMho+JSLr 9apEA1PBvewh5vWqhdAaHaNcCBkOOKLGIRZSLUUlnfOUueBs4XCddnyUaD/pegxSZNpr FSqg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-107822-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107822-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h15-20020a170902680f00b001dca6092ceasi1728401plk.409.2024.03.19.09.24.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 09:24:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-107822-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-107822-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107822-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CB104283B51 for ; Tue, 19 Mar 2024 16:24:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3328083CB6; Tue, 19 Mar 2024 16:17:02 +0000 (UTC) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14A5983A11 for ; Tue, 19 Mar 2024 16:16:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710865021; cv=none; b=Hf7sPowV3U6Qwa+FeuIfx+KN/QgmT/hTz0aV4IqxoWAfcVuT5OHHMDeeuwbSj4fcDEK1l3IKQfSWR17k+sZ+2XhJMtG52Ikf2+zbbxnzb68t4UaMilww2yKjJpPScTrkJpgJ0+VQzza2a7hTN8O9rrhKLQ4zftvqkaQPLSy8+98= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710865021; c=relaxed/simple; bh=emJA4rgmgnd/+JcRUIlMPIJB8sezta6Apcgb/jZWgu4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SYKP6+mRbG6E5TEYteF9o9eaIg1B2pfSUzS0Qm/jWtFnnGFzXqZPgZdiuucGoBkZRIU1cvci9EC28Nr/FzIsTxIFrrku1oBqp51IWdJGSshEp6qetpr87adJcA8qOMjVV/c3dPzn2HGpEoWIfcDCYUkMvGggd3sXmIBZz7HJoyA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4TzcHM5Q6dz2Bgb9; Wed, 20 Mar 2024 00:14:23 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id 7D3A514013B; Wed, 20 Mar 2024 00:16:56 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Wed, 20 Mar 2024 00:16:56 +0800 From: Li Zetao To: , CC: , , Subject: [RFC PATCH 4/5] ubifs: Introduce ACLs mount options Date: Wed, 20 Mar 2024 00:16:45 +0800 Message-ID: <20240319161646.2153867-5-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240319161646.2153867-1-lizetao1@huawei.com> References: <20240319161646.2153867-1-lizetao1@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemd500012.china.huawei.com (7.221.188.25) Implement the ability to enable or disable the ACLs feature through mount options. "-o acl" option means enable and "-o noacl" means disable and it is enable by default. Signed-off-by: Li Zetao --- fs/ubifs/super.c | 40 ++++++++++++++++++++++++++++++++++++++++ fs/ubifs/ubifs.h | 2 ++ 2 files changed, 42 insertions(+) diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 7f4031a15f4d..ed03bf11e51d 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -457,6 +457,13 @@ static int ubifs_show_options(struct seq_file *s, struct dentry *root) seq_printf(s, ",assert=%s", ubifs_assert_action_name(c)); seq_printf(s, ",ubi=%d,vol=%d", c->vi.ubi_num, c->vi.vol_id); +#ifdef CONFIG_UBIFS_FS_POSIX_ACL + if (c->mount_opts.acl == 2) + seq_puts(s, ",acl"); + else if (c->mount_opts.acl == 1) + seq_puts(s, ",noacl"); +#endif + return 0; } @@ -967,6 +974,8 @@ static int check_volume_empty(struct ubifs_info *c) * Opt_assert: set ubifs_assert() action * Opt_auth_key: The key name used for authentication * Opt_auth_hash_name: The hash type used for authentication + * Opt_acl: enable posix acl + * Opt_noacl: disable posix acl * Opt_err: just end of array marker */ enum { @@ -981,6 +990,8 @@ enum { Opt_auth_key, Opt_auth_hash_name, Opt_ignore, + Opt_acl, + Opt_noacl, Opt_err, }; @@ -997,6 +1008,8 @@ static const match_table_t tokens = { {Opt_ignore, "ubi=%s"}, {Opt_ignore, "vol=%s"}, {Opt_assert, "assert=%s"}, + {Opt_acl, "acl"}, + {Opt_noacl, "noacl"}, {Opt_err, NULL}, }; @@ -1137,6 +1150,23 @@ static int ubifs_parse_options(struct ubifs_info *c, char *options, break; case Opt_ignore: break; +#ifdef CONFIG_UBIFS_FS_POSIX_ACL + case Opt_acl: + c->mount_opts.acl = 2; + c->vfs_sb->s_flags |= SB_POSIXACL; + break; + case Opt_noacl: + c->mount_opts.acl = 1; + c->vfs_sb->s_flags &= ~SB_POSIXACL; + break; +#else + case Opt_acl: + ubifs_err(c, "acl options not supported"); + return -EINVAL; + case Opt_noacl: + ubifs_err(c, "noacl options not supported"); + return -EINVAL; +#endif default: { unsigned long flag; @@ -2011,12 +2041,17 @@ static int ubifs_remount_fs(struct super_block *sb, int *flags, char *data) sync_filesystem(sb); dbg_gen("old flags %#lx, new flags %#x", sb->s_flags, *flags); + c->mount_opts.acl = 0; err = ubifs_parse_options(c, data, 1); if (err) { ubifs_err(c, "invalid or unknown remount parameter"); return err; } +#ifdef CONFIG_UBIFS_FS_POSIX_ACL + if (!c->mount_opts.acl) + c->vfs_sb->s_flags |= SB_POSIXACL; +#endif if (c->ro_mount && !(*flags & SB_RDONLY)) { if (c->ro_error) { ubifs_msg(c, "cannot re-mount R/W due to prior errors"); @@ -2197,6 +2232,11 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent) if (err) goto out_close; +#ifdef CONFIG_UBIFS_FS_POSIX_ACL + if (!c->mount_opts.acl) + c->vfs_sb->s_flags |= SB_POSIXACL; +#endif + /* * UBIFS provides 'backing_dev_info' in order to disable read-ahead. For * UBIFS, I/O is not deferred, it is done immediately in read_folio, diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index b0d3b076290d..4a6078cbb2f5 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h @@ -956,6 +956,7 @@ struct ubifs_orphan { * specified in @compr_type) * @compr_type: compressor type to override the superblock compressor with * (%UBIFS_COMPR_NONE, etc) + * @acl: enable/disable posix acl (%0 default, %1 disable, %2 enable) */ struct ubifs_mount_opts { unsigned int unmount_mode:2; @@ -963,6 +964,7 @@ struct ubifs_mount_opts { unsigned int chk_data_crc:2; unsigned int override_compr:1; unsigned int compr_type:2; + unsigned int acl:2; }; /** -- 2.34.1