All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: linux-kernel@vger.kernel.org
Cc: Andi Kleen <ak@linux.intel.com>,
	tytso@mit.edu, linux-ext4@vger.kernel.org
Subject: [PATCH 08/11] ext4: Fix end of group handling in ext4_mb_init_cache
Date: Mon, 30 Sep 2013 13:29:09 -0700	[thread overview]
Message-ID: <1380572952-30729-9-git-send-email-andi@firstfloor.org> (raw)
In-Reply-To: <1380572952-30729-1-git-send-email-andi@firstfloor.org>

From: Andi Kleen <ak@linux.intel.com>

The first loop in ext4_mb_init_cache can bail out when the end of
all groups is reached. Unfortunately the later loops did not
have that check and could access uninitialized buffer pointers
in bh[]. Add the end of group check everywhere.

Cc: tytso@mit.edu
Cc: linux-ext4@vger.kernel.org
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 Makefile          | 6 +++---
 fs/ext4/mballoc.c | 6 +++++-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 8d0668f..be3ef83 100644
--- a/Makefile
+++ b/Makefile
@@ -663,9 +663,9 @@ KBUILD_CFLAGS   += $(call cc-option,-fconserve-stack)
 KBUILD_ARFLAGS := $(call ar-option,D)
 
 # check for 'asm goto'
-ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC)), y)
-	KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
-endif
+#ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC)), y)
+#	KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
+#endif
 
 # Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
 KBUILD_CPPFLAGS += $(KCPPFLAGS)
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index a41e3ba..619d8ed 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -878,6 +878,8 @@ static int ext4_mb_init_cache(struct page *page, char *incore)
 
 	/* wait for I/O completion */
 	for (i = 0, group = first_group; i < groups_per_page; i++, group++) {
+		if (group >= ngroups)
+			break;
 		if (bh[i] && ext4_wait_block_bitmap(sb, group, bh[i])) {
 			err = -EIO;
 			goto out;
@@ -953,7 +955,9 @@ static int ext4_mb_init_cache(struct page *page, char *incore)
 
 out:
 	if (bh) {
-		for (i = 0; i < groups_per_page; i++)
+		for (i = 0, group = first_group;
+		     i < groups_per_page && group < ngroups;
+		     i++, group++)
 			brelse(bh[i]);
 		if (bh != &bhs)
 			kfree(bh);
-- 
1.8.3.1


  parent reply	other threads:[~2013-09-30 20:29 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-30 20:29 Various static checker fixes Andi Kleen
2013-09-30 20:29 ` [PATCH 01/11] random: don't feed stack data into pool when interrupt regs NULL Andi Kleen
2013-09-30 20:51   ` Luck, Tony
2013-10-01 12:44     ` Theodore Ts'o
2014-04-04 16:54       ` Sebastian Andrzej Siewior
2014-04-07  4:01         ` Theodore Ts'o
2014-04-07 19:30           ` Sebastian Andrzej Siewior
2014-04-07 23:26             ` Theodore Ts'o
2014-04-09 18:14             ` rkuo
2013-09-30 20:29 ` [PATCH 02/11] Disable initialized_var for clang Andi Kleen
2013-09-30 20:29 ` [PATCH 03/11] posix-timers: Initialize timer value to 0 for invalid timers Andi Kleen
2013-09-30 20:29 ` [PATCH 04/11] block: Return error code of elevator init function Andi Kleen
2013-10-01 12:25   ` Jeff Moyer
2013-09-30 20:29 ` [PATCH 05/11] seq_file: Handle ->next error in seq_read Andi Kleen
2013-09-30 20:29 ` [PATCH 06/11] sysctl: remove unnecessary variable initialization Andi Kleen
2013-09-30 20:29 ` [PATCH 07/11] igb: Avoid uninitialized advertised variable in eee_set_cur Andi Kleen
2013-10-01 15:00   ` Wyborny, Carolyn
2013-10-01 23:10   ` Jeff Kirsher
2013-10-02 20:33   ` David Miller
2013-09-30 20:29 ` Andi Kleen [this message]
2013-10-01 12:45   ` [PATCH 08/11] ext4: Fix end of group handling in ext4_mb_init_cache Theodore Ts'o
2013-10-01 14:20     ` Andi Kleen
2013-09-30 20:29 ` [PATCH 09/11] epoll: Remove unnecessary error path Andi Kleen
2013-09-30 20:59   ` Eric Wong
2013-09-30 21:01     ` Andi Kleen
2013-09-30 20:29 ` [PATCH 10/11] tcp: Always set options to 0 before calling tcp_established_options Andi Kleen
2013-10-02 20:33   ` David Miller
2013-09-30 20:29 ` [PATCH 11/11] perf: Avoid uninitialized sample type reference in __perf_event__output_id_sample Andi Kleen
2013-10-02  8:57   ` Peter Zijlstra
2013-10-02 17:25     ` Andi Kleen
2013-10-02 17:36       ` Peter Zijlstra
2013-10-03  6:42         ` Ingo Molnar
2013-10-03 18:16           ` Andi Kleen
2013-10-04  6:24             ` Ingo Molnar

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=1380572952-30729-9-git-send-email-andi@firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=ak@linux.intel.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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 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.