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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4DA6EC43334 for ; Fri, 3 Jun 2022 19:49:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ABDA58434B; Fri, 3 Jun 2022 21:48:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (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="L4vuP0aW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E40E284339; Fri, 3 Jun 2022 21:48:45 +0200 (CEST) Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) (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 EEA00842F9 for ; Fri, 3 Jun 2022 21:48:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qt1-x829.google.com with SMTP id j8so3651068qtn.13 for ; Fri, 03 Jun 2022 12:48:41 -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; bh=Bvg2e96ZhL6I+qZzvTkLbn1twCiN2JwOBoSvAuBiLHg=; b=L4vuP0aWmvuIrU9imrFOzPgPIAsH5JdLCe6Y5i5KwywFx2KsRGF5knhneIU4nLhJBm QMi+SDyKTnLAe5WUHQB+woJlj+J7cehXBRkUX1wWz+E3mZhnSAf80Q8P1/iJT6zv88J9 5Ll+hukmigBrNaFutv+E1wwNPzlx2/38gv5VM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Bvg2e96ZhL6I+qZzvTkLbn1twCiN2JwOBoSvAuBiLHg=; b=xdFve0DCaxmIe7ZBpPgEnPpEayYk5/7p5dfPZpVIWww/hDJ/u+Ei7IOQDzr7UX/2tv WK+ZFPmVk+Tdub6xpLYEQPltHYzn2Q4ZxWMUNo7CCSHHEZ67uLr/SgOSpgbR9ffkfurP Qlwr/XvuQqOmmxHvWkmThh4x3rB4rtlmtQKrfcd6oSIjYtR5uveioO2n4OBtt6zQkGn6 IqOw4Co10q8khQfbKta7UKZRI4TaoXt6SGSpxUe22YqID7e8BPUqX31KnzCS23HwaQGt IhkMMhRgh7UupKojeUuJn8yUxKtRXOqS/nuUJ/W7URM6XSaroeLyDxql+OW2BABkJdC5 2f6A== X-Gm-Message-State: AOAM533je5hENYhRpmA7JL/KjvGenv1X/oYhi0EhYTT8f9D0B48AGbnM DHLMnFqNCgyf/KfgrMUGPYdEuFZ4Mni+7g== X-Google-Smtp-Source: ABdhPJx3xqwKdraUYpocIcgxfcmW9ExZ/ak8yJx3T9rO8LZdg9hFwy8EKhKtCywGHgEjIlpvvsAPiA== X-Received: by 2002:a05:622a:1456:b0:2f9:4569:1338 with SMTP id v22-20020a05622a145600b002f945691338mr9020175qtx.385.1654285720454; Fri, 03 Jun 2022 12:48:40 -0700 (PDT) Received: from bill-the-cat (2603-6081-7b01-f800-5c43-9e45-17fb-de1a.res6.spectrum.com. [2603:6081:7b01:f800:5c43:9e45:17fb:de1a]) by smtp.gmail.com with ESMTPSA id r12-20020ac8424c000000b00304dec6452csm1836000qtm.78.2022.06.03.12.48.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jun 2022 12:48:39 -0700 (PDT) Date: Fri, 3 Jun 2022 15:48:37 -0400 From: Tom Rini To: Pali =?iso-8859-1?Q?Roh=E1r?= Cc: Stefan Roese , u-boot@lists.denx.de Subject: Re: [PATCH] ubifs: Fix lockup/crash when reading files Message-ID: <20220603194837.GH1958597@bill-the-cat> References: <20220517204528.7277-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="U3BNvdZEnlJXqmh+" Content-Disposition: inline In-Reply-To: <20220517204528.7277-1-pali@kernel.org> X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.5 at phobos.denx.de X-Virus-Status: Clean --U3BNvdZEnlJXqmh+ Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, May 17, 2022 at 10:45:28PM +0200, Pali Roh=E1r wrote: > Commit b1a14f8a1c2e ("UBIFS: Change ubifsload to not read beyond the > requested size") added optimization to do not read more bytes than it is > really needed. But this commit introduced incorrect handling of the hole = at > the end of file. This logic cause U-Boot to crash or lockup when trying to > read from the ubifs filesystem. >=20 > When read_block() call returns -ENOENT error (not an error, but the hole) > then dn-> structure is not filled and contain garbage. So using of dn->si= ze > for memcpy() argument cause that U-Boot tries to copy unspecified amount = of > bytes from possible unmapped memory. Which randomly cause lockup of P2020 > CPU. >=20 > Fix this issue by copying UBIFS_BLOCK_SIZE bytes from read buffer when > dn->size is not available. UBIFS_BLOCK_SIZE is the size of the buffer > itself and read_block() fills buffer by zeros when it returns -ENOENT. >=20 > This patch fixes ubifsload on P2020. >=20 > Fixes: b1a14f8a1c2e ("UBIFS: Change ubifsload to not read beyond the requ= ested size") > Signed-off-by: Pali Roh=E1r > Reviewed-by: Stefan Roese Applied to u-boot/master, thanks! --=20 Tom --U3BNvdZEnlJXqmh+ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmKaZZUACgkQFHw5/5Y0 tyybegv+Opp0URUtLSJ3f10pjlhk7sSEyExMJb5vTbtDn/4G0cVupGwGCYiXZbhn XaItZyLDP5pV9kEyN50/98nhLShfUdLxi/yGIeteYq3R9/3F3gdsX6XpXwzI1MDI WDr4mCIVzJV6g+rLhAfRDHmDX4X22ghpCGDVB33/ZqyovxM5E0cn/tN8wJehd9h3 z9fZeFZn4HPoZWThm2yj5hq9Hbly6UdWRvS51Fjaa45/tbDuYOmN6xQZFimNI907 0vW6UCxHCOxgx//Yk4gKb696RXC7TzDvOzpdWh8j7oqgGkn3W2NaG+u8FJ2FkTpr aUuE7M3T2/EgOZcBrLJ/7UVxboV7ezgMVJZUKAgHIFnHoXbe70T2QWalni8UXg3Y 6WoTtn6zdAog7pyDXrxltpbw5u33yUTs+jZXwsTpzUlj7so1CJzmdUWCTfju2VsI t8XkSH8D/yNE1cPlskM3DYwojfmpRucDxBlDt+riN5MybuBje63oiC6qChugcmF6 8wnZGCBz =deBV -----END PGP SIGNATURE----- --U3BNvdZEnlJXqmh+--