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=-6.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS, URIBL_BLOCKED,USER_AGENT_MUTT 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 C2ABBC43387 for ; Thu, 27 Dec 2018 20:59:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8EABA218FE for ; Thu, 27 Dec 2018 20:59:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1545944372; bh=Kg/hr3ezvZjsyP0da0Fib3LSsAimrW2uigoZ97Pita0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=N+FC74XPMYW6xsh58iKxOb1CUzR7glaGdf+hXRDogqIz5lAOhX3FwvctMlaTQ8rb5 gNJ4OtemNQKsO2YctFEbpW3rFUV2DsTLk93XPw+oK4SWWEoq32uDrrb4toPfRhyXOD T9u5mzJQfhOExFUjZBFuk2YP+MYEX1wp2NdtoexY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729659AbeL0U7c (ORCPT ); Thu, 27 Dec 2018 15:59:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:54156 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729478AbeL0U7b (ORCPT ); Thu, 27 Dec 2018 15:59:31 -0500 Received: from localhost (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B92312148D; Thu, 27 Dec 2018 20:59:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1545944371; bh=Kg/hr3ezvZjsyP0da0Fib3LSsAimrW2uigoZ97Pita0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=zw1JC0y0SuF5NmNoBkBn3wAvlhaIeFncJ6vnsk8545OHxAy1EDDrBU+miZkl847Ez gg1lC3hfy3xG8+IWkCVMmvZR8qm2lpu5lPHhuR6k1LAJAxAanGx9+Xl4K/xD59on74 u4xnyorBQ1dIpqrZmF1t2fxwCv9hM2BGYpjC5K9M= Date: Thu, 27 Dec 2018 15:59:29 -0500 From: Sasha Levin To: =?utf-8?B?UmFmYcWCIE1pxYJlY2tp?= Cc: stable@vger.kernel.org, Greg Kroah-Hartman , Richard Weinberger , =?utf-8?B?UmFmYcWCIE1pxYJlY2tp?= , Russell Senior Subject: Re: [PATCH stable] ubifs: Handle re-linking of inodes correctly while recovery Message-ID: <20181227205929.GU86645@sasha-vm> References: <20181226123211.24969-1-zajec5@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20181226123211.24969-1-zajec5@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Wed, Dec 26, 2018 at 01:32:11PM +0100, Rafał Miłecki wrote: >From: Richard Weinberger > >commit e58725d51fa8da9133f3f1c54170aa2e43056b91 upstream. > >UBIFS's recovery code strictly assumes that a deleted inode will never >come back, therefore it removes all data which belongs to that inode >as soon it faces an inode with link count 0 in the replay list. >Before O_TMPFILE this assumption was perfectly fine. With O_TMPFILE >it can lead to data loss upon a power-cut. > >Consider a journal with entries like: >0: inode X (nlink = 0) /* O_TMPFILE was created */ >1: data for inode X /* Someone writes to the temp file */ >2: inode X (nlink = 0) /* inode was changed, xattr, chmod, … */ >3: inode X (nlink = 1) /* inode was re-linked via linkat() */ > >Upon replay of entry #2 UBIFS will drop all data that belongs to inode X, >this will lead to an empty file after mounting. > >As solution for this problem, scan the replay list for a re-link entry >before dropping data. > >Fixes: 474b93704f32 ("ubifs: Implement O_TMPFILE") >Cc: stable@vger.kernel.org # 4.9-4.18 >Cc: Russell Senior >Cc: Rafał Miłecki >Reported-by: Russell Senior >Reported-by: Rafał Miłecki >Tested-by: Rafał Miłecki >Signed-off-by: Richard Weinberger >[rmilecki: update ubifs_assert() calls to compile with 4.18 and older] >Signed-off-by: Rafał Miłecki >(cherry picked from commit e58725d51fa8da9133f3f1c54170aa2e43056b91) Queued for 4.14 and 4.9, thank you. -- Thanks, Sasha