Linux block layer
 help / color / mirror / Atom feed
From: Guanglei Zhu <zhugl3@xiaopeng.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	Guanglei Zhu <zhugl3@xiaopeng.com>
Subject: [PATCH] partitions: atari: fix overflow in the partition sanity check
Date: Fri, 11 Sep 2026 12:40:06 +0800	[thread overview]
Message-ID: <20260911044006.1436211-1-zhugl3@xiaopeng.com> (raw)

VALID_PARTITION() adds the 32-bit start and size fields before
comparing the sum against the disk size, so a table entry whose
st + siz wraps to a small value passes the check.  An entry with
st = 0x1000 and siz = 0xfffff000, for example, is accepted on a
32 MiB disk even though the partition ends far beyond it.

Widening the addition to sector_t rejects such entries, so the
table is no longer mistaken for a valid Atari table based on an
overflowing entry.

No Fixes tag: the check dates back to the initial git import and
predates any in-tree stable branch that would still carry it.

Signed-off-by: Guanglei Zhu <zhugl3@xiaopeng.com>

Verified in a QEMU guest with a crafted Atari root sector holding
that single entry: the unpatched kernel accepts the table and
reports

  vda: p1 size 4294963200 extends beyond EOD, truncated

with this change the entry fails the check, the table is rejected
as non-Atari, and no partition device is created.
---
 block/partitions/atari.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/partitions/atari.c b/block/partitions/atari.c
index 2438d1448f..de6d9b1b68 100644
--- a/block/partitions/atari.c
+++ b/block/partitions/atari.c
@@ -22,7 +22,7 @@
     (((pi)->flg & 1) &&							     \
      isalnum((pi)->id[0]) && isalnum((pi)->id[1]) && isalnum((pi)->id[2]) && \
      be32_to_cpu((pi)->st) <= (hdsiz) &&				     \
-     be32_to_cpu((pi)->st) + be32_to_cpu((pi)->siz) <= (hdsiz))
+     (sector_t)be32_to_cpu((pi)->st) + be32_to_cpu((pi)->siz) <= (hdsiz))
 
 static inline int OK_id(char *s)
 {
-- 
2.43.0


                 reply	other threads:[~2026-09-11  4:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260911044006.1436211-1-zhugl3@xiaopeng.com \
    --to=zhugl3@xiaopeng.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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