All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Magnani <magnani@ieee.org>
To: Jan Kara <jack@suse.com>
Cc: linux-kernel@vger.kernel.org, "Steven J . Magnani" <magnani@ieee.org>
Subject: [PATCH 1/1] udf: fix silent AED tagLocation corruption
Date: Thu,  7 Jan 2021 17:41:16 -0600	[thread overview]
Message-ID: <20210107234116.6190-2-magnani@ieee.org> (raw)
In-Reply-To: <20210107234116.6190-1-magnani@ieee.org>

From: Steven J. Magnani <magnani@ieee.org>

When extending a file, make sure that the pointer to the last written
extent does not get adjusted into the header (tag) portion of an
Allocation Extent Descriptor. Otherwise, a subsequent call to
udf_update_exents() can clobber the AED's tagLocation field, replacing
it with the logical block number of a file extent.

Signed-off-by: Steven J. Magnani <magnani@ieee.org>
---
--- a/fs/udf/inode.c	2020-12-28 20:51:29.000000000 -0600
+++ b/fs/udf/inode.c	2021-01-01 19:20:37.163767576 -0600
@@ -547,11 +547,14 @@ static int udf_do_extend_file(struct ino
 
 		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.
-		 */
-		udf_next_aext(inode, last_pos, &tmploc, &tmplen, 0);
+
+		if (new_block_bytes || prealloc_len) {
+			/*
+			 * We've rewritten the last extent but there may be empty
+			 * indirect extent after it - enter it.
+			 */
+			udf_next_aext(inode, last_pos, &tmploc, &tmplen, 0);
+		}
 	}
 
 	/* Managed to do everything necessary? */

  reply	other threads:[~2021-01-07 23:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-07 23:41 [PATCH 0/1] udf: fix silent AED tagLocation corruption Steve Magnani
2021-01-07 23:41 ` Steve Magnani [this message]
2021-01-14 14:57   ` [PATCH 1/1] " Jan Kara
2021-01-13 17:47 ` [PATCH 0/1] " Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210107234116.6190-2-magnani@ieee.org \
    --to=magnani@ieee.org \
    --cc=jack@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.