All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] UBIFS: fix assertion in layout_in_gaps()
@ 2016-08-12 13:26 Vincent Stehlé
  2016-08-12 15:39 ` Artem Bityutskiy
  2016-08-14  9:00 ` Richard Weinberger
  0 siblings, 2 replies; 4+ messages in thread
From: Vincent Stehlé @ 2016-08-12 13:26 UTC (permalink / raw)
  To: linux-mtd; +Cc: linux-kernel, Vincent Stehlé, Artem Bityutskiy

An assertion in layout_in_gaps() verifies that the gap_lebs pointer is
below the maximum bound. When computing this maximum bound the idx_lebs
count is multiplied by sizeof(int), while C pointers arithmetic does take
into account the size of the pointed elements implicitly already. Remove
the multiplication to fix the assertion.

Fixes: 1e51764a3c2ac05a ("UBIFS: add new flash file system")
Signed-off-by: Vincent Stehlé <vincent.stehle@intel.com>
Cc: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
---
 fs/ubifs/tnc_commit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ubifs/tnc_commit.c b/fs/ubifs/tnc_commit.c
index b45345d..51157da 100644
--- a/fs/ubifs/tnc_commit.c
+++ b/fs/ubifs/tnc_commit.c
@@ -370,7 +370,7 @@ static int layout_in_gaps(struct ubifs_info *c, int cnt)
 
 	p = c->gap_lebs;
 	do {
-		ubifs_assert(p < c->gap_lebs + sizeof(int) * c->lst.idx_lebs);
+		ubifs_assert(p < c->gap_lebs + c->lst.idx_lebs);
 		written = layout_leb_in_gaps(c, p);
 		if (written < 0) {
 			err = written;
-- 
2.8.1

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

* Re: [PATCH] UBIFS: fix assertion in layout_in_gaps()
  2016-08-12 13:26 [PATCH] UBIFS: fix assertion in layout_in_gaps() Vincent Stehlé
@ 2016-08-12 15:39 ` Artem Bityutskiy
  2016-08-14  9:00 ` Richard Weinberger
  1 sibling, 0 replies; 4+ messages in thread
From: Artem Bityutskiy @ 2016-08-12 15:39 UTC (permalink / raw)
  To: Vincent Stehlé, linux-mtd; +Cc: linux-kernel

On Fri, 2016-08-12 at 15:26 +0200, Vincent Stehlé wrote:
> An assertion in layout_in_gaps() verifies that the gap_lebs pointer
> is
> below the maximum bound. When computing this maximum bound the
> idx_lebs
> count is multiplied by sizeof(int), while C pointers arithmetic does
> take
> into account the size of the pointed elements implicitly already.
> Remove
> the multiplication to fix the assertion.
> 
> Fixes: 1e51764a3c2ac05a ("UBIFS: add new flash file system")
> Signed-off-by: Vincent Stehlé <vincent.stehle@intel.com>
> Cc: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>

Thanks!

-- 
Best Regards,
Artem Bityutskiy

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

* Re: [PATCH] UBIFS: fix assertion in layout_in_gaps()
  2016-08-12 13:26 [PATCH] UBIFS: fix assertion in layout_in_gaps() Vincent Stehlé
  2016-08-12 15:39 ` Artem Bityutskiy
@ 2016-08-14  9:00 ` Richard Weinberger
  2016-08-16  7:33   ` Vincent Stehlé
  1 sibling, 1 reply; 4+ messages in thread
From: Richard Weinberger @ 2016-08-14  9:00 UTC (permalink / raw)
  To: Vincent Stehlé; +Cc: linux-mtd, LKML, Artem Bityutskiy

Vincent,

On Fri, Aug 12, 2016 at 3:26 PM, Vincent Stehlé
<vincent.stehle@intel.com> wrote:
> An assertion in layout_in_gaps() verifies that the gap_lebs pointer is
> below the maximum bound. When computing this maximum bound the idx_lebs
> count is multiplied by sizeof(int), while C pointers arithmetic does take
> into account the size of the pointed elements implicitly already. Remove
> the multiplication to fix the assertion.
>
> Fixes: 1e51764a3c2ac05a ("UBIFS: add new flash file system")
> Signed-off-by: Vincent Stehlé <vincent.stehle@intel.com>
> Cc: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
> ---
>  fs/ubifs/tnc_commit.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ubifs/tnc_commit.c b/fs/ubifs/tnc_commit.c
> index b45345d..51157da 100644
> --- a/fs/ubifs/tnc_commit.c
> +++ b/fs/ubifs/tnc_commit.c
> @@ -370,7 +370,7 @@ static int layout_in_gaps(struct ubifs_info *c, int cnt)
>
>         p = c->gap_lebs;
>         do {
> -               ubifs_assert(p < c->gap_lebs + sizeof(int) * c->lst.idx_lebs);
> +               ubifs_assert(p < c->gap_lebs + c->lst.idx_lebs);

Good catch! Did you hit this assertion or was it found by review?
I bet the latter since it is here since ever and given the wrongness
it is unlikely to trigger.

-- 
Thanks,
//richard

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

* Re: [PATCH] UBIFS: fix assertion in layout_in_gaps()
  2016-08-14  9:00 ` Richard Weinberger
@ 2016-08-16  7:33   ` Vincent Stehlé
  0 siblings, 0 replies; 4+ messages in thread
From: Vincent Stehlé @ 2016-08-16  7:33 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: linux-mtd, LKML, Artem Bityutskiy

On Sun, Aug 14, 2016 at 11:00:33AM +0200, Richard Weinberger wrote:
..
> Good catch! Did you hit this assertion or was it found by review?
> I bet the latter since it is here since ever and given the wrongness
> it is unlikely to trigger.

Dear Richard,

It was found with a static checker and later review to confirm.

Best regards,

Vincent.

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

end of thread, other threads:[~2016-08-16  7:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-12 13:26 [PATCH] UBIFS: fix assertion in layout_in_gaps() Vincent Stehlé
2016-08-12 15:39 ` Artem Bityutskiy
2016-08-14  9:00 ` Richard Weinberger
2016-08-16  7:33   ` Vincent Stehlé

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.