Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1FE3C4338F for ; Thu, 5 Aug 2021 01:19:14 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2E2DF60F25 for ; Thu, 5 Aug 2021 01:19:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2E2DF60F25 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EB81582DF1; Thu, 5 Aug 2021 03:19:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="XSVIVAP1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1AEB082CF1; Thu, 5 Aug 2021 03:19:03 +0200 (CEST) Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C1CEB82BEC for ; Thu, 5 Aug 2021 03:18:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qk1-x72f.google.com with SMTP id x3so4722752qkl.6 for ; Wed, 04 Aug 2021 18:18:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=hYvzdA34XfyzBEkOp1JRvKtTNw2j2A8LNKwchFeOiQI=; b=XSVIVAP14HO9ZzwmWRnEeYSpY/f4DJPahdp7ctKMTgj/uXh3WBha9aMfAuZM7ROuGM Dj5d6Ua5zwp2jFixsOpfQNTaJp6dz8v7d/M/tbNdKJebmxBx8CYIthIGPpKJRISGHnkW PcuQgTCeRq6aAPdGtzuza2yWoYrpiV7GkRCQQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=hYvzdA34XfyzBEkOp1JRvKtTNw2j2A8LNKwchFeOiQI=; b=WfA1KMsHKN4rK90DGjNai40xp7jIQu4MtC0+p1jnFf0cNCwAExbGK8A1LszY16WcJQ /bpNJmY55eVRojHJY93sbVHqH/HMtHdDhh0xH0+kPqZok0QHX7sN4q6LN7FrEftoxg27 CjxCsZCJBDsEJkNZZHa3QE12v9QNsnxzf78OSBCz0zpPiQ8d+ptO2gNB07LSL9y6k6BW iIDSB1P8sLkzJvUAMXNsFGjRnIY8xRc7vWnsvjdFBgLiSdb7CJHdayrxyBXlUvhQoqSS JGInBvSBi7xtbokkhRcVcL4jmLhTuBtuxji3KSeCFD2Uf4QuSo1/jYf3CeKaHmUThKfH Eb8Q== X-Gm-Message-State: AOAM533l6Ve1Jj/bvQpKVpNZfvFEa3x3wTsvchIrrjlhNZYa1zF0vaUX UYY5dzwkhhUT0ZRkxiqquhhnzg== X-Google-Smtp-Source: ABdhPJxDXtl6jh+MMJENbDe5Fr8ZuAhaGHwQelHUUTP166TVCnAELK0mx8Mdqsdx6/m/v8AmHzzqWA== X-Received: by 2002:a05:620a:1498:: with SMTP id w24mr2301626qkj.349.1628126336614; Wed, 04 Aug 2021 18:18:56 -0700 (PDT) Received: from bill-the-cat (2603-6081-7b01-cbda-a9d9-7fe0-6131-a526.res6.spectrum.com. [2603:6081:7b01:cbda:a9d9:7fe0:6131:a526]) by smtp.gmail.com with ESMTPSA id x10sm2142546qkl.82.2021.08.04.18.18.55 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Aug 2021 18:18:55 -0700 (PDT) Date: Wed, 4 Aug 2021 21:18:54 -0400 From: Tom Rini To: Campbell Suter Cc: u-boot@lists.denx.de, Joao Marcos Costa , Thomas Petazzoni , Miquel Raynal Subject: Re: [PATCH] fs/squashfs: Fix some hardlinks reading the wrong inode Message-ID: <20210805011854.GE858@bill-the-cat> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="y2zxS2PfCDLh6JVG" Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.9.4 (2018-02-28) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean --y2zxS2PfCDLh6JVG Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Apr 30, 2021 at 04:45:46PM +1200, Campbell Suter wrote: > In SquashFS, the contents of a directory is stored by > squashfs_directory_entry structures which contain the file's name, inode > and position within the filesystem. >=20 > The inode number is not stored directly; instead each directory has one > or more headers which set a base inode number, and files store the > offset from that to the file's inode number. >=20 > In mksquashfs, each inode is allocated a number in the same order as > they are written to the directory table; thus the offset from the > header's base inode number to the file's inode number is usually > positive. >=20 > Hardlinks are simply stored with two directory entries referencing the > same file. This means the second entry will thus have an inode number > much lower than the surrounding files. Since the header's base inode > number comes from the first entry that uses the header, this delta will > usually be negative. >=20 > Previously, U-Boot's squashfs_directory_entry.inode_offset field was > declared as an unsigned value. Thus when a negative value was found, it > would either resolve to an invalid inode number or to that of an > unrelated file. >=20 > A squashfs image to test this can be created like so: >=20 > echo hi > sqfs_test_files/001-root-file > mkdir sqfs_test_files/002-subdir > touch sqfs_test_files/002-subdir/003-file > ln sqfs_test_files/{001-root-file,002-subdir/004-link} > mksquashfs sqfs_test_files/ test.sqfs -noappend >=20 > Note that squashfs sorts the files ASCIIbetacally, so we can use the > names to control the order they appear in. The ordering is important - > the first reference to the file must have a lower inode number than the > directory in which the second reference resides, and the second > reference cannot be the first file in the directory. >=20 > Listing this sample image in U-Boot results in: >=20 > =3D> sqfsls virtio 2 002-subdir > 0 003-file > Inode not found. > 0 004-link >=20 > Signed-off-by: Campbell Suter > Reviewed-by: Miquel Raynal Applied to u-boot/master, thanks! --=20 Tom --y2zxS2PfCDLh6JVG Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmELPH0ACgkQFHw5/5Y0 tyzD1gwAjsgjzWJZfvU964rhYD45H/rUNX/15/8AzAlafqy7f6hMHzMjpkMJAg6Y h/5WCXvIGDgXV97HsEr+hD6KvCtvRBumjnVaFmssMNBOt0vN3NeB9HfLqDUqHuAB kdJBp5/6M5CL69TrW+BIbuP81R1Rye17xa8nhsVSghdlNMdfepku4pVQaXCsZPj7 lhjF2lPU/lz6vi+qLEet9Y5XgwJ8mVTCJxPov+eKoWMyUHHSgBMYcw2AVFcgikTU oWivxMre7uextUpXwoBCyCOpubXS5QKRJtSCkNTs/x28+nNNZ2kl249jkg9YlAIN WRAzImq0NRhwIywpAL/KNXJ8t0uAYSrMu1uIjUaXcza0JKrAs0zms9IPZuIK330T L3I2YaSqWywJCQFZ6msvs0MALH+nNPtbCxK+8qF3rnfWwcOKam4ksxm32HUSpcqE 2Ob3Osx4wgC1pXBsAIEs+KENQrZvByfPk2sx61YXUJ/7eER3RJcBzOARMD4Qz3sn bnkxnhY6 =3iLs -----END PGP SIGNATURE----- --y2zxS2PfCDLh6JVG--