Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4289302pxv; Mon, 19 Jul 2021 23:20:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWCXJBBcJxyvhuiTzHT14MMukHFIUce8N/uYQfmZT/d0BGhTlf4NuI8HZBgX5tiXF6p2Jt X-Received: by 2002:a17:906:2a07:: with SMTP id j7mr7355885eje.386.1626762056161; Mon, 19 Jul 2021 23:20:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626762056; cv=none; d=google.com; s=arc-20160816; b=Bu+OmsMG+LY0Eqz8wkXIVNLXfppfYqQB3KckSNi8b8Gu0tgjke+2MtC5dHZoZqS76n H/G37kLPNjMEj7YsYS/ZkVfic46BLPm6/b1y8jMiWIq7H3Tv1Y3D/CjHyDmB/zRIhO4z A0EllBBFUSl/TAumI7YB9i78t9KEtoYIdNiUOY8NGfrshJZo0rQwMdCkIF29ijvCrSfN 9r70J8WM+a8oldAtRPosCC2FpFFZRL+TeQ719JGhBamlkfYyuMVG+zVox1jRyuqEabRz eiPQjSq4wic/ZojNbdptR+T4uVZAsknS0rdVnbwDqYUsNNCtFLmXGuX+Jiklzk2zCjP2 aZtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=i0kMgSuHZ4kPt4sP1uRhzPOM7Gd+u7oji/d01Xfy6CI=; b=Va/9cwr76O6wFEZB5uDwU9kS1RGTXrO8FmqdZg/UdVxA0bxofwrfNQryHx2XGlFtCM q+ib2OXDS5tWIVIN3t15jsk6hzrhTfOuTpC5R6KqXdsieqZGWbMeuMXZkYDUfxd0uDzB P0JJfiYoQQazDpO1eDtINMhq2odKD7OujJQPYoaFN2Yu6Ru50Oa8anSEM+eMoNswcJS7 70qd9DXaLSrCrqTOfnm8biwe6I5fCB6NUz16rcnzNcLfF9Kj7542iPfP9vO5qx51V+kq AuOc3kfm9pZC/y9mfEc6JNpPIaz5iTPuImUcqUl5a7asCZ1RR5XVPytzPhpIhSkXTiNO LtFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JN4hdVZX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k6si23551314edr.316.2021.07.19.23.20.32; Mon, 19 Jul 2021 23:20:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JN4hdVZX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238998AbhGTFhu (ORCPT + 99 others); Tue, 20 Jul 2021 01:37:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241086AbhGTFhk (ORCPT ); Tue, 20 Jul 2021 01:37:40 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A658FC0613E1; Mon, 19 Jul 2021 23:18:02 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id ca14so27129918edb.2; Mon, 19 Jul 2021 23:18:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=i0kMgSuHZ4kPt4sP1uRhzPOM7Gd+u7oji/d01Xfy6CI=; b=JN4hdVZX4kVjpEa2ZUVU46PqVLYNHzXlDz6vh8HxpEVP4n6GlVPer5Vm0zzRm+Og7U znr42WF/93H00R0SFA/Qmi50tfGItf8ENCn+XUZ+BeRdtA2JQ2bPplCqJtVvkpMrWlnI 79d8dzSKR3IwP/cbOvmjbFjrRHaTN6IbpmrkBxJYTuEJ7nstVhhJSSl1tPG4LTXtEdNV DeTpaKZuahpiFUsuLQOHmRJqq7gMn1vlXB7X05G6bdEpvaS0+VFTmODa8NCj2foTHHVj sBdBYyYZuYz1GvR1nI4P+5U5+PVPRLP0j9OZbN2OhhSDgb6K7tUcqzy4KWPg4qvnqdrr QcsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=i0kMgSuHZ4kPt4sP1uRhzPOM7Gd+u7oji/d01Xfy6CI=; b=sdunnJqf+pVx419Kr/gvObzUwkX0gMi8FQpANXgtN1MIM+Al5D+5RWKraS9GvAuZKI WkATo2Jxwlgm4hbyIR9756Wm6GnOsrnE6AvamXEDESvtSpG7NB4BP9KLrewvGZeV8gJC af8EgHXBaewKLDodd4ahsNQpqPxVecbymFtTVWKyur5whOp4PxugfsBMsyMIIBHac7m+ FMeIWAHjCFOY2/WCVXzvVEULjBjspJWouSV/OuRog9ZuxigcyPKbv9tgljFXx/biZXu0 SOYBgtBi4sCegzUHNHhxCduWWFiLAWMY99OnaZfTMuE8+JcCq+00m7foWa0CRn+LLY5i EVJw== X-Gm-Message-State: AOAM532UzJu+suePz0fdeBf+SPF2bSI4mCa8vqwYKNoPea0b3u2t2CFQ hwSex+FHYWShwbqu8rtPWOFEuGhhJUkPwNni3E0= X-Received: by 2002:a05:6402:270d:: with SMTP id y13mr39156656edd.66.1626761881202; Mon, 19 Jul 2021 23:18:01 -0700 (PDT) MIME-Version: 1.0 References: <568938486.33366.1626452816917.JavaMail.zimbra@nod.at> <1458549943.44607.1626686894648.JavaMail.zimbra@nod.at> In-Reply-To: <1458549943.44607.1626686894648.JavaMail.zimbra@nod.at> From: Pintu Agarwal Date: Tue, 20 Jul 2021 11:47:49 +0530 Message-ID: Subject: Re: MTD: How to get actual image size from MTD partition To: Richard Weinberger Cc: Greg KH , linux-kernel , linux-mtd , linux-fsdevel , Phillip Lougher , Sean Nyekjaer , Kernelnewbies Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 19 Jul 2021 at 14:58, Richard Weinberger wrote: > > ----- Urspr=C3=BCngliche Mail ----- > > Von: "Pintu Agarwal" > > An: "richard" > > CC: "Greg KH" , "linux-kernel" , "linux-mtd" > > , "linux-fsdevel" , "Phillip Lougher" > > , "Sean Nyekjaer" , "Kernelne= wbies" > > Gesendet: Montag, 19. Juli 2021 11:09:46 > > Betreff: Re: MTD: How to get actual image size from MTD partition > > > On Fri, 16 Jul 2021 at 21:56, Richard Weinberger wrote= : > > > >> >> My requirement: > >> >> To find the checksum of a real image in runtime which is flashed in= an > >> >> MTD partition. > >> > > >> > Try using the dm-verity module for ensuring that a block device real= ly > >> > is properly signed before mounting it. That's what it was designed = for > >> > and is independent of the block device type. > >> > >> MTDs are not block devices. :-) > >> > > Is it possible to use dm-verity with squashfs ? > > We are using squashfs for our rootfs which is an MTD block /dev/mtdbloc= k44 > > Well, if you emulate a block device using mtdblock, you can use dm-verity= and friends. > Also consider using ubiblock. It offers better performance and wear level= ing support. > Okay thank you. We have tried dm-verity with squashfs (for our rootfs) but we are facing some mounting issues. [...] [ 4.697757] device-mapper: init: adding target '0 96160 verity 1 /dev/mtdblock34 /dev/mtdblock39 4096 4096 12020 8 sha256 d7b8a7d0c01b9aec888930841313a81603a50a2a7be44631c4c813197a50d681 aee087a5be3b982978c923f566a94613496b417f2af592639bc80d141e34dfe7' [ 4.704771] device-mapper: verity: sha256 using implementation "sha256-generic" [...] [ 4.727366] device-mapper: init: dm-0 is ready [ 4.912558] VFS: Cannot open root device "dm-0" or unknown-block(253,0): error -5 The same works with ext4 emulation. So, not sure if there are any changes missing w.r.t. squashfs on 4.14 kerne= l ? Anyways, I will create a separate thread for dm-verity issue and keep this thread still open for UBI image size issue. We may use dm-verify for rootfs during booting, but still we need to perform integrity check for other nand partitions and UBI volumes. So, instead of calculating the checksum for the entire partition, is it possible to perform checksum only based on the image size ? Right now, we are still exploring what are the best possible mechanisms available for this. Thanks, Pintu