Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.174 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796434301; b=r7+sU7QElFfybtyJOsOCml88ERw+FUCHGeYKTlbBgI8ujjGZuxsL2qUJvXfk0fjq6XTl 1i2fsu28p3mKAWXz4QfzivlUEboenQsrNMlFSodCC6rrCJDH0qa6l3KxvYJFeUWrfnbML Duw5Nh1BPGs7vL2egkPtmA2nNHstABrMA17imhkoBo+QMiEXCWnjGYdhyjnG4LQYbp7zs hGPLfaWAWOri0YkxoloEKwzXXfzbvMtRFsFFygkrLoliEv40ELV0xoZ/UvYS2zFsQegpS 3/o78JRPnRbgahYIWPRj1NGm9nTZ2WL5pM9Gv9fPKxYPFm40TfVf9VaLFoW0ZNNJ2Ew== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796434301; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=9FpQp34NFo0fMCaONOV/1a5GtrW9Uc4LJ+JZ5E5LyHU=; b=TAdnXf+hVxbBulZro6wJU9xwoAWYtKLTuxDuTgj5mnqHniHBtgd+mHdihJjZSPZkeqEH PBBg1yt+D+8JvIQPhE7dX0j2/5bpf48EHZw7CvwNYuaRZKuZ3hh2v1vYo/Tq7TIjoP5gp KlLFprSj94k0vXDA+/MDOmBIIsPRTkw5tuhTEwaZKUeFwDvg5t1DTPrNoZTKxeIg4mANF LioDTMUMNIUy2x2ebC3UMFwpao25SjDSX0r5YyKHG53G2kxAEneMB39rNSna3GgI39qLD HoRTVUMXjL1cDc3ts60GGaImk44hYwm12uLpSPdyMHsarSCF4ghXGcm5ee8QpTb4PPQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=dubeyko.com; spf=pass smtp.mailfrom=dubeyko.com; dkim=pass header.d=dubeyko-com.20260707.gappssmtp.com header.i=@dubeyko-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=CoG1jILa; arc=none smtp.remote-ip=209.85.128.174 Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5B38606A69F for ; Sat, 5 Dec 2026 01:31:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B5B38606A69F Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=dubeyko.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dubeyko.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dubeyko-com.20260707.gappssmtp.com header.i=@dubeyko-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=CoG1jILa Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-8b315dd057bso9455787b3.1 for ; Fri, 04 Dec 2026 17:31:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dubeyko-com.20260707.gappssmtp.com; s=20260707; t=1796434300; x=1797039100; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=9FpQp34NFo0fMCaONOV/1a5GtrW9Uc4LJ+JZ5E5LyHU=; b=CoG1jILaOxmlXUscCcVhuAOt6DHO0cdonUteY0+N2JkY6081nzFAkZs52cKrsLlOy2 AueobShV0jdnLvBKqPtwfM4uCD1HgwPMWFMiwtJc521lCZDGbof0SGnc3bJm7wNMB9t6 XBeyEL05YD+WT9b5O9DDWIe1ntKpCDaR2S7hZQyIB6CDVnV/UWlL9S1M2LNxftdkmohI QGttRFWVH71d5yCw/GPbyoYV60NwHSRru8irUlPgM9G683R6L/vVoEkN/bzJHxc0CB1S foYE8vsGnC+SuX8gDOCsfAhiT7DsK0mgEDCeg5K3ctruTE61QV+xOxZBKBFvWbMDDMpB IXBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796434300; x=1797039100; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=9FpQp34NFo0fMCaONOV/1a5GtrW9Uc4LJ+JZ5E5LyHU=; b=dU3abKwmw3QxddSt+EyMM+gaqSYcrwbdDo0YHozAf5SCViTmQ1J5GKyjW6MJ00JLEm WDP8yZCUrdBPU5MSV3Z0JKbaBCk+uapluwJfMEgtOTmLMhdAxgZgH7mp8+2zM/Lq4/XE 0iRiXW3sn8d12QzzmvL+CJMFY7N5/qWI+81mQL/BxPUx9NEOgA8f8mNYJapgqWQUfOv7 4u646Lh/D60MiQVkkukZ6BmeJpf2zHiq5jre8xcT0yglN297QmJZ+z4i6hHzF5rXQqaH jgjSRXCh1Socc2TxEqFIlJ8eGhaciW+JgrgBR+F8/noLu/jA/biPIr5oz3rxoZXwsTji iMHw== X-Gm-Message-State: AB4q+uHHxg+V8GQ7ABUstrlD0IFEio+lIul7TvooGJidrvWXKvisdSzA 72l9F6b+GQPYSanSr8Es9c29LwS5mnYuDTNjgbofZjNywPqhYVzWcO1NFiuGljjRCbs= X-Gm-Gg: AZFdTZd5DbS9NO+ifbryD1YMTizf2oamKRIf7ZR0565ulOJNJP/y5EJshImLArk+tOr 82/MxRo/69HvCxTJCHZoY728ER4ZeaRquIV6ApDfSwcOI7jdEoV8cXw6G/H0tm8dkYok1q8QavJ kJHWa/m4DEDXEDomsWP9J4BDRI0EKXXC1/zuuxeILasYCl24HTb022VJGTs3lwaWeTsBgopNPVD yMoh2rziCOz8VJZI0S42Dwk5gNcjSjznqkawBjurU0/2SEhvdZNMSD1GANDdU0x2yHpDkd50jZA F/dBAxEEjFQb+AIYFyEDE8I9zy7Uq/IN0K52E7MZRKoZaH674NbkZlRHAAN2ELL9FX8SjOqbX9G IsLLD0OLXob+id+esjuVglkiJLt3bKhTfXhxEWxBvZ2LglZ+7nbWE9yFW/L8M8HUBniXaIvampY all1Met5DNnKHu3Y1VT/W27i24UuCDg3s6KzGqTRdOgLGdhSx3Hmay84odzh/d+cCuWNmy4BUK5 vzJt6h1l7CR2TGCrumlU58itXCT21PdxdIEu/zkEiIXpFv2116JHB/gObVxAGsWxP3WJx5TN7TM 3wSAHdYjk7wNym7WF6ZOzzUt7oIl4/1TtPseHFm+4ncA0JLXUu8HpE6xcnSnTv5tqmAqQA/CkNJ WzS4xD2lddo0swd6i1Oul623ljBzqWSXNQJouh77mzmpUpzXTSiRZiuI+3HQDJXl3IWjHVNU= X-Received: by 2002:a05:690c:6182:b0:8b4:dba5:f101 with SMTP id 00721157ae682-8b660d9a90amr19842367b3.52.1796434299860; Fri, 04 Dec 2026 17:31:39 -0800 (PST) Received: from system76-laptop.attlocal.net ([2600:1700:6476:1430:d9f4:eaa9:479c:5d66]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b660e183acsm17228137b3.45.2026.12.04.17.31.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 17:31:39 -0800 (PST) From: Viacheslav Dubeyko 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 , Aymen T , stable@vger.kernel.org Subject: [PATCH 4/6] hfs: look for the MDB in the order of the on-disk layout Date: Fri, 4 Dec 2026 17:31:25 -0800 Message-ID: <20261205013127.1533652-5-slava@dubeyko.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261205013127.1533652-1-slava@dubeyko.com> References: <20261205013127.1533652-1-slava@dubeyko.com> X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit hfs_mdb_get() looks for the MDB by rereading at part_start until it finds the HFS signature, calling hfs_part_find() whenever it does not. hfs_part_find() moves part_start by the start of the found partition, which comes from disk. For an Apple_HFS entry with pmPyPartStart = 0, part_start does not move, the same partition map is found again, and the mount loops forever. As the MDB sector is read from the buffer cache, the loop spins on the CPU without any I/O. There is no iteration limit and no signal check, so the mount(2) caller cannot be killed. The on-disk layout allows only an optional Apple partition map at the start of the device, whose partition contains the volume. Follow it instead of rereading in a loop: look for a partition map only if no MDB is found at the start of the device, and require the found partition to contain the MDB. As there is no way back, the mount cannot loop, whatever the metadata are. Reported-by: Aymen T Link: https://lore.kernel.org/linux-fsdevel/45bfa4d7-e9e2-45f2-9e12-a794defae64a@gmail.com/ Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Viacheslav Dubeyko Cc: stable@vger.kernel.org cc: John Paul Adrian Glaubitz cc: Yangtao Li cc: linux-fsdevel@vger.kernel.org --- fs/hfs/mdb.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/fs/hfs/mdb.c b/fs/hfs/mdb.c index 277de712f9d4..d17d7f9ac4f5 100644 --- a/fs/hfs/mdb.c +++ b/fs/hfs/mdb.c @@ -142,21 +142,36 @@ int hfs_mdb_get(struct super_block *sb) if (hfs_get_last_session(sb, &part_start, &part_size)) return -EINVAL; - while (1) { - /* See if this is an HFS filesystem */ - bh = sb_bread512(sb, part_start + HFS_MDB_BLK, mdb); - if (!bh) - return -EIO; - if (mdb->drSigWord == cpu_to_be16(HFS_SUPER_MAGIC)) - break; + /* + * The MDB is in sector HFS_MDB_BLK of the volume. The volume can be + * in a partition of an Apple partition map at the start of the + * device, so look for the partition map at most once. + */ + bh = sb_bread512(sb, part_start + HFS_MDB_BLK, mdb); + if (!bh) + return -EIO; + + if (mdb->drSigWord != cpu_to_be16(HFS_SUPER_MAGIC)) { brelse(bh); - /* check for a partition block + /* + * Check for a partition block. The partition found must + * contain the volume itself. + * * (should do this only for cdrom/loop though) */ if (hfs_part_find(sb, &part_start, &part_size)) return -EIO; + + bh = sb_bread512(sb, part_start + HFS_MDB_BLK, mdb); + if (!bh) + return -EIO; + + if (mdb->drSigWord != cpu_to_be16(HFS_SUPER_MAGIC)) { + brelse(bh); + return -EINVAL; + } } HFS_SB(sb)->alloc_blksz = size = be32_to_cpu(mdb->drAlBlkSiz); -- 2.53.0