RBAC fails hard when `mv`/rename to a subject binary.
Posted: Sat Aug 16, 2014 9:21 am
Changing topic, was: "RBAC does not handle hardlink-rename."
RBAC seems to fail hard if the subject's binary is replaced with binary from the same filesystem, if the subject's binary is already running. If the 'mv' is from different filesystem or the binary is not running, there's not a problem.
The problem is trigged after reloading policy, after the `mv`.
---
Hi.
It seems that RBAC does not handle rename of hardlink, keeping old path in memory as the path of given inode.
For example, if I have subject rule for /usr/sbin/metalog and run prelink, I will start getting:
Same goes for Gentoo's Portage. If $PORTAGE_TMPDIR (default /var/tmp/portage) is on the same filesystem as rootfs, it will try to hardlink instead of copy the files from $D (install path after building) to target path. Then it will start think that /usr/bin/WHATEVER that is already running is indeed from /var/tmp/portage/cat/app/image/usr/bin/WHATEVER and as there's no subject for that, it will deny the accesses (reducing the role to user:U:/).
After prelink and un-prelink everything was fine until `gradm -R` after loading new policy (the only changes were for git subject, totally unrelated). Disabling RBAC via `gradm -D` and re-enabling it with `gradm -E` does not fixes the issue. The only workaround is to restart the given binary like in my case, restart all services.
RBAC seems to fail hard if the subject's binary is replaced with binary from the same filesystem, if the subject's binary is already running. If the 'mv' is from different filesystem or the binary is not running, there's not a problem.
The problem is trigged after reloading policy, after the `mv`.
---
Hi.
It seems that RBAC does not handle rename of hardlink, keeping old path in memory as the path of given inode.
For example, if I have subject rule for /usr/sbin/metalog and run prelink, I will start getting:
- Code: Select all
[2330407.753718] grsec: (root:U:/) use of CAP_SYSLOG denied for /usr/sbin/metalog.#prelink#.lh9QyW[metalog:1033] uid/euid:0/0 gid/egid:0/0, parent /usr/sbin/metalog.#prelink#.lh9QyW[metalog:1032] uid/euid:0/0 gid/egid:0/0
[2330407.753739] grsec: (root:U:/) use of CAP_SYSLOG denied for /usr/sbin/metalog.#prelink#.lh9QyW[metalog:1033] uid/euid:0/0 gid/egid:0/0, parent /usr/sbin/metalog.#prelink#.lh9QyW[metalog:1032] uid/euid:0/0 gid/egid:0/0
[2330407.753742] grsec: (root:U:/) use of CAP_SYSLOG denied for /usr/sbin/metalog.#prelink#.lh9QyW[metalog:1033] uid/euid:0/0 gid/egid:0/0, parent /usr/sbin/metalog.#prelink#.lh9QyW[metalog:1032] uid/euid:0/0 gid/egid:0/0
Same goes for Gentoo's Portage. If $PORTAGE_TMPDIR (default /var/tmp/portage) is on the same filesystem as rootfs, it will try to hardlink instead of copy the files from $D (install path after building) to target path. Then it will start think that /usr/bin/WHATEVER that is already running is indeed from /var/tmp/portage/cat/app/image/usr/bin/WHATEVER and as there's no subject for that, it will deny the accesses (reducing the role to user:U:/).
After prelink and un-prelink everything was fine until `gradm -R` after loading new policy (the only changes were for git subject, totally unrelated). Disabling RBAC via `gradm -D` and re-enabling it with `gradm -E` does not fixes the issue. The only workaround is to restart the given binary like in my case, restart all services.