From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 475963E0223 for ; Fri, 5 Jun 2026 18:37:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780684664; cv=none; b=VpnDqkvldkNslDUB7bXeg00A75EgmFBFVeMVTYFPhTWwyQcLxbGt4nyd7smvqbs8FuJ/w8qxX7Ij166Vc2khwgGMJmRHdyVb5/xTOAofBZppy6ZdD8xhL2HkP7X1FU3Vw3lY9IBhCnyHeohtdQpgQa2Pezy1dCrCHFvP7oYdlho= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780684664; c=relaxed/simple; bh=ddWQI4QGangymfx2zXkxiStPTPLk4yIMSEKTR6viVHw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=OSmZxIb/ZnSiw2WVkxWVZo232cy2kHv+pr4gfB73Y3zevYPfXPZrF0q4xGcXYTkMdt21m3tFT9pr8tDZ9RfibpPwf+7OdLpoxPTROF6dQthWiIz7KHcpQwFcRvgIwHIcT3d6aAcYUr9LF+FZNLrTsKHl0SoCNavTWuUNdE0biSU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=trailofbits.com; spf=pass smtp.mailfrom=trailofbits.com; dkim=pass (2048-bit key) header.d=trailofbits.com header.i=@trailofbits.com header.b=aLNuJtRF; arc=none smtp.client-ip=209.85.222.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=trailofbits.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=trailofbits.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=trailofbits.com header.i=@trailofbits.com header.b="aLNuJtRF" Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-915767ea2d0so189290485a.1 for ; Fri, 05 Jun 2026 11:37:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trailofbits.com; s=google; t=1780684662; x=1781289462; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=PYN/COcj9sZ4HsHipW+NHsMJI4nInaopQ7r/o+mLKb4=; b=aLNuJtRFtlDSe5a/8J/8iPz7cjrL0o9HbnCyie8I3tmzFe3pR1upqaoigNzTewr4/1 rIdG2PSbLMQ3giuBKLVUsucIhjNSGBJ1kzG7haFzu+B0PCkRM4P2CIhFlVlIQKoTJ5Pv syDWuQNlKFx3tOEvXiubZWV5ZQkrsotbp8kCbCM4hfIEGBcIg+sMX/R90RvKSomxm1pU fauxPFSf0JpC5hUhuXLFbQcJl2oV5cRG8Ya+OctapzXW8SAjUXlbbyTxu8aUgz3Gjfqh lmM75oMjP89ukmLhId2e9dhS1r86TbOjUqOdFFf7VDU5tIf4B1TctQz7aibH89MbRqd9 dziw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780684662; x=1781289462; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=PYN/COcj9sZ4HsHipW+NHsMJI4nInaopQ7r/o+mLKb4=; b=WBoJHKRpjTUNobmEZ/0J2qIm9tM2ArJzrEEFtBq3WvYbzMvX3O6sBn/s+mN3msX0pq dBsrfh/3Mv2kFEKDhK3TUlF1vFnY2Jt+I8KeGNEMvmITZtCwJ9qzEn05FiyP2Q05sBWJ RDuWbApBbcvoimvCadfCkEPfDVzu8pwkXoohxlunYnkcS6N7/DfotR3KjaUq4SIooYuI meJGUEgCFLbkMj2/vS6c5/fvYZFo/wJswW/gEbY5syOQlqLopeViXmsOf2OHSbrmkM9k sOvcRz+AiB+iaxyPN2l65XFZ/RiQ8XgCFxypgoeEbXmAa1mIfqIa+KD/Hgx7uj0mc3hG +7EA== X-Forwarded-Encrypted: i=1; AFNElJ810z2J9SCZUhpTWxF+ORYyrnVbhtK4uX0c6P0WcYQCmjd09lCpXCYlRsZ7ncK5CmgmuHqVYmpHRcToFsE=@vger.kernel.org X-Gm-Message-State: AOJu0Yxx0ELgxYjAPHIUL9EQn73XPNv5Vlpx/fKB6Gvig/f5XI+KT5Wj N4S6On6zzCunuzFuWLQmBy1PQrPicue3mZ7frh6lh1pzHXXAu4EZ5Hir8705WkCGUmc= X-Gm-Gg: Acq92OFcAeT4071VOCM9vEPr6MnTb2AtatpLaKTvM4WT4qTEyJSoEmoWcteXEzZ7cmd z/cywaGaehUqEl0gb+QoUnl8GMgKSCw5k1foy/YirseYNT9U7hbiZnMZXZEdYKsVJunYaoPeYUs bCvpdpqKVPuZLCpPVenoTvYTtCLrAWTyn7h78bOMu642fTmi/njXpFxveae4LauT4/7B+WEVfDM Jg+jlhZ5LrdqZt3MRbnMuhPB425GIYrnnwcBmd/YNDfyBh43Iz5gF5/B8rxwuTzoSSoJDF7SEas SLvy7oYUNUtLppAm21o+HBsgI+XtIy1jhbsdjDc1y0mc0BqL6oQzodr+3wyiLV3X7uGDzhqsxxU 1KUF5TVziybaAsMTV06lsCggFlzaLF1kJWvpDjkUsuKGkeImBhCYzSh6jUbR6Pe2vjX1frL99BC oUGYxM2oBqP/rC9RnHQ0kTLx6X0K0qurIi8vPjVw== X-Received: by 2002:a05:620a:4405:b0:915:aff9:5449 with SMTP id af79cd13be357-915aff95b4fmr520927785a.34.1780684662246; Fri, 05 Jun 2026 11:37:42 -0700 (PDT) Received: from localhost ([161.35.96.86]) by smtp.gmail.com with UTF8SMTPSA id af79cd13be357-9158a3d3a0esm979729785a.40.2026.06.05.11.37.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Jun 2026 11:37:41 -0700 (PDT) From: Samuel Moelius To: "Russell King (Oracle)" Cc: Samuel Moelius , Bae Yeonju , Christian Brauner , Kees Cook , Al Viro , linux-kernel@vger.kernel.org (open list) Subject: [PATCH] adfs: reject disc records smaller than one filesystem block Date: Fri, 5 Jun 2026 18:37:34 +0000 Message-ID: <20260605183738.2489977-1-sam.moelius@trailofbits.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ADFS uses the on-disk disc size to report statfs block counts. The disc record validator checks the sector size, id length, high disc-size bits, map zone count, and reserved bytes, but it accepts a declared disc size smaller than one filesystem block. A crafted one-zone image with log2secsize 9 and disc_size 1 can pass map checksum validation and mount. A subsequent statfs then reports zero f_blocks from adfs_map_statfs(), and adfs_statfs() divides by that zero while deriving f_ffree. Reject disc records whose declared disc size is smaller than one filesystem block. Assisted-by: Codex:gpt-5.5-cyber-preview Signed-off-by: Samuel Moelius --- fs/adfs/super.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/adfs/super.c b/fs/adfs/super.c index a4cd0a5159dd..cb8f3919e3bb 100644 --- a/fs/adfs/super.c +++ b/fs/adfs/super.c @@ -73,6 +73,10 @@ static int adfs_checkdiscrecord(struct adfs_discrecord *dr) if (le32_to_cpu(dr->disc_size_high) >> dr->log2secsize) return 1; + /* disc size must contain at least one filesystem block */ + if (adfs_disc_size(dr) < (1ULL << dr->log2secsize)) + return 1; + /* * Maximum idlen is limited to 16 bits for new directories by * the three-byte storage of an indirect disc address. For -- 2.43.0