pseudo: Fix race problems

There is a potential issue with the fastop code in pseudo since a process may
exit and allow some other function to run before the server has processed
the commands run by the process. Issues have been see with unpredictable
file permissions.

To avoid this, we ping the server before exitting which guarantees it has
processed the current command queue.

The patch was written by peter.seebach@windriver.com

[YOCTO #5132]

(From OE-Core rev: a8a1f12c51ffdca011db194894fd7d14c119fb09)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2013-09-26 17:01:29 +00:00
parent b43c8126de
commit a1d9b6df86
2 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,53 @@
There is a potential issue with the fastop code in pseudo since a process may
exit and allow some other function to run before the server has processed
the commands run by the process. Issues have been see with unpredictable
file permissions.
To avoid this, we ping the server before exitting which guarantees it has
processed the current command queue.
Debugged-by: RP
Fix written by peter.seebach@windriver.com
Upstream-Status: Submitted
[YOCTO #5132]
diff --git a/pseudo_client.c b/pseudo_client.c
index f58ce4c..20943b6 100644
--- a/pseudo_client.c
+++ b/pseudo_client.c
@@ -75,6 +75,9 @@ static int nfds = 0;
static int messages = 0;
static struct timeval message_time = { .tv_sec = 0 };
static int pseudo_inited = 0;
+
+static int sent_messages = 0;
+
int pseudo_nosymlinkexp = 0;
/* note: these are int, not uid_t/gid_t, so I can use 'em with scanf */
@@ -711,6 +714,11 @@ client_ping(void) {
return 0;
}
+static void
+void_client_ping(void) {
+ client_ping();
+}
+
int
pseudo_fd(int fd, int how) {
int newfd;
@@ -1043,6 +1051,11 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path
/* disable wrappers */
pseudo_antimagic();
+ if (!sent_messages) {
+ sent_messages = 1;
+ atexit(void_client_ping);
+ }
+
if (op == OP_RENAME) {
va_list ap;
va_start(ap, buf);

View File

@ -5,6 +5,7 @@ PR = "r4"
SRC_URI = " \
http://www.yoctoproject.org/downloads/${BPN}/${BPN}-${PV}.tar.bz2 \
file://0001-pseudo_has_unload-add-function.patch \
file://shutdownping.patch \
"
SRC_URI[md5sum] = "5ec67c7bff5fe68c56de500859c19172"