Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1502411

Re: [PATCH] aio: fix a use after free (and fix freeze protection of aio writes)

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject Re: [PATCH] aio: fix a use after free (and fix freeze protection of aio writes)
Date 2016-10-17 22:00 +0200
Message-ID <stmeL-7YZ-63@gated-at.bofh.it> (permalink)
References <ssMEh-1F5-1@gated-at.bofh.it> <stkPD-7cX-19@gated-at.bofh.it> <stliG-7os-27@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Oct 17, 2016 at 08:55:52PM +0200, Christoph Hellwig wrote:
> On Mon, Oct 17, 2016 at 02:19:47PM -0400, Jeff Moyer wrote:
> > This ends up being a call to __sb_end_write:
> > 
> > void __sb_end_write(struct super_block *sb, int level)
> > {
> >         percpu_up_read(sb->s_writers.rw_sem + level-1);
> > }
> > 
> > Nothing guarantees that submission and completion happen on the same
> > CPU.  Is this safe?
> 
> Good point.  From my reading of the percpu_rwsem implementation it
> is not safe to release it from a different CPU.  Which makes me
> wonder how we can protect aio writes properly here..

percpu-rwsem has the same semantics as regular rwsems, so preemptible
and 'owner' stuff.

Therefore we must support doing up from a different cpu than we did down
on; the owner could've been migrated while we held it.

And while there's a metric ton of tricky in the implementation, this
part is actually fairly straight forward. We only care about the direct
sum of the per-cpu counter, see readers_active_check() -> per_cpu_sum().

So one cpu doing an inc and another doing a dec summed is still 0.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] aio: fix a use after free (and fix freeze protection of aio writes) Christoph Hellwig <hch@lst.de> - 2016-10-16 08:00 +0200
  Re: [PATCH] aio: fix a use after free (and fix freeze protection of aio writes) Jeff Moyer <jmoyer@redhat.com> - 2016-10-17 20:30 +0200
    Re: [PATCH] aio: fix a use after free (and fix freeze protection         of aio writes) Christoph Hellwig <hch@lst.de> - 2016-10-17 21:00 +0200
      Re: [PATCH] aio: fix a use after free (and fix freeze protection of aio writes) Jeff Moyer <jmoyer@redhat.com> - 2016-10-17 21:50 +0200
        Re: [PATCH] aio: fix a use after free (and fix freeze protection of  aio writes) Peter Zijlstra <peterz@infradead.org> - 2016-10-17 22:00 +0200
          Re: [PATCH] aio: fix a use after free (and fix freeze protection         of aio writes) Christoph Hellwig <hch@lst.de> - 2016-10-17 22:10 +0200
          Re: [PATCH] aio: fix a use after free (and fix freeze protection of aio writes) Jeff Moyer <jmoyer@redhat.com> - 2016-10-17 22:10 +0200
      Re: [PATCH] aio: fix a use after free (and fix freeze protection of  aio writes) Peter Zijlstra <peterz@infradead.org> - 2016-10-17 22:00 +0200
  Re: [PATCH] aio: fix a use after free (and fix freeze protection of aio writes) Jeff Moyer <jmoyer@redhat.com> - 2016-10-17 22:10 +0200
  Re: [PATCH] aio: fix a use after free (and fix freeze protection         of aio writes) Christoph Hellwig <hch@lst.de> - 2016-10-24 08:40 +0200

csiph-web