]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fincore: do not fall back to mincore if cachestat fails with EPERM
authorThomas Weißschuh <thomas@t-8ch.de>
Sat, 1 Nov 2025 13:58:34 +0000 (14:58 +0100)
committerThomas Weißschuh <thomas@t-8ch.de>
Sat, 1 Nov 2025 20:38:14 +0000 (21:38 +0100)
cachestat() and mincore() both require that the tested file is
(potentially) writable by the current user. If this permission check
fails, cachestat() will return EPERM while mincore() will simply mark
all pages as resident in core, as a proper EPERM would violate its API
contract. But when cachestat() fails with EPERM we know that mincore()
will not return real data, so instead show an error message.

Reported-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
misc-utils/fincore.c

index c297c10457331fbc66e0ce89d0e262e1eb839c1b..7ccec2a82ec92f3fbba592393b0a35c1391ba3b4 100644 (file)
@@ -370,7 +370,7 @@ static int fincore_fd (struct fincore_control *ctl,
        if (errno != ENOSYS || ctl->cachestat)
                warn(_("failed to do cachestat: %s"), st->name);
 
-       if (ctl->cachestat)
+       if (errno == EPERM || ctl->cachestat)
                return -errno;
 
        return mincore_fd(ctl, fd, st);