Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756020AbcLNRIE (ORCPT ); Wed, 14 Dec 2016 12:08:04 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:37088 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753439AbcLNRIC (ORCPT ); Wed, 14 Dec 2016 12:08:02 -0500 Date: Wed, 14 Dec 2016 09:07:19 -0800 From: Christoph Hellwig To: Stefan Haberland Cc: axboe@kernel.dk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, hoeppner@linux.vnet.ibm.com, sebott@linux.vnet.ibm.com Subject: Re: [RFC] block: check partition alignment Message-ID: <20161214170719.GA3599@infradead.org> References: <20161214164706.45543-1-sth@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161214164706.45543-1-sth@linux.vnet.ibm.com> User-Agent: Mutt/1.6.1 (2016-04-27) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 570 Lines: 12 > To prevent partitions that are not aligned to the physical blocksize > of a device check for the alignment in the blkpg_ioctl. We'd also need to reject this when reading partitions from disk, right? > + /* check if partition is aligned to blocksize */ > + if (p.start % bdev_physical_block_size(bdev) != 0) And this should be bdev_logical_block_size, as the logical block size is the only thing that matters for the OS - exposing the physical block size is just an optional hint to prevent users from doing stupid things (like creating unaligned partitions :))