xfs
[Top] [All Lists]

Re: [patch] xfsprogs: repair pagefault due to missed out sanity NULL che

To: Ajeet Yadav <ajeet.yadav.77@xxxxxxxxx>
Subject: Re: [patch] xfsprogs: repair pagefault due to missed out sanity NULL check
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Mon, 31 Jan 2011 15:17:29 +1100
Cc: xfs@xxxxxxxxxxx
In-reply-to: <AANLkTiktigbHHHsYrxRBja6LxQ3N_gAq_KAoLNYGRB=r@xxxxxxxxxxxxxx>
References: <AANLkTiktigbHHHsYrxRBja6LxQ3N_gAq_KAoLNYGRB=r@xxxxxxxxxxxxxx>
User-agent: Mutt/1.5.20 (2009-06-14)
On Fri, Jan 28, 2011 at 08:13:04PM +0900, Ajeet Yadav wrote:
> libxfs_putbuf() is called with bp = NULL, resulting in pagefault in
> libpthread.
> 
> Function da_read_buf() allocate array of xfs_buf_t *
> 
>    * xfs_buf_t       **bplist;*
> 
> *    bplist = calloc(nex, sizeof(*bplist));*
> 
> Read and fill it using
> 
> *for (i = 0; i < nex; i++) {
>     bplist[i] = libxfs_readbuf()*
> 
> *    if (!bplist[i]){
>         goto failed;
>     }  *
> 
> *}*
> 
> *failed:
>         for (i = 0; i < nex; i++)
>                 libxfs_putbuf(bplist[i]);*
> 
> Now assume nex = 10,
> 
> 1. Will create bplist for 10 array elements.
> 
> 3. Reading from disk 0,1, 2, 3
> 
> 4. When reading from disk 4, USB is removed
> 
> 5. libxfs_readbuf() will at fail, pblist[4] = NULL, goto failed.
> 
> 6. Since only 4 buffers were read successfully, so only 4 are in lock state.
> 
> 7.  Error handling will unlock buffer from 1-10
> 
> 8. Buffer 0-3 were read successfully, hence will have valid pdlist[i]
> 
> 9. Access pblist[4] == NULL, therefore unlocking will set bp == NULL in
> libxfs_putbuf(bp);
> 10. Page fault in libpthread
> 
> 
> Solution patch attached with mail

Can you please include the patches in-line in your email rather than
as base64 encoded attachments? Even though it is for xfsprogs, we
ask that the same process is followed as per kernel patches. That
includes addіng Signed-off-by tags to the patches...

See Documentation/SubmittingPatches:

| 7) No MIME, no links, no compression, no attachments.  Just plain text.
| 
| Linus and other kernel developers need to be able to read and comment
| on the changes you are submitting.  It is important for a kernel
| developer to be able to "quote" your changes, using standard e-mail
| tools, so that they may comment on specific portions of your code.
| 
| For this reason, all patches should be submitting e-mail "inline".
| WARNING:  Be wary of your editor's word-wrap corrupting your patch,
| if you choose to cut-n-paste your patch.
| 
| Do not attach the patch as a MIME attachment, compressed or not.
| Many popular e-mail applications will not always transmit a MIME
| attachment as plain text, making it impossible to comment on your
| code.  A MIME attachment also takes Linus a bit more time to process,
| decreasing the likelihood of your MIME-attached change being accepted.
| 
| Exception:  If your mailer is mangling patches then someone may ask
| you to re-send them using MIME.
| 
| See Documentation/email-clients.txt for hints about configuring
| your e-mail client so that it sends your patches untouched.

And as it suggests, read Documentation/email-clients.txt on how to
do this with various mail clients.

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>