public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: Christoph Hellwig <hch@infradead.org>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH] xfs: validate quota log items during log recovery
Date: Tue, 26 May 2009 11:07:56 -0500	[thread overview]
Message-ID: <4A1C13DC.5000605@sandeen.net> (raw)
In-Reply-To: <20090303175427.GA20582@infradead.org>

Christoph Hellwig wrote:
> Arkadiusz has been seeing really strange crashes in xfs_qm_dqcheck that
> I can only explain by a log item beeing too smal to actually fit the
                                 ^^being too small^^
> xfs_dqblk_t we're dereferencing all over xfs_qm_dqcheck.  So add
> graceful checks for NULL or too small quota items to the log recovery
> code.
> 
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Index: xfs/fs/xfs/xfs_log_recover.c
> ===================================================================
> --- xfs.orig/fs/xfs/xfs_log_recover.c	2009-03-02 04:15:11.410430892 +0100
> +++ xfs/fs/xfs/xfs_log_recover.c	2009-03-02 04:16:29.649444226 +0100
> @@ -1975,16 +1975,26 @@ xlog_recover_do_reg_buffer(
>  		error = 0;
>  		if (buf_f->blf_flags &
>  		   (XFS_BLI_UDQUOT_BUF|XFS_BLI_PDQUOT_BUF|XFS_BLI_GDQUOT_BUF)) {
> +			if (item->ri_buf[i].i_addr == NULL ||
> +			    item->ri_buf[i].i_len < sizeof(xfs_dqblk_t)) {
> +				cmn_err(CE_ALERT,
> +	"XFS: dquot too small (%d) in xlog_recover_do_reg_buffer.",
> +						item->ri_buf[i].i_len);

Shouldn't this differentiate between i_addr == NULL and i_len too small,
though?  While we're at it anyway...

Maybe:

+	"XFS: dquot null addr (%p) or len too small (%d) in %s."
+	item->ri_buf[i].i_addr, item->ri_buf[i].i_len, __func__);

? (not hardcoding function name may be good too)

> +				goto next;
> +			}
>  			error = xfs_qm_dqcheck((xfs_disk_dquot_t *)
>  					       item->ri_buf[i].i_addr,
>  					       -1, 0, XFS_QMOPT_DOWARN,
>  					       "dquot_buf_recover");
> +			if (error)
> +				goto next;

I guess we can't do much else, but what happens in the end, when we skip
a buffer...

>  		}
> -		if (!error)
> -			memcpy(xfs_buf_offset(bp,
> -				(uint)bit << XFS_BLI_SHIFT),	/* dest */
> -				item->ri_buf[i].i_addr,		/* source */
> -				nbits<<XFS_BLI_SHIFT);		/* length */
> +
> +		memcpy(xfs_buf_offset(bp,
> +			(uint)bit << XFS_BLI_SHIFT),	/* dest */
> +			item->ri_buf[i].i_addr,		/* source */
> +			nbits<<XFS_BLI_SHIFT);		/* length */
> + next:
>  		i++;
>  		bit += nbits;
>  	}
> @@ -2615,7 +2625,15 @@ xlog_recover_do_dquot_trans(
>  		return (0);
>  
>  	recddq = (xfs_disk_dquot_t *)item->ri_buf[1].i_addr;
> -	ASSERT(recddq);
> +
> +	if (item->ri_buf[1].i_addr == NULL ||
> +	    item->ri_buf[1].i_len < sizeof(xfs_dqblk_t)) {
> +		cmn_err(CE_ALERT,
> +	"XFS: dquot too small (%d) in xlog_recover_do_dquot_trans.",
> +			item->ri_buf[1].i_len);

Same deal here, should you differentiate on the error & use __func__ ?

-Eric

> +		return XFS_ERROR(EIO);
> +	}
> +
>  	/*
>  	 * This type of quotas was turned off, so ignore this record.
>  	 */
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
> 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2009-05-26 16:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-03 17:54 [PATCH] xfs: validate quota log items during log recovery Christoph Hellwig
2009-03-16  7:54 ` Christoph Hellwig
2009-03-29  7:42   ` Christoph Hellwig
2009-05-26  9:11     ` Christoph Hellwig
2009-04-04 11:59 ` Arkadiusz Miskiewicz
2009-05-26 16:07 ` Eric Sandeen [this message]
2009-05-27  9:17   ` Christoph Hellwig
2009-05-27 19:06     ` Eric Sandeen

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=4A1C13DC.5000605@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=hch@infradead.org \
    --cc=xfs@oss.sgi.com \
    /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