Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed to open /usr/lib/x86_64-linux-gnu/libc.so.6 when injecting #39

Open
BrandowLucas opened this issue Jun 4, 2024 · 1 comment
Open

Comments

@BrandowLucas
Copy link

BrandowLucas commented Jun 4, 2024

shell ~ sudo ./injector -n procExample -p 2167 ~/lib.so

targeting process "procExample" with pid 2167
targeting process with pid 2167

failed to open /usr/lib/x86_64-linux-gnu/libc.so.6. (dev:0x1b, ino:557139)

I was getting this error on Arch Linux, now I tried on Ubuntu 22 LTS and I could reproduce the same issue.

Until some months ago I could inject this same shared library on the same process id, now I can't anymore.

ldd --version
ldd (Ubuntu GLIBC 2.35-0ubuntu3.8) 2.35 / 2.39 (on arch-linux)

@Brandon-T
Copy link

Brandon-T commented Nov 8, 2024

static inline int is_on_overlay_fs(int fd)
{
    struct statfs sbuf;
    if (fstatfs(fd, &sbuf) != 0) {
        DEBUG(" fstatfs() error %s\n", strerror(errno));
        return -1;
    }
#ifndef OVERLAYFS_SUPER_MAGIC
#define OVERLAYFS_SUPER_MAGIC 0x794c7630
#endif
    return (sbuf.f_type == OVERLAYFS_SUPER_MAGIC) ? 1 : 0;
}

This line is causing the issue. On Fedora Workstation for example, sbuf.f_type is BTRFS_SUPER_MAGIC and not OVERLAYFS_SUPER_MAGIC. If I comment out that line and return true (1), it works just fine. So this check will break on different file system types.

There are a ton of Linux file-systems that this library works on, but will fail due to the above check. https://man7.org/linux/man-pages/man2/statfs.2.html lists all of them.

cc: @kubo . It might be better to try the injection, and if it fails, then return an error, rather than trying to detect all the file-system types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants