lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1375746189.18481.23.camel@dabdike.int.hansenpartnership.com>
Date:	Mon, 05 Aug 2013 16:43:09 -0700
From:	James Bottomley <James.Bottomley@...senPartnership.com>
To:	Roland Dreier <roland@...nel.org>
Cc:	Jens Axboe <axboe@...nel.dk>, Doug Gilbert <dgilbert@...erlog.com>,
	Costa Sapuntzakis <costa@...estorage.com>,
	Jörn Engel <joern@...estorage.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	linux-scsi <linux-scsi@...r.kernel.org>
Subject: Re: [PATCH] [SCSI] sg: Fix user memory corruption when SG_IO is
 interrupted by a signal

On Mon, 2013-08-05 at 16:38 -0700, Roland Dreier wrote:
> On Mon, Aug 5, 2013 at 4:31 PM, James Bottomley
> <James.Bottomley@...senpartnership.com> wrote:
> > I agree with the analysis.  The fix is a bit draconian, though.  A
> > workqueue actually runs in a kernel thread and there's a simple test for
> > that (!current->mm), so how about this instead (which is much less
> > intrusive)
> 
> > ---
> 
> > diff --git a/fs/bio.c b/fs/bio.c
> > index 94bbc04..e2ab39c 100644
> > --- a/fs/bio.c
> > +++ b/fs/bio.c
> > @@ -1045,12 +1045,22 @@ static int __bio_copy_iov(struct bio *bio, struct bio_vec *iovecs,
> >  int bio_uncopy_user(struct bio *bio)
> >  {
> >         struct bio_map_data *bmd = bio->bi_private;
> > -       int ret = 0;
> > +       struct bio_vec *bvec;
> > +       int ret = 0, i;
> >
> > -       if (!bio_flagged(bio, BIO_NULL_MAPPED))
> > -               ret = __bio_copy_iov(bio, bmd->iovecs, bmd->sgvecs,
> > -                                    bmd->nr_sgvecs, bio_data_dir(bio) == READ,
> > -                                    0, bmd->is_our_pages);
> > +       if (!bio_flagged(bio, BIO_NULL_MAPPED)) {
> > +               /*
> > +                * if we're in a workqueue, the request is orphaned, so
> > +                * don't copy into the kernel address space, just free
> > +                */
> > +               if (current->mm)
> > +                       ret = __bio_copy_iov(bio, bmd->iovecs, bmd->sgvecs,
> > +                                            bmd->nr_sgvecs, bio_data_dir(bio) == READ,
> > +                                            0, bmd->is_our_pages);
> > +               else if (bmd->is_our_pages)
> > +                       bio_for_each_segment_all(bvec, bio, i)
> > +                               __free_page(bvec->bv_page);
> > +       }
> >         bio_free_map_data(bmd);
> >         bio_put(bio);
> >         return ret;
> 
> Yes, looks reasonable -- I can't think of any reason why anyone would
> ever want the bio code to copy to a random userspace address space.
> 
> Acked-by: Roland Dreier <roland@...estorage.com>

You did all the work ... just replace this patch with your previous one
and keep the original tags. (test it first, of course ...)

James


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ