mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Viacheslav Dubeyko <slava@dubeyko.com>
To: glaubitz@physik.fu-berlin.de, frank.li@vivo.com
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	vdubeyko@coreweave.com, Viacheslav Dubeyko <slava@dubeyko.com>,
	stable@vger.kernel.org
Subject: [PATCH 6/6] hfs: stop at the first matching entry of the old partition map
Date: Fri,  4 Dec 2026 17:31:27 -0800	[thread overview]
Message-ID: <20261205013127.1533652-7-slava@dubeyko.com> (raw)
In-Reply-To: <20261205013127.1533652-1-slava@dubeyko.com>

When hfs_part_find() finds a matching "TFS1" entry in the old partition
map, it adds the start of the partition to *part_start and sets
*part_size, but it doesn't leave the loop. It goes on checking the rest
of the 42 entries, so without the part= mount option every following
"TFS1" entry adds its start to *part_start again. As a result, the MDB is
looked for at the sum of the partition starts, which is not the start of
any partition, and the size of the last entry is used with it. Also,
hfs_part_valid() checks the following entries against the already
shifted *part_start.

The new partition map branch of hfs_part_find() and the hfsplus code
stop at the first matching entry. Do the same for the old partition map.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>
Cc: stable@vger.kernel.org
cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
cc: Yangtao Li <frank.li@vivo.com>
cc: linux-fsdevel@vger.kernel.org
---
 fs/hfs/part_tbl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/hfs/part_tbl.c b/fs/hfs/part_tbl.c
index 05c4c360bd68..5764e282b779 100644
--- a/fs/hfs/part_tbl.c
+++ b/fs/hfs/part_tbl.c
@@ -117,6 +117,7 @@ int hfs_part_find(struct super_block *sb,
 				*part_start += entry_start;
 				*part_size = entry_count;
 				res = 0;
+				break;
 			}
 		}
 		break;
-- 
2.53.0


      parent reply	other threads:[~2026-12-05  1:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05  1:31 [PATCH 0/6] hfs/hfsplus: fix endless loop on mount of crafted images Viacheslav Dubeyko
2026-12-05  1:31 ` [PATCH 1/6] hfsplus: look for the volume header in the order of the on-disk layout Viacheslav Dubeyko
2026-12-05  1:31 ` [PATCH 2/6] hfsplus: validate the HFS wrapper before following it Viacheslav Dubeyko
2026-12-05  1:31 ` [PATCH 3/6] hfsplus: validate the partition map entry " Viacheslav Dubeyko
2026-12-05  1:31 ` [PATCH 4/6] hfs: look for the MDB in the order of the on-disk layout Viacheslav Dubeyko
2026-12-05  1:31 ` [PATCH 5/6] hfs: validate the partition map entry before following it Viacheslav Dubeyko
2026-12-05  1:31 ` Viacheslav Dubeyko [this message]

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=20261205013127.1533652-7-slava@dubeyko.com \
    --to=slava@dubeyko.com \
    --cc=frank.li@vivo.com \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=vdubeyko@coreweave.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

all inboxes | Powered by JetHome®