Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3522773pxf; Mon, 15 Mar 2021 11:26:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJbsfYQ4P8KosA5RTPSg0Y8tNHs2bJPyO6QVe8Wv6Jor6SC/yGLqZ8YdP0YGpAYgG5KFtQ X-Received: by 2002:a17:906:c9c2:: with SMTP id hk2mr25379879ejb.244.1615832796254; Mon, 15 Mar 2021 11:26:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832796; cv=none; d=google.com; s=arc-20160816; b=w/Vd1vYsd630dbzuLw7Zxcss7cba4dK/3UsfJhPBcjhO5xkmSjW6ZviDjvQSu4JhyK MsxL1VnrAMqLFgV2RAMb2djf3e7t4iccuGHfyWaz1ZGxvTL+5uBrcEyCKINaR0WyEr3x PV/Dp/Jj8v5cFyYmMX+FU1GusG3skGeQrPldA2TwmqBy2fdxEwkifDiI2rhpAwcvgvRO fYzyzXA+n3zdTMxjOlQNUiBOZd91JsrpA8aNT1+LlK/4h2Adu7WyGkCSxosNtGf0qkRV sU0CmykzFBnwFPToAo3wS7KY8DCMUAQvyPQ1+g6ZFPmeJcCYScUo/5K1lXuXRwJk+/1E eo9w== 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=HnPbfCyHb4Tc4iadKCinME7f9u8QEkkZRTJqacf/EAY=; b=LZGXYwF0baUwkaQQimRn/zZWXJHCE81ww6BGZEfRN3DH5SXf1zxJ20yix42gyNA0D9 EhXrWf7zjAjp9u8R+2Jpn85QxzrOhVQaa4T12jNyN0N+qR9MJrjf2F/7OIDrqm3pNEOU 3rP1OBo4+gxrllRXxqdLvMXrn3Vm8HMPBZ8dnqILL/8CCOgykHUAD4pmQItv79/8bYx5 3P71Hc77wRoKBER/QZc2fzrA80ZkjUnqpg9RvCrCG/PHw0YoqL6ojdlLM6G8RmItveGY TuX6K6RFXHr91EPLturp9RXGj8vA2kLfyNALuOjVRpXPIapzdjzTEQk50HijfbOiBSeX wHrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uUPehyKP; 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 m18si11922566edv.199.2021.03.15.11.26.07; Mon, 15 Mar 2021 11:26:36 -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=uUPehyKP; 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 S239167AbhCOO1y (ORCPT + 99 others); Mon, 15 Mar 2021 10:27:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:37632 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233084AbhCOOAh (ORCPT ); Mon, 15 Mar 2021 10:00:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4B57664EFC; Mon, 15 Mar 2021 14:00:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816823; bh=G54vohvt+g5VieYybML1LGzxlSiZ1Tb+gpNzAx1aXvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uUPehyKPCaVSvoHh3GMUFO7sWT2JHXbp5mmKJw0dvrHS+wO/Ygdri7aPVJjXP/CvD 0726FOmLqPkxE6iW7Larwg00SCBjWweDtxV0fTNAdw9b/k/cdkp+iNl/k8CSsJgncA 7lGrPIROMVhTcqGsxT9tUkDC6t52u1l4TeOsaJa0= 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 5.10 134/290] udf: fix silent AED tagLocation corruption Date: Mon, 15 Mar 2021 14:53:47 +0100 Message-Id: <20210315135546.437045564@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@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 bb89c3e43212..0dd2f93ac048 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -544,11 +544,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