From mboxrd@z Thu Jan 1 00:00:00 1970 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.2 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,URIBL_BLOCKED,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 3D8ADC433DB for ; Sun, 14 Feb 2021 15:28:24 +0000 (UTC) X-Greylist: delayed 343 seconds by postgrey-1.34 at mail.kernel.org; Sun, 14 Feb 2021 15:28:23 UTC DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1DB1564E56 Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=lists.ozlabs.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1DB1564E56 for ; Sun, 14 Feb 2021 15:28:23 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4DdrZl4rQ8z30Gt for ; Mon, 15 Feb 2021 02:22:39 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ozlabs.org; s=201707; t=1613316159; bh=1o4tD7/vbQrfp7EtTi5HAawZb5YthZ+Vk907CfdaW/w=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=QUI/ungk3vrinzZmu5NyFC2oGndcF+o9rmot6Yt2f4tTwbs3ivNfKQIu1i+QAC1Vh kT9pzU1ikwJygKlhlKFF2yA5q67wPEwIz/TeFQRAM86SHh/PVnBUj7uir50Z6iqPTY AuTJZBWvHOU/tL3sUlQ2qWL33XGXLyQ6HubDNFgtkbWh3xs+ldyxt0OZTx9xO8lJ21 QGNjgR1Za2uCusXAZWDdKXWAsV9Mq1tfLyWKQGgJVniG3pyCfg5azjjbZqh6alQJXx Zi64OB2mS1zPKWLAF3t+qq123xMSBlpM53PE6pSvSmg2GvXUTlq6Dxk+avpxz7f8tD HbhORMG2xbxEg== Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aol.com (client-ip=98.137.68.205; helo=sonic304-24.consmr.mail.gq1.yahoo.com; envelope-from=hsiangkao@aol.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aol.com header.i=@aol.com header.a=rsa-sha256 header.s=a2048 header.b=D4r2Etq8; dkim-atps=neutral Received: from sonic304-24.consmr.mail.gq1.yahoo.com (sonic304-24.consmr.mail.gq1.yahoo.com [98.137.68.205]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4DdrZh3BYWz2yRg for ; Mon, 15 Feb 2021 02:22:32 +1100 (AEDT) X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1613316147; bh=TAaUx+T3H4RSKyLL/C+Qxiqa4AK6C+moknH+H9Dr+Oz=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=MyQIztfpPeRnJSFd7Aurz6tn6x0nfyrT/FAs+j9sbRb6i8uDhtHAHRJAxiExHH8S9wN5cBnu4vwfI5KIfzX0b2pWcm1zLK3XcfEHYANcKtcp00za2WY2V3o6jinba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975BE3dW_xsU2c6zffp6fHLMrUtV08LpnznzaZyPjk2gQrN8pc r.2Examd3GkbZvcDCiS8P6BCTVg8s4lVwfPqkJ6plec4hZ_6j9rZJnS1CUK3tDoR1qOo_VK5euJN ViYlUx8vIxv536furqglDu29Kv73hEmupdfvMV_jMmPX02IR.1sVFF5o1mSwj5RVBRsDC9RoLjMX sYnyWWatMu_.stKtmwG0HZMBwtr6QDRTShBjEJOv3bEnWWDAZuQa_eaQqms50cnlFaiLXnbedXNq MSFwqCD_YmnjlFo5mY4ShXwCkDJrliTxPE6K3yanspwHXF40SzjYRyTWRg0aLM4OSBYPrjQzkDpC zqfmJT_sLM87kI4N9CQGMWhv9YP4x.W..rce9r.JmTdOJzLVKItzEPow_eLxBma9XZaHxsVPa1Av tZ7604Cs5wWrRN_7cLUqwlljr8keO3PLwHvaEpitX2W5.764ZKTq6mciEKlrcmATTI9KDiZWhu_4 XNI1uZ3.iDUkNZhvyBhQViWL2C6WY9eIifsal1k6UCWlEiGNlOWZ3q3td0LfNcpg_LPtWfqDLoL7 OltlUYg_gs.mxdAq2hVKLf4.0HMv3.G8hYlpgVx45yDPpdRM7vA-- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.gq1.yahoo.com with HTTP; Sun, 14 Feb 2021 15:22:27 +0000 Received: by smtp424.mail.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID f44844d2a2b523938aa04bf428a617e8; Sun, 14 Feb 2021 15:22:22 +0000 (UTC) Date: Sun, 14 Feb 2021 23:22:07 +0800 To: Hu Weiwen Subject: Re: [PATCH v2] erofs-utils: fix battach on full buffer block Message-ID: <20210214152201.GA29988@hsiangkao-HP-ZHAN-66-Pro-G1> References: <20210120051216.GA2688693@xiangao.remote.csb> <20210121162606.8168-1-sehuww@mail.scut.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210121162606.8168-1-sehuww@mail.scut.edu.cn> User-Agent: Mutt/1.10.1 (2018-07-13) X-Mailer: WebService/1.1.17712 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol Apache-HttpAsyncClient/4.1.4 (Java/11.0.9.1) X-BeenThere: linux-erofs@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development of Linux EROFS file system List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Gao Xiang via Linux-erofs Reply-To: Gao Xiang Cc: linux-erofs@lists.ozlabs.org Errors-To: linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Sender: "Linux-erofs" Hi Weiwen, On Fri, Jan 22, 2021 at 12:26:06AM +0800, Hu Weiwen wrote: > When __erofs_battach() is called on an buffer block of which > (bb->buffers.off % EROFS_BLKSIZ == 0), `tail_blkaddr' will not be > updated correctly. This bug can be reproduced by: > > mkdir bug-repo > head -c 4032 /dev/urandom > bug-repo/1 > head -c 4095 /dev/urandom > bug-repo/2 > head -c 12345 /dev/urandom > bug-repo/3 # arbitrary size > mkfs.erofs -Eforce-inode-compact bug-repo.erofs.img bug-repo > > Then mount this image and see that file `3' in the image is different > from `bug-repo/3'. > > This patch fix this by: > > * Don't inline tail-end data in this case, since the tail-end data will > be in a different block from inode. > * Correctly handle `battach' in this case. > > Signed-off-by: Hu Weiwen > --- Now I get what you mentioned to, and I think this is a valid case and might influence old versions (even I have no idea how to reproduce it effectively.) So I tend to apply this patch right now, and thanks for your patch! Reviewed-by: Gao Xiang With updated commit message below: When the subsequent erofs_battach() is called on an buffer block of which (bb->buffers.off % EROFS_BLKSIZ == 0), `tail_blkaddr' won't be updated correctly. This bug can be reproduced by: mkdir bug-repo head -c 4032 /dev/urandom > bug-repo/1 head -c 4095 /dev/urandom > bug-repo/2 head -c 12345 /dev/urandom > bug-repo/3 # arbitrary size mkfs.erofs -Eforce-inode-compact bug-repo.erofs.img bug-repo Then mount this image and see that file `3' in the image is different from `bug-repo/3'. This patch fix this by: * Handle `oob' and `tail_blkaddr' for the case above properly; * Don't inline tail-packing data for such case, since the tail-packing data is actually in a different block from inode itself even kernel can handle such cases properly. Thanks, Gao Xiang