Skip to content

Resolve file paths inside OSCAP_PROBE_ROOT - #2475

Open
0intro wants to merge 1 commit into
OpenSCAP:mainfrom
0intro:djc/probe-root-paths
Open

0intro wants to merge 1 commit into
OpenSCAP:mainfrom
0intro:djc/probe-root-paths

Conversation

@0intro

@0intro 0intro commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

The file probes join OSCAP_PROBE_ROOT with the paths they read, and
the kernel resolves an absolute symbolic link from the real root. So
with a RHEL 9 root, whose /etc/pam.d/system-auth links to
/etc/authselect/system-auth, the PAM checks read the scanner's
files, and the file walker skipped such links as dangling.

test_probes_system_info_offline_mode.sh linked etc to the real /etc,
which now resolves to itself, so it builds a root of its own.

Also have the partition probe read the root's /proc/1/mounts, since
the root's /proc/mounts lists the mounts of the reading process.

@0intro
0intro force-pushed the djc/probe-root-paths branch from fd36cab to 141e7d8 Compare October 29, 2026 20:51
@Mab879 Mab879 self-assigned this Nov 19, 2026
@Mab879 Mab879 added this to the 1.4.7 milestone Nov 20, 2026
Comment thread src/common/util.c
errno = ELOOP;
return NULL;
}
if (n < 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do some more checking here?

A symlink like /missing/../etc/authselect/system-auth will work, but in chroot environment it returns ENOENT.

We will need to better track errors here.

Comment thread src/common/util.c Outdated
memcpy(rest, target, strlen(target));
p = rest;
}
return oscap_sprintf("%.*s%s", (int)rootlen, root, outlen > 0 ? out : "/");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unconditional drop the final / can be problematic.

A symlink to a directory becomes a readable file vs error out as not directory in some edge cases.

The file probes join OSCAP_PROBE_ROOT with the paths they read, and
the kernel resolves an absolute symbolic link from the real root. So
with a RHEL 9 root, whose /etc/pam.d/system-auth links to
/etc/authselect/system-auth, the PAM checks read the scanner's
files, and the file walker skipped such links as dangling.

test_probes_system_info_offline_mode.sh linked etc to the real /etc,
which now resolves to itself, so it builds a root of its own.

Also have the partition probe read the root's /proc/1/mounts, since
the root's /proc/mounts lists the mounts of the reading process.
@0intro
0intro force-pushed the djc/probe-root-paths branch from 141e7d8 to 48e3688 Compare November 25, 2026 15:54
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

Successfully merging this pull request may close these issues.

2 participants