Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4334600rwb; Tue, 8 Nov 2022 15:48:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Yw1GlZEcsjuBUQFbV2FrR3EDR9Uis50eidaDJEsCmh45HHR4EG0Mj5wAaKtpkoDRtvC7i X-Received: by 2002:a63:fc16:0:b0:470:7889:4993 with SMTP id j22-20020a63fc16000000b0047078894993mr11591567pgi.317.1667951305993; Tue, 08 Nov 2022 15:48:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667951305; cv=none; d=google.com; s=arc-20160816; b=YzZjhvfZVKa1Mw8pv8fcfXCCb7Onx3XuexW1phR91ltomi4FqO91B4Tjd1OHu1rbUw cmoR/NE0hcxXkuEs7wqDOtDCnXQqGE29XbMOuWfzUCbQpL1wzpwq7XC1Gc2n29QtrRVv imhs5mTyOkFxQ5KnXyFhpLRHYRUGKL558H5/16roZq793l1kTZXUqn8ZfoaSlquxdRhB Zbcmw+991Cnul3K3ZbX3TF4/Fhy4VJNSVJ4E0GAoo2Ob/D22I6M9xH8kUi2Nmw+j87wt PN7oMb6c9Zwk8xBxYKwG/InS98QPu9vojyHLLWyL+yVxpjxU9AGgHjOohaPBMLXdgOoj 3AGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date; bh=QL8a0deLAuhj1IQrO+ZAK2NOnJRVmLLYuYU2Bz1xQ2g=; b=T97LHs/zP71fF8ZqDUs9r8fOVncYVCARTKe0wwhtriMRe8CECbtinJVN0u3JYKOOkP Ppv7WiRM9bCvs48T/6QqaVNH+/WUHkx79nVOzT06rL6ByaZu7FOGWsU42sHOTPgwY9T5 GJnRrcXvxnGmayhwESc/iS/UggeIEGbb8B0v/iF489rLzkGbsQcL4OmLVKWqfl0+oTMs RmDVDKRrEzy9+yOqTlXqj0wVi9//IEgW4w6G2V3CLc0cs3hLjDWAfhAh6p4sDTMPJJq7 2hG+BDcYax83+F3IensrwwwroTlVdahp1BdmUMDYsWpv+Cr8k0Oc2icZCk6ILsO5NPsG KaPw== 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 oa10-20020a17090b1bca00b00214021e87d1si21711879pjb.173.2022.11.08.15.48.14; Tue, 08 Nov 2022 15:48:25 -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 S229907AbiKHXE2 (ORCPT + 92 others); Tue, 8 Nov 2022 18:04:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbiKHXE1 (ORCPT ); Tue, 8 Nov 2022 18:04:27 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1C4C6314B; Tue, 8 Nov 2022 15:04:26 -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 1osXde-0005td-94; Wed, 09 Nov 2022 00:04:14 +0100 Date: Tue, 8 Nov 2022 23:02:49 +0000 From: Daniel Golle To: Jens Axboe , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Davidlohr Bueso , Matthew Wilcox , "Martin K. Petersen" , Chaitanya Kulkarni , Daniel Golle , Ming Lei , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH v4 1/5] block: add new flag to add partitions read-only Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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