From: Jesper Juhl <juhl-lkml@dif.dk>
To: Jesper Juhl <juhl-lkml@dif.dk>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Gadi Oxman <gadio@netvision.net.il>, Jens Axboe <axboe@suse.de>,
Andrew Morton <akpm@osdl.org>
Subject: Re: [PATCH][2/2] ide-tape: small cleanups - handle copy_to|from_user() failures
Date: Sun, 28 Nov 2004 22:16:39 +0100 (CET) [thread overview]
Message-ID: <Pine.LNX.4.61.0411282212340.3389@dragon.hygekrogen.localhost> (raw)
In-Reply-To: <Pine.LNX.4.61.0411282028200.3389@dragon.hygekrogen.localhost>
On Sun, 28 Nov 2004, Jesper Juhl wrote:
> On Sun, 28 Nov 2004, Alan Cox wrote:
>
> > On Sul, 2004-11-28 at 16:32, Jesper Juhl wrote:
> > > #endif /* IDETAPE_DEBUG_BUGS */
> > > count = min((unsigned int)(bh->b_size - atomic_read(&bh->b_count)), (unsigned int)n);
> > > - copy_from_user(bh->b_data + atomic_read(&bh->b_count), buf, count);
> > > + if (copy_from_user(bh->b_data + atomic_read(&bh->b_count), buf, count))
> > > + return -EFAULT;
> > > n -= count;
> > > atomic_add(count, &bh->b_count);
> > > buf += count;
> >
> > If you do this then you don't fix up tape->bh for further operations.
>
> True, if copy_from_user fails it just bails out, I didn't see anything
> really bad that could happen from that, but I'm an idiot, looking at it
> again I guess it could probably mess up tape->bh pretty bad.
> Guess I need to go back and look at this in greater detail.
Does this really matter though? if copy_from_user fails here the function
bails out, and with the other changes I made the caller will bail out as
well with the effect that the entire IO operation will fail. and once a
new read or write is submitted we get a brand new tape->bh
Am I completely brain-dead or is it not in fact OK as I wrote it the first
time?
--
Jesper Juhl
next prev parent reply other threads:[~2004-11-28 21:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-28 16:32 Jesper Juhl
2004-11-28 17:34 ` Alan Cox
2004-11-28 19:39 ` Jesper Juhl
2004-11-28 21:16 ` Jesper Juhl [this message]
2004-11-29 22:47 ` Bill Davidsen
2004-11-29 23:23 ` Jesper Juhl
2004-11-30 12:03 ` Alan Cox
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=Pine.LNX.4.61.0411282212340.3389@dragon.hygekrogen.localhost \
--to=juhl-lkml@dif.dk \
--cc=akpm@osdl.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=axboe@suse.de \
--cc=gadio@netvision.net.il \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®