All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: atari: Return early for unsupported sector size
@ 2016-07-05 16:38 Gabriel Krisman Bertazi
  2016-07-13  1:42 ` Gabriel Krisman Bertazi
  2016-07-13 16:32 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Gabriel Krisman Bertazi @ 2016-07-05 16:38 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, Gabriel Krisman Bertazi

For 4K LBA or very large disks, atari_partition can easily get tricked
into thinking it has found an Atari partition table.  Depending on the
data in the disk, it ends up creating partitions with awkward lengths.

We saw logs like this while playing with fio.

[5.625867] nvme2n1: AHDI p2
[5.625872] nvme2n1: p2 size 2910030523 extends beyond EOD, truncated

People has had issues with misinterpreted AHDI partition tables for a long
time, see this BSD thread from 1995, for example.

https://mail-index.netbsd.org/port-atari/1995/11/19/0001.html

Since the atari partition, according to the spec, doesn't even support
sector sizes with more than 512, a quick sanity check is reasonable to
just bail out early, before even attempting to read sector 0.

Signed-off-by: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>
---
 block/partitions/atari.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/block/partitions/atari.c b/block/partitions/atari.c
index 9875b05..ff1fb93 100644
--- a/block/partitions/atari.c
+++ b/block/partitions/atari.c
@@ -42,6 +42,13 @@ int atari_partition(struct parsed_partitions *state)
 	int part_fmt = 0; /* 0:unknown, 1:AHDI, 2:ICD/Supra */
 #endif
 
+	/*
+	 * ATARI partition scheme supports 512 lba only.  If this is not
+	 * the case, bail early to avoid miscalculating hd_size.
+	 */
+	if (bdev_logical_block_size(state->bdev) != 512)
+		return 0;
+
 	rs = read_part_sector(state, 0, &sect);
 	if (!rs)
 		return -1;
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] block: atari: Return early for unsupported sector size
  2016-07-05 16:38 [PATCH] block: atari: Return early for unsupported sector size Gabriel Krisman Bertazi
@ 2016-07-13  1:42 ` Gabriel Krisman Bertazi
  2016-07-13 16:32 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Gabriel Krisman Bertazi @ 2016-07-13  1:42 UTC (permalink / raw)
  To: axboe; +Cc: linux-block

Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com> writes:

> For 4K LBA or very large disks, atari_partition can easily get tricked
> into thinking it has found an Atari partition table.  Depending on the
> data in the disk, it ends up creating partitions with awkward lengths.
>
> We saw logs like this while playing with fio.
>
> [5.625867] nvme2n1: AHDI p2
> [5.625872] nvme2n1: p2 size 2910030523 extends beyond EOD, truncated
>
> People has had issues with misinterpreted AHDI partition tables for a long
> time, see this BSD thread from 1995, for example.
>
> https://mail-index.netbsd.org/port-atari/1995/11/19/0001.html
>
> Since the atari partition, according to the spec, doesn't even support
> sector sizes with more than 512, a quick sanity check is reasonable to
> just bail out early, before even attempting to read sector 0.
>
> Signed-off-by: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>
> ---

Hi Jens,

Any thoughts on this?  Do you think we can get it queued for 4.8?
-- 
Gabriel Krisman Bertazi

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] block: atari: Return early for unsupported sector size
  2016-07-05 16:38 [PATCH] block: atari: Return early for unsupported sector size Gabriel Krisman Bertazi
  2016-07-13  1:42 ` Gabriel Krisman Bertazi
@ 2016-07-13 16:32 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2016-07-13 16:32 UTC (permalink / raw)
  To: Gabriel Krisman Bertazi; +Cc: linux-block

On 07/05/2016 09:38 AM, Gabriel Krisman Bertazi wrote:
> For 4K LBA or very large disks, atari_partition can easily get tricked
> into thinking it has found an Atari partition table.  Depending on the
> data in the disk, it ends up creating partitions with awkward lengths.
>
> We saw logs like this while playing with fio.
>
> [5.625867] nvme2n1: AHDI p2
> [5.625872] nvme2n1: p2 size 2910030523 extends beyond EOD, truncated
>
> People has had issues with misinterpreted AHDI partition tables for a long
> time, see this BSD thread from 1995, for example.
>
> https://mail-index.netbsd.org/port-atari/1995/11/19/0001.html
>
> Since the atari partition, according to the spec, doesn't even support
> sector sizes with more than 512, a quick sanity check is reasonable to
> just bail out early, before even attempting to read sector 0.

Added for 4.8, thanks.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-07-13 16:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-05 16:38 [PATCH] block: atari: Return early for unsupported sector size Gabriel Krisman Bertazi
2016-07-13  1:42 ` Gabriel Krisman Bertazi
2016-07-13 16:32 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.