Discussion:
[PATCH] lsmd: Fix a possible infinity loop on plugin search.
Gris Ge
2015-05-05 14:51:35 UTC
Permalink
* On Debian 8, in plugin search path '/usr/bin', there is a symbolic linki

[***@Gris-Laptop daemon]$ ls -l /usr/bin/X11
lrwxrwxrwx 1 root root 1 May 2 22:52 /usr/bin/X11 -> .

The stat() will treat it as an folder and scan it again which create
a infinity loop scan.

* Changing stat() to lstat() could fix this as lstat() does not follow
the symbolic link which skip the scan in it.

Signed-off-by: Gris Ge <***@redhat.com>
---
daemon/lsm_daemon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/daemon/lsm_daemon.c b/daemon/lsm_daemon.c
index e21cb16..2dd3363 100644
--- a/daemon/lsm_daemon.c
+++ b/daemon/lsm_daemon.c
@@ -281,7 +281,7 @@ void process_directory( char *dir, void *p, file_op call_back)
free(full_name);
full_name = path_form(dir, entry->d_name);

- if( stat(full_name, &entry_st ) != 0 ) {
+ if( lstat(full_name, &entry_st ) != 0 ) {
continue;
}
--
2.1.4
Tony Asleson
2015-05-06 19:34:47 UTC
Permalink
Patch merged.

Thanks!

-Tony
Post by Gris Ge
* On Debian 8, in plugin search path '/usr/bin', there is a symbolic linki
lrwxrwxrwx 1 root root 1 May 2 22:52 /usr/bin/X11 -> .
The stat() will treat it as an folder and scan it again which create
a infinity loop scan.
* Changing stat() to lstat() could fix this as lstat() does not follow
the symbolic link which skip the scan in it.
---
daemon/lsm_daemon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemon/lsm_daemon.c b/daemon/lsm_daemon.c
index e21cb16..2dd3363 100644
--- a/daemon/lsm_daemon.c
+++ b/daemon/lsm_daemon.c
@@ -281,7 +281,7 @@ void process_directory( char *dir, void *p, file_op call_back)
free(full_name);
full_name = path_form(dir, entry->d_name);
- if( stat(full_name, &entry_st ) != 0 ) {
+ if( lstat(full_name, &entry_st ) != 0 ) {
continue;
}
Loading...