From patchwork Sun May 7 17:55:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?6IOh546u5paH?= X-Patchwork-Id: 13233877 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD675C77B7D for ; Sun, 7 May 2023 17:56:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230450AbjEGR4I (ORCPT ); Sun, 7 May 2023 13:56:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231589AbjEGR4G (ORCPT ); Sun, 7 May 2023 13:56:06 -0400 Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01olkn2031.outbound.protection.outlook.com [40.92.98.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A74392D50 for ; Sun, 7 May 2023 10:56:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hbqHueXb9DH/3kplGHCn0zS8Sren8SdC6m60olKWAEtgvsRvSDRNIA9o7Z/yVNYzK0PoKzSqDTmtOCDRSOFon/m0G401l38miULmxl8sBSENiC9Rk4OAxwVuHFfo7OeeiZuyPvrCvi9Ksef1YN5CRr9z2wgqShos2Y835KYGrroos4wYYuYQIRz2/BdyDBWwcvzvbEt89GQjEE4tB3dldyOHBx5JtttXQGgipXpwGwsZUNyZM0yPsU7czN7+sdei31aYkoKfVzaJJdC0MGi9q2ys50ufvYd22hm1glZq8IAT2DR/SSjdrft2ZIn70AXfTpWK4ooRqNiz46Z7I2hdjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SRDtaGdt2/6sK6FxdX5m8CKiWIGMeoS8voZ9oV98+4Y=; b=cLSeqEXfuz8u9gSGtLFQnKAs6jdFj25pbSpFd+BTBYTUoup7hW56tmfcDUhgIZBxsm8odZw5dyovyuAw0RhPkntLj37RQ9lmhe67KJrsIyKOK/l2fNeHS7NTqbpkcQrGkJYahrg+vnH7ccmatas3skxtzembG9OEygVqSOgVr/txJkiYjthSBt3auJnCB2+mydQ7JTZ5p6pQKUBxHM0LkOhlwEOEXVRgi83hl+PQneF0jJbBQlMcROtPmbHk1xR8P1YNceOlAq6l1XbobngPtkpBufWANTDKFFnboJHy5pN4jPE2tQ0ky+Wb57hS9D80VKqjwEpgluzdpL0c6LViHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SRDtaGdt2/6sK6FxdX5m8CKiWIGMeoS8voZ9oV98+4Y=; b=kFlQIJEJt/z7bHl7gRG6ZLWumetPZw2mZPqv539TGKLsaEGR/6aAfFV583GBvvBFcVacsIjQf05JgZdyIR6HmnjfR+6Y+4f3yIssx6gxZ+ISvjGz6RtxDyMfh0XCpGOOnWejMPJ9j3gaR5ZsfVB37uW5wk4cVtJ+hQOWQ8DSEtsoVvLGY7PmYcLp90TyRSo/GvgNK1zbtxP4ix8mtzylTUqnHJPkHlQtJZXIaoDbTpvSsMyZWYJSb+NEMlnhQqYOUTaXdhjno8SEEfXOhlg7kXw1j/xNwQoe1mvvj6kkJ2ldRituODCCJgF32hINkEMzEx7NEWvCQ75xIw3k8mccsQ== Received: from TYCP286MB2066.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::14) by OS3P286MB2567.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:1fa::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.32; Sun, 7 May 2023 17:56:01 +0000 Received: from TYCP286MB2066.JPNP286.PROD.OUTLOOK.COM ([fe80::d9fd:1e8f:2bf4:e44]) by TYCP286MB2066.JPNP286.PROD.OUTLOOK.COM ([fe80::d9fd:1e8f:2bf4:e44%6]) with mapi id 15.20.6363.032; Sun, 7 May 2023 17:56:01 +0000 From: Hu Weiwen To: ceph-devel@vger.kernel.org, Xiubo Li , Ilya Dryomov Cc: Venky Shankar , Hu Weiwen Subject: [PATCH 3/3] libceph: reject mismatching name and fsid Date: Mon, 8 May 2023 01:55:03 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [jSPRQhFXM6Ozvf5IyVDEVUjzzzOs80bP] X-ClientProxiedBy: BY5PR16CA0033.namprd16.prod.outlook.com (2603:10b6:a03:1a0::46) To TYCP286MB2066.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::14) X-Microsoft-Original-Message-ID: <20230507175503.2271-3-huww98@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCP286MB2066:EE_|OS3P286MB2567:EE_ X-MS-Office365-Filtering-Correlation-Id: 783528b9-459d-45d4-d749-08db4f24519c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E/natYHQCywiIz5yIxly+7xYgoSicy6tWELAZ2z99YgRcprDtiGyhoFxjnYT8HmiWAT7IQxkPMrA9RIKpYTZuG+hvZLwQdjdelppw05H5K+/rMWAbnAaL4JGeVfaL5xRqembs5UzG9u14u+JlJUg8QCJCsw65GHwQiTkEtb9j+HEAPtgyRQEVrnxgXa3OLLkiS4Q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LBupmR5XrzwCh5I+2NUw5v/bsAaj541LxZ7NtbV4wmExFJFrYxfKVmWkvKK/dA9sUP5Obv4PFSkdK0S6wfvX1trogcv9pb7jTXZRFhL8r44n+Bt0Qi202LIuM6Z5D1rGD2OwQgzirSc5y1LufoUDwLufijzegFHoZdzxdF/NEb+dWpj8wrE5W7wcF8EgMAOMVy8LLwFuOgrJUtEBmDYRNfrD7FO7FiquopK6YZPmGNuiRRBtUPyLA+fKGTnQtXpgZi2ONJcpAoEs9b949DnRBFzDUZznCVyKodRtVHo7FmJsJxFCW8eBvfaMZu2trt/4l+jCxrz5F3s7bl3BIuKN7TYDLmxMZDIUWyqwGYlTOcV80CMPr2a61ZxMsjWeBIp7IBnqJ5d+KzB8AVw2S90c+mFDV5GPp86vhClPBQEsPBHMEFVITcVjIjI4mjyPjzZauMUDqLnyeCZxfpk8MOQs3y7UzyfdA+JTMBja/sEUO/+6kLtnaYDkOIXKQjtefmGvpoltqEQeEIaLZBDXqUpjlMiv/shN9ko+tTKMGlkIK0MscWYimW0T6pT4ox+v4amrBUkVuhAhix434l+wo+GKgbprQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 783528b9-459d-45d4-d749-08db4f24519c X-MS-Exchange-CrossTenant-AuthSource: TYCP286MB2066.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2023 17:56:01.6165 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3P286MB2567 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Hu Weiwen These are present in the device spec of cephfs. So they should be treated as immutable. Also reject `mount()' calls where options and device spec are inconsistent. Signed-off-by: Hu Weiwen --- net/ceph/ceph_common.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c index 4c6441536d55..c59c5ccc23a8 100644 --- a/net/ceph/ceph_common.c +++ b/net/ceph/ceph_common.c @@ -440,17 +440,33 @@ int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt, break; case Opt_fsid: - err = ceph_parse_fsid(param->string, &opt->fsid); + { + struct ceph_fsid fsid; + + err = ceph_parse_fsid(param->string, &fsid); if (err) { error_plog(&log, "Failed to parse fsid: %d", err); return err; } - opt->flags |= CEPH_OPT_FSID; + + if (!(opt->flags & CEPH_OPT_FSID)) { + opt->fsid = fsid; + opt->flags |= CEPH_OPT_FSID; + } else if (ceph_fsid_compare(&opt->fsid, &fsid)) { + error_plog(&log, "fsid already set to %pU", + &opt->fsid); + return -EINVAL; + } break; + } case Opt_name: - kfree(opt->name); - opt->name = param->string; - param->string = NULL; + if (!opt->name) { + opt->name = param->string; + param->string = NULL; + } else if (strcmp(opt->name, param->string)) { + error_plog(&log, "name already set to %s", opt->name); + return -EINVAL; + } break; case Opt_secret: ceph_crypto_key_destroy(opt->key);