From: Matt Cowell <matt.cow...@nokia.com> Some symlinks in /proc, such as those under /proc/[pid]/fd, /proc/[pid]/cwd, and /proc/[pid]/exe that are not real and should not have readlink called on them. These look like symlinks, but behave like hardlinks. Readlink does not return actual paths. Previously pseudo_fix_path would expand files such as /dev/stdin to paths such as /proc/6680/fd/pipe:[1270830076] which do not exist.
This issue affects: - deleted files - deleted directories - fifos - sockets - anon_inodes (epoll, eventfd, inotify, signalfd, timerfd, etc) Testing: - run_tests: all tests passed (3 tests check the new code path). Checked test output to make sure the new codepath gets executed. - perftest: measured time before and after applying the patch had insignificant differences (roughly ~1%) - world build: completed without warning/errors Signed-off-by: Sakib Sajal <sakib.sa...@windriver.com> --- pseudo_util.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pseudo_util.c b/pseudo_util.c index b6980c2..b9de81e 100644 --- a/pseudo_util.c +++ b/pseudo_util.c @@ -29,6 +29,11 @@ #include "pseudo_ipc.h" #include "pseudo_db.h" +/* O_PATH is defined in glibc 2.16 and later only */ +#ifndef O_PATH +#define O_PATH 010000000 +#endif + struct pseudo_variables { char *key; size_t key_len; @@ -678,6 +683,18 @@ pseudo_append_element(char *newpath, char *root, size_t allocated, char **pcurre */ if (!leave_this && is_dir) { int is_link = S_ISLNK(buf->st_mode); + + /* do not expand symlinks in the proc filesystem, since they may not be real + * check if newpath starts with "/proc/" + * strlen of "/proc/" = 6 + */ + if (is_link && (strncmp("/proc/", newpath, 6) == 0)) { + pseudo_debug(PDBGF_PATH | PDBGF_VERBOSE, + "pae: '%s' is procfs symlink, not expanding\n", + newpath); + is_link = 0; + } + if (link_recursion >= PSEUDO_MAX_LINK_RECURSION && is_link) { pseudo_diag("link recursion too deep, not expanding path '%s'.\n", newpath); is_link = 0; -- 2.25.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#158154): https://lists.openembedded.org/g/openembedded-core/message/158154 Mute This Topic: https://lists.openembedded.org/mt/86978294/21656 Group Owner: openembedded-core+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-