From patchwork Mon Jan 26 12:48:19 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Katiyar X-Patchwork-Id: 20275 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 3362A474C2 for ; Mon, 26 Jan 2009 23:48:24 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750978AbZAZMsX (ORCPT ); Mon, 26 Jan 2009 07:48:23 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751056AbZAZMsW (ORCPT ); Mon, 26 Jan 2009 07:48:22 -0500 Received: from ti-out-0910.google.com ([209.85.142.184]:40726 "EHLO ti-out-0910.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751018AbZAZMsW (ORCPT ); Mon, 26 Jan 2009 07:48:22 -0500 Received: by ti-out-0910.google.com with SMTP id b6so3339638tic.23 for ; Mon, 26 Jan 2009 04:48:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=A2ew7cB5TXY6kKunWu3b0keOhQ2i+oO5mzfLIyTrL54=; b=ATrccJMDYhvLE2itzuWfrqA5b5ColriL+wNMsf0Tz8+PLKBWWJbYFbaNOVA0WQ3tmV hF4cn6jWnv5h7K2S0mUOUA0zC/wpzT0L9aNExrQ5efmI659XYia3O7OqldoVo1n1NpL9 2RIaPctjGbg7CkcbEZdDfz8FM8sGJSiglXy1I= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=DIWAHfGgOf9q+3LLlLcB/I35kmyWOrCDMfrKh2nSAanlTMzLrONnfkjcP7wDat16+/ skqsxz1XCInWD2SaNFqd65t0yZthar+qDlPI82pAKm5YCjEMXLPB80QYLRWxrksPgCAc hrt1ClBx7zP8aZwsKiqPW7E/GQcPKzsBK5Dvc= MIME-Version: 1.0 Received: by 10.110.2.2 with SMTP id 2mr2082286tib.17.1232974099641; Mon, 26 Jan 2009 04:48:19 -0800 (PST) In-Reply-To: References: <20090126122907.GA18681@atrey.karlin.mff.cuni.cz> Date: Mon, 26 Jan 2009 18:18:19 +0530 Message-ID: Subject: Re: [PATCH] : make sure the buffer head members are zeroed out before using them. From: Manish Katiyar To: Jan Kara Cc: ext4 , "Theodore Ts'o" , cmm@us.ibm.com Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon, Jan 26, 2009 at 6:03 PM, Manish Katiyar wrote: > On Mon, Jan 26, 2009 at 5:59 PM, Jan Kara wrote: >>> On Tue, Jan 20, 2009 at 10:36 PM, Manish Katiyar wrote: >>> > ext2_quota_read doesn't bzeroes tmp_bh before calling ext2_get_block() >>> > where we access the b_size of it. Since it is a local variable it >>> > might contain some garbage. Make sure it is filled with zero before >>> > passing. >>> >>> Hi Ted/mingming, >>> >>> Any feedback on this ?? >> Ops, sorry. I wanted to reply but first I wanted to research more >> whether we can set b_size to 0 and then forgot about it. Looking into >> other code (e.g. in fs/mpage.c or fs/buffer.c) I think it would be >> better to set b_size to sb->s_blocksize and be done with that. Mapping >> code does not need anything else set to a deterministic value so using >> memset is a bit overkill. > > Thanks Jan for your comments. Yes memset is an overkill. I did it just > because other users of ext2_get_block were doing the same way. Will > rework the patch with setting b_size as blocksize and send again. Here is the updated patch. compile tested. Signed-off-by : Manish Katiyar --- fs/ext2/super.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) return err; @@ -1367,6 +1368,7 @@ static ssize_t ext2_quota_write(struct super_block *sb, int type, sb->s_blocksize - offset : towrite; tmp_bh.b_state = 0; + tmp_bh.b_size = sb->s_blocksize; err = ext2_get_block(inode, blk, &tmp_bh, 1); if (err < 0) goto out; diff --git a/fs/ext2/super.c b/fs/ext2/super.c index da8bdea..2a1c0c6 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -1328,6 +1328,7 @@ static ssize_t ext2_quota_read(struct super_block *sb, int type, char *data, sb->s_blocksize - offset : toread; tmp_bh.b_state = 0; + tmp_bh.b_size = sb->s_blocksize; err = ext2_get_block(inode, blk, &tmp_bh, 0); if (err < 0)