From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.178 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796434301; b=y6j+LUrqa7y0OjL+PJZ/o/b1E2uQR9AKfDdh1oSHk3r4SbPk8KET5VZ46P2rWHrVcnHt 7GoGQFGzm8uCdpVlSxY2Lmxg9rF1YogYiOE+GlhCwMHOTMXVVFITPzbxXE+a+tYGanrpS c2znhKjwHuMKWGZzLhzV1A4kiRBb4qF5RPae//fCuonrBUpHRKJhl6O28BrlQR4iC09Uu EcnWJ9wfPFjy9QQdPpVCs/wvZ+R7g507iJkTHXXS56+vaMijYkT/O2Mag30RbrjX8AVTC qbYXl7Pr+x5VK1IKFYciAYsCis7Cy87EGZMREvfvdNQ9viBGZprxOUj+IPLkYYGLzLg== 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-Forwarded-Encrypted: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=haQQtaBoC00R5gaeLNRYdEtE8xPXhcW2W9vULJXHC4GQxu3JQ3HX1McFyY21/13IHmLE h/P0I9ExBZDNO54psJ60D/Vx/Ijh9+XDZaIvqyvW1pCAVq27pVeMtJeoTCIkgBPVVKrbe WWHDv6zwEzHsREFd/b69sE/3AGTfz1fUcmGDC3QnrTPkJnF0O605Rp8c1VYJcPwwsgHYR YZE2nNpPwjt4sG09S273O9/CTnsQcK429wvB47rRZGN3mSSEKmRLZ5ZQ+y1eFxkybSVXD MwbEQdwMCzwH0UJ5UwrEN7USGy69xUMTtzMFOlmLf9N+No1/HR8Czl+X+6rnD7EqArg== 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.178 Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) (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 AD07F606A69E for ; Sat, 5 Dec 2026 01:31:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AD07F606A69E 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-f178.google.com with SMTP id 00721157ae682-8b5981c4834so14618467b3.2 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=Y6POT8K3J+3+H2frRBUkdBhUfhF6LXyr+ibRmwVpK7JGf9Qd1GiYhdmxWtuqO30zPT DoyyPMZWxoBxA9k1pnD17/nUilr9pJVVH0tLjuFTQYYbCHOBQS+a58En5Y88hE0Zwu7j +KvCqGNl963RrydEbHXF3izQHayLKGCphzA8QAszQLkiP4qSjpG1qLfPg3pF9wrXyGgX El4DwrjsWnEQfQIXHFCRSrZ/Y79l83ZCIzKiQKQQHQkRTDd9GONkpPSsy8iZ2kx7T/vj zpE5xbbbn5IXKV15BlHZMMBMV0YYnakkl0K75h6CMAaXFnN+2pHV4DMQxY/S04mJiD2B YfoA== X-Forwarded-Encrypted: i=1; AL+hErF7++IRUGZ19+2bgmUi/4XZDXfX5pjjUoaNwyLCL06wxmZLMzzPOvLwWRK07zSMnI/D7HJwJs3U7y0Yfzo=@vger.kernel.org X-Gm-Message-State: AB4q+uEjvYFS70LJO+Vj5/0E4scnhyLavq2Sy6Df+2mozdOXbgbhdZGY fVHiwaky5XiAK2iq3r+kc/j74hO3k9SkMDk6BA7fpMMtUG19uezA1vNM8jkH9w2QBGc= X-Gm-Gg: AZFdTZekxFvnYi615WcMPVVxddJ7F7bGDP1MXRLKV2C/J1VoNvF2NUEWfMULMI7u/Es Bi8ZMAqWikJPJrGzS5HhiVqPg+V1H6sNVdqYMUoWnMN8IkmP47SZ7RGhrgrHiiDm6iHqnAz3OMs XxDMmJCEB6zYmtoa2356q07F7zl5BmDNqtr2p1RnxxlJ2rrQypMPLpjpGfhLf7tklK8um1oTeAX MZfuH5gNTTuGw4LVb4IkMKSKa95AkVaOScnqDGMxDA46EUqiDCJmb/Srfs86zCH4V5usTc1F6ri iHSVf6JVeWJHbIL/BSe7Aw0Un2H3zZ0a+cMZ/fCxDSG5EVmJK1eCurAzTAb3kKOxuvYNPiihxuT qNBS7/0IzCsujpPsg3Nnx+p+fHgBHSOPWiSMdtj+3H6KF0pFPT+U2XlmUDVqEwRJgDiakoUilp/ OwqeNHPc73neFIsPVqTghMmRov6tnxqwRHCPvvVJguBDVlL/ONl3WXKd1ghxX7/Q8hE5sAlvF1s LX6Gvf9dft1foYhpaRjKY0l5kZGG87g6JRTxYnSViJp1U6JOfWy6u+LW1v3oyn/z6mkhRxNt/v4 WXp15jLHbPOPUQqB9F/p5CgMNI51WfWGPjF67YgGjxqru2pd5MOue7II3kkALObFMY/6ywCOWuX xx38UU2gA0/YRolZgNcQTHvqHyGB8WT40Gu+yZkSyJUQAqkKWxGoGzZrsxKU3luiydxdBgfc= 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-kernel@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