[systemd-devel] [PATCH] add extra check for DT_UNKNOWN files in directory scan

Lennart Poettering lennart at poettering.net
Thu Mar 3 07:36:19 PST 2011


On Thu, 03.03.11 18:27, Andrey Borzenkov (arvidjaar at gmail.com) wrote:

> Some file systems (at least, reiserfs) return DT_UNKNOWN for
> every directory entry in readdir(). So far in several places
> systemd filtered on DT_REG/DT_LNK and so skipped any file on
> such filesystems. It affected systemd-update-utmp, systemd-modules-load
> and systemd-tty-ask-password-agent.
> 
> This patch adds additional stat() check for file type for DT_UNKNOWN
> case. Additionally, it adds check that DT_LNK really points to
> regular file.
> 
> The patch fixes misterious runlevel entry in utmp discussed in
> http://lists.freedesktop.org/archives/systemd-devel/2011-March/001433.html

OOps, sorry. already applied a simpler fix before I saw this patch of
yours.

I think it is acceptable to skip these checks if the underlying fs
doesn't make them cheap. Doing an explicit stat() in case of DT_UNKNOWN
buys us very little since stat() plus open() is still vulnerable to
races.

So, I think the simple fix that is in right now is already more than
enough. Especially since those dirs are actually root-only writable,
hence not super security sensitive.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list