Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3311404pxf; Mon, 15 Mar 2021 06:55:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDeShO5HW4p+6ryMPG0/PtS6+F7NdIiArHaVI/EKg+9pJbSryulZCBFPmowG7zOf2g7Tar X-Received: by 2002:a17:906:b752:: with SMTP id fx18mr24339711ejb.128.1615816559651; Mon, 15 Mar 2021 06:55:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615816559; cv=none; d=google.com; s=arc-20160816; b=CkpBnjeLdDm9xR29Isa2Jys9+k9XSX60kY6IWzuokJ9ulBEOKKAIwpZ3kFKKakrcWU g+cRqdSwf5IPuyVjobSLBUY9vDiDz3EcmzjjZG6psp9mvuPrn0X7sj5Bvm/T0sRxmev5 7UXsTVwq9/FMc+VNR/llE5ZURpftGLcpKat/H7OW2Ok8puYWxQG3v5D2R5hm53T9qao+ d+z+tf0s4+oGgywcz9Y78JnfbsraZ452+sYK0AeIko+8cvtuiUlXd3m7pwgW7Naflg6J oltMJ0mLH2rIQYiVUjjhgaRMsHOgjmwSlGn0G75KLyISdUopPODpeEPjRsaqqqtQwISK vjQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vhWqIjXmpRo+Ru/gHzpvz9+6Xnlp68ceb7yfUJcQLeE=; b=nNa8OUi0+FmPOH2lF4F9JRJK0SKPzgzHaIT93q1CMcFPH0dNveaJt/aETXqoQua+FI K2gOvNHB3RZaW01lk8iAD/2LC3YXrKY8aPjcLkvtQezKZlHDODCJ50x+QPnKM9eFzFTo cac2Gw88ww9ZZb0bkOZCZaCs3Y45ZfrREYlhJxXsJBNvEqzspt/aNH6tUF7Qlcl9UYG+ Eh5UCTSVy3jehZ3HCaF/Fq2tOne9u2KRs46cil7a+77RrjEesPHljhXARaRy8Mr3cGJE jyNVw9genGol5c8U/GCxGeKNCjzD3OJERKgdfImrgbgoo4OnBDZAbxuq//Ng8qgBowMA LP5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YSRkfQnG; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t8si10968797ejj.661.2021.03.15.06.55.36; Mon, 15 Mar 2021 06:55:59 -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=@linuxfoundation.org header.s=korg header.b=YSRkfQnG; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231553AbhCONyg (ORCPT + 99 others); Mon, 15 Mar 2021 09:54:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:55842 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229921AbhCONxV (ORCPT ); Mon, 15 Mar 2021 09:53:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E428C64EE3; Mon, 15 Mar 2021 13:53:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816401; bh=bjk8PQVrzoJuLFSJ+kN8uM7FlRaIrgGcdQwMJGeTwS8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YSRkfQnGzwu1MHeNiwuVgB/pi8tdcAkyAjd0htywfUFNDaBHf2ICD4648yuHDzQok 3GSL/7YIA3c4k44WQkqwquinwMOG8ED0PX2UjNso+9PwZs5I75t2W3Z+QrpfQzwJNk m5ahH6E2918IeN1Xp4ww5O2SzehMcONs2fuXxXp8= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Steven J. Magnani" , Jan Kara , Sasha Levin Subject: [PATCH 4.9 18/78] udf: fix silent AED tagLocation corruption Date: Mon, 15 Mar 2021 14:51:41 +0100 Message-Id: <20210315135212.663538880@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135212.060847074@linuxfoundation.org> References: <20210315135212.060847074@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Steven J. Magnani [ Upstream commit 63c9e47a1642fc817654a1bc18a6ec4bbcc0f056 ] When extending a file, udf_do_extend_file() may enter following empty indirect extent. At the end of udf_do_extend_file() we revert prev_epos to point to the last written extent. However if we end up not adding any further extent in udf_do_extend_file(), the reverting points prev_epos into the header area of the AED and following updates of the extents (in udf_update_extents()) will corrupt the header. Make sure that we do not follow indirect extent if we are not going to add any more extents so that returning back to the last written extent works correctly. Link: https://lore.kernel.org/r/20210107234116.6190-2-magnani@ieee.org Signed-off-by: Steven J. Magnani Signed-off-by: Jan Kara Signed-off-by: Sasha Levin --- fs/udf/inode.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 149baf5f3d19..50607673a6a9 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -548,11 +548,14 @@ static int udf_do_extend_file(struct inode *inode, udf_write_aext(inode, last_pos, &last_ext->extLocation, last_ext->extLength, 1); + /* - * We've rewritten the last extent but there may be empty - * indirect extent after it - enter it. + * We've rewritten the last extent. If we are going to add + * more extents, we may need to enter possible following + * empty indirect extent. */ - udf_next_aext(inode, last_pos, &tmploc, &tmplen, 0); + if (new_block_bytes || prealloc_len) + udf_next_aext(inode, last_pos, &tmploc, &tmplen, 0); } /* Managed to do everything necessary? */ -- 2.30.1