* [PATCH][pseudo 1/7] pseudo_util: don't overrun strings when looking for keys
@ 2021-01-08 14:06 Ross Burton
2021-01-08 14:06 ` [PATCH][pseudo 2/7] Silence switch block warnings Ross Burton
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Ross Burton @ 2021-01-08 14:06 UTC (permalink / raw)
To: openembedded-core
Use strcmp() insead of memcmp() when searching for keys as otherwise
the comparison will run off the end of the NULL-terminated string.
Signed-off-by: Ross Burton <ross.burton@arm.com>
---
pseudo_util.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pseudo_util.c b/pseudo_util.c
index 1d06009..51c07c2 100644
--- a/pseudo_util.c
+++ b/pseudo_util.c
@@ -159,7 +159,7 @@ pseudo_get_value(const char *key) {
if (pseudo_util_initted == -1)
pseudo_init_util();
- for (i = 0; pseudo_env[i].key && memcmp(pseudo_env[i].key, key, pseudo_env[i].key_len + 1); i++)
+ for (i = 0; pseudo_env[i].key && strcmp(pseudo_env[i].key, key); i++)
;
/* Check if the environment has it and we don't ...
@@ -188,7 +188,7 @@ pseudo_set_value(const char *key, const char *value) {
if (pseudo_util_initted == -1)
pseudo_init_util();
- for (i = 0; pseudo_env[i].key && memcmp(pseudo_env[i].key, key, pseudo_env[i].key_len + 1); i++)
+ for (i = 0; pseudo_env[i].key && strcmp(pseudo_env[i].key, key); i++)
;
if (pseudo_env[i].key) {
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH][pseudo 2/7] Silence switch block warnings 2021-01-08 14:06 [PATCH][pseudo 1/7] pseudo_util: don't overrun strings when looking for keys Ross Burton @ 2021-01-08 14:06 ` Ross Burton 2021-01-08 14:06 ` [PATCH][pseudo 3/7] Disable deprecated function warnings Ross Burton ` (4 subsequent siblings) 5 siblings, 0 replies; 8+ messages in thread From: Ross Burton @ 2021-01-08 14:06 UTC (permalink / raw) To: openembedded-core Slightly alter a fallthrough comment so that GCC recognises it, and add a default: case to a switch which explicitly only handles a few values. Signed-off-by: Ross Burton <ross.burton@arm.com> --- pseudo.c | 2 ++ pseudo_client.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pseudo.c b/pseudo.c index ff8e1b9..55f0f18 100644 --- a/pseudo.c +++ b/pseudo.c @@ -1036,6 +1036,8 @@ pseudo_op(pseudo_msg_t *msg, const char *program, const char *tag, char **respon pdb_may_unlink_file(msg, msg->client); } break; + default: + break; } op_exit: diff --git a/pseudo_client.c b/pseudo_client.c index 3c49644..eeb1fdc 100644 --- a/pseudo_client.c +++ b/pseudo_client.c @@ -1860,7 +1860,8 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path break; case OP_OPEN: pseudo_client_path(fd, path); - case OP_EXEC: /* fallthrough */ + /* fallthrough */ + case OP_EXEC: do_request = pseudo_client_logging; break; case OP_CLOSE: -- 2.25.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH][pseudo 3/7] Disable deprecated function warnings 2021-01-08 14:06 [PATCH][pseudo 1/7] pseudo_util: don't overrun strings when looking for keys Ross Burton 2021-01-08 14:06 ` [PATCH][pseudo 2/7] Silence switch block warnings Ross Burton @ 2021-01-08 14:06 ` Ross Burton 2021-01-08 14:06 ` [PATCH][pseudo 4/7] Fix some memory leaks Ross Burton ` (3 subsequent siblings) 5 siblings, 0 replies; 8+ messages in thread From: Ross Burton @ 2021-01-08 14:06 UTC (permalink / raw) To: openembedded-core Pseudo has to call deprecated functions because it is wrapping them, so disable deprecation warnings. Signed-off-by: Ross Burton <ross.burton@arm.com> --- Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index b43d2d6..d1f77d5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -42,7 +42,7 @@ LOCALSTATE=var/pseudo BINDIR=$(PREFIX)/$(BIN) LOCALSTATEDIR=$(PREFIX)/$(LOCALSTATE) -CFLAGS_BASE=-pipe -std=gnu99 -Wall -W -Wextra +CFLAGS_BASE=-pipe -std=gnu99 -Wall -W -Wextra -Wno-deprecated-declarations CFLAGS_CODE=-fPIC -D_LARGEFILE64_SOURCE -D_ATFILE_SOURCE $(ARCH_FLAGS) CFLAGS_DEFS=-DPSEUDO_PREFIX='"$(PREFIX)"' -DPSEUDO_SUFFIX='"$(SUFFIX)"' -DPSEUDO_BINDIR='"$(BIN)"' -DPSEUDO_LIBDIR='"$(LIB)"' -DPSEUDO_LOCALSTATEDIR='"$(LOCALSTATE)"' -DPSEUDO_VERSION='"$(VERSION)"' $(SQLITE_MEMORY) $(FORCE_ASYNC) -DPSEUDO_PASSWD_FALLBACK='$(PASSWD_FALLBACK)' $(OPTDEFS) $(EPOLL) CFLAGS_DEBUG=-O2 -g -- 2.25.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH][pseudo 4/7] Fix some memory leaks 2021-01-08 14:06 [PATCH][pseudo 1/7] pseudo_util: don't overrun strings when looking for keys Ross Burton 2021-01-08 14:06 ` [PATCH][pseudo 2/7] Silence switch block warnings Ross Burton 2021-01-08 14:06 ` [PATCH][pseudo 3/7] Disable deprecated function warnings Ross Burton @ 2021-01-08 14:06 ` Ross Burton 2021-01-08 16:01 ` [OE-core] " Seebs 2021-01-08 14:06 ` [PATCH][pseudo 5/7] makewrappers: fix Python 2 hangover Ross Burton ` (2 subsequent siblings) 5 siblings, 1 reply; 8+ messages in thread From: Ross Burton @ 2021-01-08 14:06 UTC (permalink / raw) To: openembedded-core pseudo_get_value() returns newly allocated memory that the caller must free, so add some free() calls. Signed-off-by: Ross Burton <ross.burton@arm.com> --- pseudo.c | 4 +++- pseudo_client.c | 9 +++++++++ pseudo_util.c | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pseudo.c b/pseudo.c index 55f0f18..f2e2f87 100644 --- a/pseudo.c +++ b/pseudo.c @@ -245,10 +245,12 @@ main(int argc, char *argv[]) { /* Options are processed, preserve them... */ pseudo_set_value("PSEUDO_OPTS", opts); - if (!pseudo_get_prefix(argv[0])) { + s = pseudo_get_prefix(argv[0]); + if (!s) { pseudo_diag("Can't figure out prefix. Set PSEUDO_PREFIX or invoke with full path.\n"); exit(PSEUDO_EXIT_PSEUDO_PREFIX); } + free(s); /* move database */ if (opt_m || opt_M) { diff --git a/pseudo_client.c b/pseudo_client.c index eeb1fdc..6310b99 100644 --- a/pseudo_client.c +++ b/pseudo_client.c @@ -431,6 +431,7 @@ pseudo_profile_report(void) { void pseudo_init_client(void) { char *env; + int need_free = 0; pseudo_antimagic(); pseudo_new_pid(); @@ -450,9 +451,11 @@ pseudo_init_client(void) { * or it may have gone away, in which case we'd enable * pseudo (and cause it to reinit the defaults). */ + need_free = 0; env = getenv("PSEUDO_DISABLED"); if (!env) { env = pseudo_get_value("PSEUDO_DISABLED"); + need_free = 1; } if (env) { int actually_disabled = 1; @@ -487,15 +490,19 @@ pseudo_init_client(void) { } else { pseudo_set_value("PSEUDO_DISABLED", "0"); } + if (need_free) + free(env); /* ALLOW_FSYNC is here because some crazy hosts will otherwise * report incorrect values for st_size/st_blocks. I can sort of * understand st_blocks, but bogus values for st_size? Not cool, * dudes, not cool. */ + need_free = 0; env = getenv("PSEUDO_ALLOW_FSYNC"); if (!env) { env = pseudo_get_value("PSEUDO_ALLOW_FSYNC"); + need_free = 1; } else { pseudo_set_value("PSEUDO_ALLOW_FSYNC", env); } @@ -504,6 +511,8 @@ pseudo_init_client(void) { } else { pseudo_allow_fsync = 0; } + if (need_free) + free(env); /* in child processes, PSEUDO_UNLOAD may become set to * some truthy value, in which case we're being asked to diff --git a/pseudo_util.c b/pseudo_util.c index 51c07c2..b6980c2 100644 --- a/pseudo_util.c +++ b/pseudo_util.c @@ -967,6 +967,7 @@ pseudo_setupenv() { } snprintf(newenv, len, "%s:%s64", libdir_path, libdir_path); SETENV(PRELINK_PATH, newenv, 1); + free(newenv); } else if (!strstr(ld_library_path, libdir_path)) { size_t len = strlen(ld_library_path) + 1 + strlen(libdir_path) + 1 + (strlen(libdir_path) + 2) + 1; char *newenv = malloc(len); @@ -975,6 +976,7 @@ pseudo_setupenv() { } snprintf(newenv, len, "%s:%s:%s64", ld_library_path, libdir_path, libdir_path); SETENV(PRELINK_PATH, newenv, 1); + free(newenv); } else { /* nothing to do, ld_library_path exists and contains * our preferred path */ -- 2.25.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [OE-core] [PATCH][pseudo 4/7] Fix some memory leaks 2021-01-08 14:06 ` [PATCH][pseudo 4/7] Fix some memory leaks Ross Burton @ 2021-01-08 16:01 ` Seebs 0 siblings, 0 replies; 8+ messages in thread From: Seebs @ 2021-01-08 16:01 UTC (permalink / raw) To: Ross Burton; +Cc: openembedded-core For reference, I believe the rationale on these originally was "none of these functions happen repeatedly, in general, and the extra complexity and potential to get the logic wrong isn't appealing", but I don't think I object to these. -s ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH][pseudo 5/7] makewrappers: fix Python 2 hangover 2021-01-08 14:06 [PATCH][pseudo 1/7] pseudo_util: don't overrun strings when looking for keys Ross Burton ` (2 preceding siblings ...) 2021-01-08 14:06 ` [PATCH][pseudo 4/7] Fix some memory leaks Ross Burton @ 2021-01-08 14:06 ` Ross Burton 2021-01-08 14:06 ` [PATCH][pseudo 6/7] makewrappers: support architecture-overrides in wrapper modifiers Ross Burton 2021-01-08 14:06 ` [PATCH][pseudo 7/7] ports/linux/xattr: add arm64 versions for xattr calls Ross Burton 5 siblings, 0 replies; 8+ messages in thread From: Ross Burton @ 2021-01-08 14:06 UTC (permalink / raw) To: openembedded-core An except statement was still using Python 2 syntax so caused SyntaxErrors if the exception was raised. Signed-off-by: Ross Burton <ross.burton@arm.com> --- makewrappers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makewrappers b/makewrappers index 232c08d..e68f6a9 100755 --- a/makewrappers +++ b/makewrappers @@ -593,7 +593,7 @@ def process_wrapfuncs(port): func.directory = directory funcs[func.name] = func sys.stdout.write(".") - except Exception(e): + except Exception as e: print("Parsing failed:", e) exit(1) funclist.close() -- 2.25.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH][pseudo 6/7] makewrappers: support architecture-overrides in wrapper modifiers 2021-01-08 14:06 [PATCH][pseudo 1/7] pseudo_util: don't overrun strings when looking for keys Ross Burton ` (3 preceding siblings ...) 2021-01-08 14:06 ` [PATCH][pseudo 5/7] makewrappers: fix Python 2 hangover Ross Burton @ 2021-01-08 14:06 ` Ross Burton 2021-01-08 14:06 ` [PATCH][pseudo 7/7] ports/linux/xattr: add arm64 versions for xattr calls Ross Burton 5 siblings, 0 replies; 8+ messages in thread From: Ross Burton @ 2021-01-08 14:06 UTC (permalink / raw) To: openembedded-core Pseudo allows wrappers to define special comments in the wrapper lists to pass extra arguments such as version=GLIBC_2.3 to control which symbol version to search for. However, these arguments can be architecture-specific. When parsing the arguments, check for flags that end in the architecture name (as returned by platform.machine()) and use those values instead. Signed-off-by: Ross Burton <ross.burton@arm.com> --- makewrappers | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/makewrappers b/makewrappers index e68f6a9..6681e11 100755 --- a/makewrappers +++ b/makewrappers @@ -11,6 +11,7 @@ import glob import sys import re import os.path +import platform import string import subprocess from templatefile import TemplateFile @@ -290,10 +291,18 @@ class Function: # handle special comments, such as flags=AT_SYMLINK_NOFOLLOW if self.comments: - modifiers = self.comments.split(', ') - for mod in modifiers: - key, value = mod.split('=') - value = value.rstrip() + # Build a dictionary of key=value, key=value pairs + modifiers = dict(mod.split("=") for mod in self.comments.split(',')) + # Strip all leading/trailing whitespace + modifiers = {k.strip():v.strip() for k, v in modifiers.items()} + + arch = "-" + platform.machine() + # Sorted so that versions-foo appear after versions, so overrides are easy + for key in sorted(modifiers): + value = modifiers[key] + # If the key is version-arm64 and we're on arm64 then rename this to version + if key.endswith(arch): + key = key.replace(arch, "") setattr(self, key, value) def maybe_inode64(self): -- 2.25.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH][pseudo 7/7] ports/linux/xattr: add arm64 versions for xattr calls 2021-01-08 14:06 [PATCH][pseudo 1/7] pseudo_util: don't overrun strings when looking for keys Ross Burton ` (4 preceding siblings ...) 2021-01-08 14:06 ` [PATCH][pseudo 6/7] makewrappers: support architecture-overrides in wrapper modifiers Ross Burton @ 2021-01-08 14:06 ` Ross Burton 5 siblings, 0 replies; 8+ messages in thread From: Ross Burton @ 2021-01-08 14:06 UTC (permalink / raw) To: openembedded-core The xattr functions need to use a specific version of the symbols to avoid calling into libattr.so, which on Tumbleweed causes failures[1]. However on arm64 systems the glibc version is different. This means that searching for llistattr(GLIBC_2.3) fails to initially match the symbol in libc.so, and instead if libattr.so is linked then the symbol in that library is used. This is simply a wrapper that is intended to call the symbol in libc.so but instead calls the symbol in pseudo, so infinite loops. Using the just-added architecture overrides, add the right versions for arm64 systems so the correct symbols in libc.so are found. [ YOCTO #14133 ] [1] b94fa2fc81cde25865ee223ca437d07377229a53 Signed-off-by: Ross Burton <ross.burton@arm.com> --- ports/linux/xattr/wrapfuncs.in | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ports/linux/xattr/wrapfuncs.in b/ports/linux/xattr/wrapfuncs.in index b8e007d..09eba23 100644 --- a/ports/linux/xattr/wrapfuncs.in +++ b/ports/linux/xattr/wrapfuncs.in @@ -1,12 +1,12 @@ -ssize_t getxattr(const char *path, const char *name, void *value, size_t size); /* flags=0, version="GLIBC_2.3" */ -ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size); /* flags=AT_SYMLINK_NOFOLLOW, version="GLIBC_2.3" */ -ssize_t fgetxattr(int filedes, const char *name, void *value, size_t size); /* version="GLIBC_2.3" */ -int setxattr(const char *path, const char *name, const void *value, size_t size, int xflags); /* flags=0, version="GLIBC_2.3" */ -int lsetxattr(const char *path, const char *name, const void *value, size_t size, int xflags); /* flags=AT_SYMLINK_NOFOLLOW, version="GLIBC_2.3" */ -int fsetxattr(int filedes, const char *name, const void *value, size_t size, int xflags); /* version="GLIBC_2.3" */ -ssize_t listxattr(const char *path, char *list, size_t size); /* flags=0, version="GLIBC_2.3" */ -ssize_t llistxattr(const char *path, char *list, size_t size); /* flags=AT_SYMLINK_NOFOLLOW, version="GLIBC_2.3" */ -ssize_t flistxattr(int filedes, char *list, size_t size); /* version="GLIBC_2.3" */ -int removexattr(const char *path, const char *name); /* flags=0, version="GLIBC_2.3" */ -int lremovexattr(const char *path, const char *name); /* flags=AT_SYMLINK_NOFOLLOW, version="GLIBC_2.3" */ -int fremovexattr(int filedes, const char *name); /* version="GLIBC_2.3" */ +ssize_t getxattr(const char *path, const char *name, void *value, size_t size); /* flags=0, version="GLIBC_2.3", version-aarch64="GLIBC_2.17" */ +ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size); /* flags=AT_SYMLINK_NOFOLLOW, version="GLIBC_2.3", version-aarch64="GLIBC_2.17" */ +ssize_t fgetxattr(int filedes, const char *name, void *value, size_t size); /* version="GLIBC_2.3", version-aarch64="GLIBC_2.17" */ +int setxattr(const char *path, const char *name, const void *value, size_t size, int xflags); /* flags=0, version="GLIBC_2.3", version-aarch64="GLIBC_2.17" */ +int lsetxattr(const char *path, const char *name, const void *value, size_t size, int xflags); /* flags=AT_SYMLINK_NOFOLLOW, version="GLIBC_2.3", version-aarch64="GLIBC_2.17" */ +int fsetxattr(int filedes, const char *name, const void *value, size_t size, int xflags); /* version="GLIBC_2.3", version-aarch64="GLIBC_2.17" */ +ssize_t listxattr(const char *path, char *list, size_t size); /* flags=0, version="GLIBC_2.3", version-aarch64="GLIBC_2.17" */ +ssize_t llistxattr(const char *path, char *list, size_t size); /* flags=AT_SYMLINK_NOFOLLOW, version="GLIBC_2.3", version-aarch64="GLIBC_2.17" */ +ssize_t flistxattr(int filedes, char *list, size_t size); /* version="GLIBC_2.3", version-aarch64="GLIBC_2.17" */ +int removexattr(const char *path, const char *name); /* flags=0, version="GLIBC_2.3", version-aarch64="GLIBC_2.17" */ +int lremovexattr(const char *path, const char *name); /* flags=AT_SYMLINK_NOFOLLOW, version="GLIBC_2.3", version-aarch64="GLIBC_2.17" */ +int fremovexattr(int filedes, const char *name); /* version="GLIBC_2.3", version-aarch64="GLIBC_2.17" */ -- 2.25.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-01-08 16:01 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-01-08 14:06 [PATCH][pseudo 1/7] pseudo_util: don't overrun strings when looking for keys Ross Burton 2021-01-08 14:06 ` [PATCH][pseudo 2/7] Silence switch block warnings Ross Burton 2021-01-08 14:06 ` [PATCH][pseudo 3/7] Disable deprecated function warnings Ross Burton 2021-01-08 14:06 ` [PATCH][pseudo 4/7] Fix some memory leaks Ross Burton 2021-01-08 16:01 ` [OE-core] " Seebs 2021-01-08 14:06 ` [PATCH][pseudo 5/7] makewrappers: fix Python 2 hangover Ross Burton 2021-01-08 14:06 ` [PATCH][pseudo 6/7] makewrappers: support architecture-overrides in wrapper modifiers Ross Burton 2021-01-08 14:06 ` [PATCH][pseudo 7/7] ports/linux/xattr: add arm64 versions for xattr calls Ross Burton
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox