All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: <linux-fsdevel@vger.kernel.org>
Cc: "Pali Rohár" <pali.rohar@gmail.com>, "Jan Kara" <jack@suse.cz>
Subject: [PATCH 1/6] udf: Fix off-by-one in volume descriptor sequence length
Date: Wed, 14 Feb 2018 11:28:45 +0100	[thread overview]
Message-ID: <20180214102850.28755-2-jack@suse.cz> (raw)
In-Reply-To: <20180214102850.28755-1-jack@suse.cz>

We pass one block beyond end of volume descriptor sequence into
process_sequence() as 'lastblock' instead of the last block of the
sequence. When the sequence is not terminated with TD descriptor, this
could lead to false errors due to invalid blocks in volume descriptor
sequence and thus unmountable volumes.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/udf/super.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index f73239a9a97d..5c5d5fd513cc 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1658,7 +1658,7 @@ static noinline int udf_process_sequence(
 				next_e = le32_to_cpu(
 					vdp->nextVolDescSeqExt.extLength);
 				next_e = next_e >> sb->s_blocksize_bits;
-				next_e += next_s;
+				next_e += next_s - 1;
 			}
 			break;
 		case TAG_IDENT_IUVD: /* ISO 13346 3/10.4 */
@@ -1760,13 +1760,13 @@ static int udf_load_sequence(struct super_block *sb, struct buffer_head *bh,
 	main_s = le32_to_cpu(anchor->mainVolDescSeqExt.extLocation);
 	main_e = le32_to_cpu(anchor->mainVolDescSeqExt.extLength);
 	main_e = main_e >> sb->s_blocksize_bits;
-	main_e += main_s;
+	main_e += main_s - 1;
 
 	/* Locate the reserve sequence */
 	reserve_s = le32_to_cpu(anchor->reserveVolDescSeqExt.extLocation);
 	reserve_e = le32_to_cpu(anchor->reserveVolDescSeqExt.extLength);
 	reserve_e = reserve_e >> sb->s_blocksize_bits;
-	reserve_e += reserve_s;
+	reserve_e += reserve_s - 1;
 
 	/* Process the main & reserve sequences */
 	/* responsible for finding the PartitionDesc(s) */
-- 
2.13.6

  reply	other threads:[~2018-02-14 10:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14 10:28 [PATCH 0/6] udf: Fix processing of Volume Descriptor Sequence Jan Kara
2018-02-14 10:28 ` Jan Kara [this message]
2018-02-14 10:28 ` [PATCH 2/6] udf: Simplify handling of Volume Descriptor Pointers Jan Kara
2018-02-14 17:26   ` Pali Rohár
2018-02-15  8:43     ` Jan Kara
2018-02-15 22:33       ` Pali Rohár
2018-02-16 10:16         ` Jan Kara
2018-02-14 10:28 ` [PATCH 3/6] udf: Allow volume descriptor sequence to be terminated by unrecorded block Jan Kara
2018-02-14 10:28 ` [PATCH 4/6] udf: Convert descriptor index definitions to enum Jan Kara
2018-02-14 10:28 ` [PATCH 5/6] udf: Unify common handling of descriptors Jan Kara
2018-02-14 10:28 ` [PATCH 6/6] udf: Fix handling of Partition Descriptors 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=20180214102850.28755-2-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=pali.rohar@gmail.com \
    /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.