From: Steve Magnani <steve.magnani@digidescorp.com>
To: Jan Kara <jack@suse.com>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Steve Magnani <steve@digidescorp.com>
Subject: [PATCH] udf: prevent allocation beyond UDF partition
Date: Sun, 28 Jul 2019 14:19:12 -0500 [thread overview]
Message-ID: <1564341552-129750-1-git-send-email-steve@digidescorp.com> (raw)
The UDF bitmap allocation code assumes that a recorded
Unallocated Space Bitmap is compliant with ECMA-167 4/13,
which requires that pad bytes between the end of the bitmap
and the end of a logical block are all zero.
When a recorded bitmap does not comply with this requirement,
for example one padded with FF to the block boundary instead
of 00, the allocator may "allocate" blocks that are outside
the UDF partition extent. This can result in UDF volume descriptors
being overwritten by file data or by partition-level descriptors,
and in extreme cases, even in scribbling on a subsequent disk partition.
Add a check that the block selected by the allocator actually
resides within the UDF partition extent.
Signed-off-by: Steven J. Magnani <steve@digidescorp.com>
--- a/fs/udf/balloc.c 2019-07-26 11:35:28.249563705 -0500
+++ b/fs/udf/balloc.c 2019-07-28 13:11:25.061431597 -0500
@@ -325,6 +325,13 @@ got_block:
newblock = bit + (block_group << (sb->s_blocksize_bits + 3)) -
(sizeof(struct spaceBitmapDesc) << 3);
+ if (newblock >= sbi->s_partmaps[partition].s_partition_len) {
+ /* Ran off the end of the bitmap,
+ * and bits following are non-compliant (not all zero)
+ */
+ goto error_return;
+ }
+
if (!udf_clear_bit(bit, bh->b_data)) {
udf_debug("bit already cleared for block %d\n", bit);
goto repeat;
next reply other threads:[~2019-07-28 19:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-28 19:19 Steve Magnani [this message]
2019-07-31 9:59 ` [PATCH] udf: prevent allocation beyond UDF partition Jan Kara
2019-07-31 14:06 ` Steve Magnani
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=1564341552-129750-1-git-send-email-steve@digidescorp.com \
--to=steve.magnani@digidescorp.com \
--cc=jack@suse.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=steve@digidescorp.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).