Giter VIP home page Giter VIP logo

Comments (5)

mvollmer avatar mvollmer commented on July 3, 2024

I don't think this needs anything special to reproduce. Any encrypted pool with a passphrase should exhibit this behavior. I found it when stratis-min failed like this during boot when called from stratis-fstab-setup.

from stratisd.

mvollmer avatar mvollmer commented on July 3, 2024

I could also reproduce this after boot, by stopping stratisd.service and then running stratisd-min and stratis-min from the command line.

from stratisd.

mulkieran avatar mulkieran commented on July 3, 2024

Smoking gun has got to be here:

+++ b/src/jsonrpc/client/key.rs
@@ -25,7 +25,7 @@ pub fn key_set(key_desc: KeyDescription, keyfile_path: Option<
&str>) -> StratisR
 
             let (read_end, write_end) = pipe()?;
             write(write_end, password.as_bytes())?;
-            do_request!(KeySet, key_desc; read_end)
+            do_request!(KeySet, key_desc; read_end.as_raw_fd())
         }
     };
     if rc != 0 {

and here:

--- a/src/jsonrpc/client/pool.rs
+++ b/src/jsonrpc/client/pool.rs
@@ -2,7 +2,7 @@
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-use std::path::PathBuf;
+use std::{os::fd::AsRawFd, path::PathBuf};
 
 use nix::unistd::{pipe, write};
 
@@ -37,7 +37,7 @@ pub fn pool_start(
         do_request_standard!(PoolStart, id, unlock_method; {
             let (read_end, write_end) = pipe()?;
             write(write_end, password.as_bytes())?;
-            read_end
+            read_end.as_raw_fd()
         })
     } else {
         do_request_standard!(PoolStart, id, unlock_method)

Actually, I believe the first change is benign because the pipe is created before the macro is expanded.

from stratisd.

mvollmer avatar mvollmer commented on July 3, 2024
-            do_request!(KeySet, key_desc; read_end)
+            do_request!(KeySet, key_desc; read_end.as_raw_fd())

Just thinking out loud, I have no idea what's actually going on: Does this now leak the file descriptor? I.e., where is it closed now? But maybe this doesn't matter in a one-shot process like stratis-min. It will exit very soon anyway.

from stratisd.

mulkieran avatar mulkieran commented on July 3, 2024
-            do_request!(KeySet, key_desc; read_end)
+            do_request!(KeySet, key_desc; read_end.as_raw_fd())

Just thinking out loud, I have no idea what's actually going on: Does this now leak the file descriptor? I.e., where is it closed now? But maybe this doesn't matter in a one-shot process like stratis-min. It will exit very soon anyway.

The do_request_standard! macros final "argument" is the entire expression below.

let (read_end, write_end) = pipe()?;
             write(write_end, password.as_bytes())?;
            read_end

When the macro is expanded, that whole bit of syntax is evaluated and used in the call. That worked, when read_end was the value of the expression, because Rust lifetime rules prevented drop from being called on the file descriptor while it was in use. But when nix went to requiring a raw file descriptor instead, i.e., just a number, the lifetime rules allowed the file to be dropped while that number was still in use.

from stratisd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.