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: <CANeycqotBmHkXAFbibp3BerEt=RA6sse+dgAkmpcy+oFMiA-vA@mail.gmail.com>
Date:   Thu, 30 Mar 2023 18:04:48 -0300
From:   Wedson Almeida Filho <wedsonaf@...il.com>
To:     Benno Lossin <y86-dev@...tonmail.com>
Cc:     rust-for-linux@...r.kernel.org, Miguel Ojeda <ojeda@...nel.org>,
        Alex Gaynor <alex.gaynor@...il.com>,
        Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
        Björn Roy Baron <bjorn3_gh@...tonmail.com>,
        linux-kernel@...r.kernel.org,
        Wedson Almeida Filho <walmeida@...rosoft.com>
Subject: Re: [PATCH 13/13] rust: sync: introduce `LockedBy`

On Thu, 30 Mar 2023 at 08:45, Benno Lossin <y86-dev@...tonmail.com> wrote:
>
> On 30.03.23 13:28, Benno Lossin wrote:
>      struct Outer {
>          mtx1: Mutex<()>,
>          mtx2: Mutex<()>,
>          inners: Vec<Inner>,
>      }
>
>      struct Inner {
>          count: LockedBy<usize, ()>,
>      }
>
>      fn new_inner(outer: &Outer) -> Inner {
>          Inner { count: LockedBy::new(&outer.mtx1, 0) }
>      }
>
>      fn evil(outer: &Outer) {
>          let inner = outer.inners.get(0).unwrap();
>          let mut guard1 = outer.mtx1.lock();
>          let mut guard2 = outer.mtx2.lock();
>         // The pointee of `guard1` and `guard2` have the same address.
>          let ref1 = inner.count.access_mut(&mut *guard1);
>          let ref2 = inner.count.access_mut(&mut *guard2);
>          mem::swap(ref1, ref2);
>      }

This doesn't reproduce the issue because `mtx2` itself is not a ZST
(it contains a `struct mutex` before the data it protects).

Something like the following should reproduce it though:

    struct Outer {
         mtx1: Mutex<()>,
         zst: (),
     }

     fn evil(outer: &Outer) {
         let lb = LockedBy::new(&outer.mtx1, 0u8);
         let value = lb.access(&outer.zst);
         // Accessing "value" without holding `mtx1`.
         pr_info!("{}", *value);
     }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ