* [PATCH 1/2] ports/linux: Add wrapper for fstatat/fstatat64 in glibc 2.33
@ 2021-02-15 20:52 Richard Purdie
2021-02-15 20:52 ` [PATCH 2/2] makewrappers: Fix glibc 2.33 fstatat usage issues Richard Purdie
0 siblings, 1 reply; 2+ messages in thread
From: Richard Purdie @ 2021-02-15 20:52 UTC (permalink / raw)
To: openembedded-core; +Cc: seebs
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
ports/linux/guts/fstatat.c | 15 +++++++++++++++
ports/linux/guts/fstatat64.c | 15 +++++++++++++++
ports/linux/wrapfuncs.in | 2 ++
3 files changed, 32 insertions(+)
create mode 100644 ports/linux/guts/fstatat.c
create mode 100644 ports/linux/guts/fstatat64.c
diff --git a/ports/linux/guts/fstatat.c b/ports/linux/guts/fstatat.c
new file mode 100644
index 0000000..3267641
--- /dev/null
+++ b/ports/linux/guts/fstatat.c
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2021 Linux Foundation; see
+ * guts/COPYRIGHT for information.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * int fstatat(int dirfd, const char *path, struct stat *buf, int flags)
+ * int rc = -1;
+ */
+
+ rc = wrap___fxstatat(_STAT_VER, dirfd, path, buf, flags);
+
+/* return rc;
+ * }
+ */
diff --git a/ports/linux/guts/fstatat64.c b/ports/linux/guts/fstatat64.c
new file mode 100644
index 0000000..c981e14
--- /dev/null
+++ b/ports/linux/guts/fstatat64.c
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2021 Linux Foundation; see
+ * guts/COPYRIGHT for information.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * int fstatat64(int dirfd, const char *path, struct stat64 *buf, int flags)
+ * int rc = -1;
+ */
+
+ rc = wrap___fxstatat64(_STAT_VER, dirfd, path, buf, flags);
+
+/* return rc;
+ * }
+ */
diff --git a/ports/linux/wrapfuncs.in b/ports/linux/wrapfuncs.in
index 80221fc..3824fd8 100644
--- a/ports/linux/wrapfuncs.in
+++ b/ports/linux/wrapfuncs.in
@@ -23,9 +23,11 @@ int creat64(const char *path, mode_t mode);
int stat(const char *path, struct stat *buf); /* real_func=pseudo_stat */
int lstat(const char *path, struct stat *buf); /* real_func=pseudo_lstat, flags=AT_SYMLINK_NOFOLLOW */
int fstat(int fd, struct stat *buf); /* real_func=pseudo_fstat */
+int fstatat(int dirfd, const char *path, struct stat *buf, int flags);
int stat64(const char *path, struct stat64 *buf); /* real_func=pseudo_stat64 */
int lstat64(const char *path, struct stat64 *buf); /* real_func=pseudo_lstat64, flags=AT_SYMLINK_NOFOLLOW */
int fstat64(int fd, struct stat64 *buf); /* real_func=pseudo_fstat64 */
+int fstatat64(int dirfd, const char *path, struct stat64 *buf, int flags);
int __xstat64(int ver, const char *path, struct stat64 *buf);
int __lxstat64(int ver, const char *path, struct stat64 *buf); /* flags=AT_SYMLINK_NOFOLLOW */
int __fxstat64(int ver, int fd, struct stat64 *buf);
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/2] makewrappers: Fix glibc 2.33 fstatat usage issues
2021-02-15 20:52 [PATCH 1/2] ports/linux: Add wrapper for fstatat/fstatat64 in glibc 2.33 Richard Purdie
@ 2021-02-15 20:52 ` Richard Purdie
0 siblings, 0 replies; 2+ messages in thread
From: Richard Purdie @ 2021-02-15 20:52 UTC (permalink / raw)
To: openembedded-core; +Cc: seebs
In glibc 2.33 it makes calls like:
fstatat64 (pathfd, "", &st, AT_EMPTY_PATH);
where pathfd may be a symlink. This interacts badly with pseudo_root_path()
since the empty path is replaced with a pathname from the open fd but
AT_SYMLINK_NOFOLLOW is not set, hence the link is resolved and pseudo
throws an abort() due to inode mismatch.
Where the path is empty, an fd is passed and AT_EMPTY_PATH is set,
we can imply that AT_SYMLINK_NOFOLLOW is also effectly set. Adjust
the wrapper functions to ensure this, allowing the functions to behave
correctly in the AT_EMPTY_PATH case.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
makewrappers | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/makewrappers b/makewrappers
index 6681e11..818834e 100755
--- a/makewrappers
+++ b/makewrappers
@@ -372,6 +372,11 @@ class Function:
prefix = path[:-4]
if prefix not in self.specific_dirfds:
prefix = ''
+ if self.dirfd != "AT_FDCWD" and "flags" in self.flags \
+ and "AT_SYMLINK_NOFOLLOW" in self.flags:
+ fix_paths.append(
+ "if (%s && !*%s && (flags & AT_EMPTY_PATH))\n"
+ "\t\t\tflags |= AT_SYMLINK_NOFOLLOW;" % (path, path))
fix_paths.append(
"%s = pseudo_root_path(__func__, __LINE__, %s%s, %s, %s);" %
(path, prefix, self.dirfd, path, self.flags))
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-15 20:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-15 20:52 [PATCH 1/2] ports/linux: Add wrapper for fstatat/fstatat64 in glibc 2.33 Richard Purdie
2021-02-15 20:52 ` [PATCH 2/2] makewrappers: Fix glibc 2.33 fstatat usage issues Richard Purdie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox