linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Salah Triki <salah.triki@gmail.com>
To: Luis de Bethencourt <luisbg@osg.samsung.com>
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
Date: Fri, 12 Aug 2016 11:17:26 +0100	[thread overview]
Message-ID: <20160812101726.GA18531@pc> (raw)
In-Reply-To: <57AD9932.6050608@osg.samsung.com>

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 <salah.triki@gmail.com>
> >>> ---
> >>>  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

      reply	other threads:[~2016-08-12 10:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-10 22:12 [PATCH 1/4] befs: check allocation_group number before use Salah Triki
2016-08-10 22:12 ` [PATCH 2/4] befs: check return value of iaddr2blockno Salah Triki
2016-08-10 22:12 ` [PATCH 3/4] befs: remove the validation of allocation group number Salah Triki
2016-08-10 22:12 ` [PATCH 4/4] befs: remove unnecessary initialization Salah Triki
2016-08-11 11:07   ` Luis de Bethencourt
2016-08-11 10:56 ` [PATCH 1/4] befs: check allocation_group number before use Luis de Bethencourt
2016-08-12  7:26   ` Salah Triki
2016-08-12  9:38     ` Luis de Bethencourt
2016-08-12 10:17       ` Salah Triki [this message]

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=20160812101726.GA18531@pc \
    --to=salah.triki@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luisbg@osg.samsung.com \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).