Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7555571rwb; Tue, 15 Nov 2022 14:15:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf5SVJcEW1W73B8W29pizLRhFNiQgVNz08xVMYxhgJzVjoCbQCDAkCDWP3GALfmBjDOWmAza X-Received: by 2002:a17:903:50e:b0:188:6300:57ad with SMTP id jn14-20020a170903050e00b00188630057admr6102337plb.7.1668550509020; Tue, 15 Nov 2022 14:15:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668550509; cv=none; d=google.com; s=arc-20160816; b=QipBqdN6Bqa6ArmyWO4ZBXEcfzeBmqu6F2hbi0LfL69r1TYcwVCKF+wby0URwDcFcD ePo5Mvs0V1ciRNjUKE5sstdGgrzrWYFyvIFUAQgYDKyD7hyW92RO41lpG3EcjzYIgvY/ QuQzeIiCF0lBhavZz3bC2WzYbxmAHzzI24sDuZulBvhqfROrvOxaI0I1/Oj5yoh5ntoW eQcwxVD5t1lqVPm/Kz+8hUFXw/tUz/Ah6QLDQn/hgyLQwuEuv2Wi9yZ5lCsGcN9zPx1S VfGrPm2M0iHv1fzkj4EFtcDKIA6I2lJGH+E4GRzjmRgNXywHPTvHPG/Inz4LdP2vfQ3O XO6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date; bh=QL8a0deLAuhj1IQrO+ZAK2NOnJRVmLLYuYU2Bz1xQ2g=; b=kJcBGySucwha/GiDvTBbxGTAUjX6rj/ZgUx/xy4bxn8ePg7AgVkwc5OufLsCwcuV3w CGkgzE94Yxc8G9Izh3TySJrMsL8sK6oCfeVWH3mYCpykxunxYJ5wa6jbxoDF/hsKbs2x QgoQDuG+ostWucj+a4IfDfF73MZ1YIH1fcJtxEe/23bJv6GB+mNAuFphL0hYiW29OpnW rg7yvziob0FAYDxcX6fme4hnrvatCuN0Lmn5tqN+aZ34cEtdONDE5Dty83m4VLZjDOkZ 7JSJI3nWW24xdW5+WbBkFnDOsAxSHS+B1FaheuOenVnRMNSREKW2A6rw3aXMc/ZnCvzK gJWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l1-20020a635b41000000b0046ebb8f5cb4si13296995pgm.691.2022.11.15.14.14.57; Tue, 15 Nov 2022 14:15:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230136AbiKOVrN (ORCPT + 90 others); Tue, 15 Nov 2022 16:47:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231409AbiKOVrF (ORCPT ); Tue, 15 Nov 2022 16:47:05 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5602AE7A; Tue, 15 Nov 2022 13:47:04 -0800 (PST) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.94.2) (envelope-from ) id 1ov3le-0005Hm-IC; Tue, 15 Nov 2022 22:46:54 +0100 Date: Tue, 15 Nov 2022 21:45:29 +0000 From: Daniel Golle To: Jens Axboe , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Matthew Wilcox , Daniel Golle , "Martin K. Petersen" , Chaitanya Kulkarni , Michal Orzel , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org Subject: [PATCH v5 1/4] block: add new flag to add partitions read-only Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00,PDS_OTHER_BAD_TLD, SPF_HELO_NONE,SPF_PASS autolearn=no 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 Add flag ADDPART_FLAG_READONLY to allow partition parsers marking a partition to be set read-only. This is needed for the uImage.FIT partition parser added by a follow-up commit: we need to be sure the contents of uImage.FIT sub-images remain unaltered they are validated using a hash within the uImage.FIT structure which also serves as partition table. Signed-off-by: Daniel Golle --- block/blk.h | 1 + block/partitions/core.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/block/blk.h b/block/blk.h index e85703ae81dd..05ac426350b2 100644 --- a/block/blk.h +++ b/block/blk.h @@ -414,6 +414,7 @@ void blk_free_ext_minor(unsigned int minor); #define ADDPART_FLAG_NONE 0 #define ADDPART_FLAG_RAID 1 #define ADDPART_FLAG_WHOLEDISK 2 +#define ADDPART_FLAG_READONLY 4 int bdev_add_partition(struct gendisk *disk, int partno, sector_t start, sector_t length); int bdev_del_partition(struct gendisk *disk, int partno); diff --git a/block/partitions/core.c b/block/partitions/core.c index b8112f52d388..355646b0707d 100644 --- a/block/partitions/core.c +++ b/block/partitions/core.c @@ -398,6 +398,9 @@ static struct block_device *add_partition(struct gendisk *disk, int partno, goto out_del; } + if (flags & ADDPART_FLAG_READONLY) + bdev->bd_read_only = true; + /* everything is up and running, commence */ err = xa_insert(&disk->part_tbl, partno, bdev, GFP_KERNEL); if (err) -- 2.38.1