From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752268AbcHLKRd (ORCPT ); Fri, 12 Aug 2016 06:17:33 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35799 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751230AbcHLKRc (ORCPT ); Fri, 12 Aug 2016 06:17:32 -0400 Date: Fri, 12 Aug 2016 11:17:26 +0100 From: Salah Triki To: Luis de Bethencourt Cc: akpm@linux-foundation.org, viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/4] befs: check allocation_group number before use Message-ID: <20160812101726.GA18531@pc> References: <8f7f9b76ead677bdc834867e549ea6c4d1c04ccd.1470867071.git.salah.triki@gmail.com> <57AC59D0.7030408@osg.samsung.com> <20160812072651.GA6033@pc> <57AD9932.6050608@osg.samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <57AD9932.6050608@osg.samsung.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 12, 2016 at 10:38:58AM +0100, Luis de Bethencourt wrote: > On 12/08/16 08:26, Salah Triki wrote: > > On Thu, Aug 11, 2016 at 11:56:16AM +0100, Luis de Bethencourt wrote: > >> On 10/08/16 23:12, Salah Triki wrote: > >>> Check that the allocation group number is not greater or equal to the > >>> number of allocations group in the file system and return BEF_ERR in the > >>> case of error. > >>> > >>> Signed-off-by: Salah Triki > >>> --- > >>> fs/befs/befs.h | 5 +++++ > >>> 1 file changed, 5 insertions(+) > >>> > >>> diff --git a/fs/befs/befs.h b/fs/befs/befs.h > >>> index 55f3ea2..6daf4c4 100644 > >>> --- a/fs/befs/befs.h > >>> +++ b/fs/befs/befs.h > >>> @@ -121,6 +121,11 @@ BEFS_I(const struct inode *inode) > >>> static inline befs_blocknr_t > >>> iaddr2blockno(struct super_block *sb, const befs_inode_addr *iaddr) > >>> { > >>> + if (iaddr->allocation_group >= BEFS_SB(sb)->num_ags) { > >>> + befs_error(sb, "BEFS: Invalid allocation group %u, max is %u", > >>> + iaddr->allocation_group, BEFS_SB(sb)->num_ags); > >>> + return BEFS_ERR; > >>> + } > >>> return ((iaddr->allocation_group << BEFS_SB(sb)->ag_shift) + > >>> iaddr->start); > >>> } > >>> > >> > >> Hi Salah, > >> > >> To understand why would we check for this. When can this error happen? I mean, > >> when can iaddr2blockno() be called with an out of bounds allocation group? > >> > >> Thanks, > >> Luis > > > > Hi Luis, > > > > allocation group number is set to blockno >> BEFS_SB(sb)->ag_shift by > > blockno2iaddr(), so if ag_shift is not valid, an out of bound may occur. > > By now, thanx to your question ;), I think it's better to check the validity > > of ag_shift when the superblock is loaded. > > > > Nack. > > > > Thanx for the question :) > > Salah > > > > No problem :) > > I will assume the Nack covers patch 1 to 3. Since they are all related. > > Enjoy the weekend, > Luis You too. Salah