eminence / eminence/procfs

Internal error when there is limited permissions to /proc

Open
#367 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
445
Forks
134
PR merge metrics
No merged PRs in 30d

Description

When the process running the crates is having limited privileges, it trigger an `Internal error`.

First of all, this a strange setup, it happens when I was trying to debug a container, so I'm not sure if this is a valid bug.

Here is the minimal example which will trigger the error:

```rust
fn main() {
println!("Hello, world!");

match procfs::process::all_processes() {
Ok(all) => {
for p in all {
//for n in p.unwrap().namespaces().unwrap().0.values() {
match p {
Ok(o) => match o.namespaces() {
Ok(n) => {
println!("{:?}", n);
}
Err(e) => {
println!("{e}");
}
},
Err(e) => {
println!("{e}")
}
}
}
}
Err(e) => {
println!("{e}")
}
}
}
```

This can be build in a container with the following `Containerfile`:

```dockerfile
FROM rust

RUN mkdir /app

COPY src /app/src
COPY Cargo.* /app/

WORKDIR /app

RUN --mount=type=cache,target=/app/target/ \
--mount=type=cache,target=/usr/local/cargo/git/db \
--mount=type=cache,target=/usr/local/cargo/registry/ \
cargo install --path .

#RUN procfs-bug
CMD ["procfs-bug"]
```

Then, this can be build in a container with:

```
$ sudo podman build . -t procfs-bug
```

And when it runs with the following configuration, it will trigger the internal error
```
$ sudo podman run -it --pid=host procfs-bug
Hello, world!
Internal error: bug at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/procfs-0.18.0/src/process/namespaces.rs:33 (please report this procfs bug)
Internal Unwrap Error: Unable to stat "/proc/1/ns/net"
Internal error: bug at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/procfs-0.18.0/src/process/namespaces.rs:33 (please report this procfs bug)
Internal Unwrap Error: Unable to stat "/proc/2/ns/net"
Internal error: bug at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/procfs-0.18.0/src/process/namespaces.rs:33 (please report this procfs bug)
Internal Unwrap Error: Unable to stat "/proc/3/ns/net"
Internal error: bug at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/procfs-0.18.0/src/process/namespaces.rs:33 (please report this procfs bug)
Internal Unwrap Error: Unable to stat "/proc/4/ns/net"
Internal error: bug at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/procfs-0.18.0/src/process/namespaces.rs:33 (please report this procfs bug)
Internal Unwrap Error: Unable to stat "/proc/5/ns/net"
Internal error: bug at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/procfs-0.18.0/src/process/namespaces.rs:33 (please report this procfs bug)
Internal Unwrap Error: Unable to stat "/proc/6/ns/net"
Internal error: bug at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/procfs-0.18.0/src/process/namespaces.rs:33 (please report this procfs bug)
Internal Unwrap Error: Unable to stat "/proc/7/ns/net"
Internal error: bug at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/procfs-0.18.0/src/process/namespaces.rs:33 (please report this procfs bug)
Internal Unwrap Error: Unable to stat "/proc/8/ns/net"
Internal error: bug at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/procfs-0.18.0/src/process/namespaces.rs:33 (please report this procfs bug)
Internal Unwrap Error: Unable to stat "/proc/13/ns/net"
Internal error: bug at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/procfs-0.18.0/src/process/namespaces.rs:33 (please report this procfs bug)
Internal Unwrap Error: Unable to stat "/proc/15/ns/net"
Internal error: bug at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/procfs-0.18.0/src/process/namespaces.rs:33 (please report this procfs bug)
Internal Unwrap Error: Unable to stat "/proc/16/ns/net"
Internal error: bug at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/procfs-0.18.0/src/process/namespaces.rs:33 (please report this procfs bug)
Internal Unwrap Error: Unable to stat "/proc/17/ns/net"
Internal error: bug at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/procfs-0.18.0/src/process/namespaces.rs:33 (please report this procfs bug)
Internal Unwrap Error: Unable to stat "/proc/18/ns/net"
Internal error: bug at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/procfs-0.18.0/src/process/namespaces.rs:33 (please report this procfs bug)
Internal Unwrap Error: Unable to stat "/proc/19/ns/net"
Internal error: bug at /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/procfs-0.18.0/src/process/namespaces.rs:33 (please report this procfs bug)
Internal Unwrap Error: Unable to stat "/proc/20/ns/net"
...
```

If you don't know podman, the options I set will give the container access to the host `/proc` as the root user but remove some capabilities.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.