diff mbox series

unfs3: Fix race issue causing a glibc test hang

Message ID 20260113232618.2701009-1-richard.purdie@linuxfoundation.org
State Accepted, archived
Commit e51d5e19cb1ba1d5ad7442064b64821d178bc9ca
Headers show
Series unfs3: Fix race issue causing a glibc test hang | expand

Commit Message

Richard Purdie Jan. 13, 2026, 11:26 p.m. UTC
When running glibc tests under user mode NFS, tst-syslog was causing a hang. The
hang was traced to unfsd exitting with a buffer overflow being detected.

This was traced down to mksocket() where we'd see:

socket path '/media/build/poky/build/build-st-2118464/tmp/work/x86-64-v3-poky-linux/glibc-testsuite/2.42+git/build-x86_64-poky-linux/testroot.root/dev/log' is too long at 141 vs 108

There is a length check in mknod_args() but obj may not be setup at this point by
cat_name() since the functions can be executed out of order according to C.

To avoid this, make the order explict. This means the length is checked and we
avoid the buffer overflow. This will likely cause the glibc test to fail however
it won't hang, which is a win.

[YOCTO #16113]

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 .../unfs3/unfs3/fixrace.patch                 | 35 +++++++++++++++++++
 meta/recipes-devtools/unfs3/unfs3_0.11.0.bb   |  3 +-
 2 files changed, 37 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-devtools/unfs3/unfs3/fixrace.patch
diff mbox series

Patch

diff --git a/meta/recipes-devtools/unfs3/unfs3/fixrace.patch b/meta/recipes-devtools/unfs3/unfs3/fixrace.patch
new file mode 100644
index 00000000000..b41ec4b3d27
--- /dev/null
+++ b/meta/recipes-devtools/unfs3/unfs3/fixrace.patch
@@ -0,0 +1,35 @@ 
+When running glibc tests under user mode NFS, tst-syslog was causing a hang. The
+hang was traced to unfsd exitting with a buffer overflow being detected.
+
+This was traced down to mksocket() where we'd see:
+
+socket path '/media/build/poky/build/build-st-2118464/tmp/work/x86-64-v3-poky-linux/glibc-testsuite/2.42+git/build-x86_64-poky-linux/testroot.root/dev/log' is too long at 141 vs 108
+
+There is a length check in mknod_args() but obj may not be setup at this point by
+cat_name() since the functions can be executed out of order according to C.
+
+To avoid this, make the order explict. This means the length is checked and we
+avoid the buffer overflow. This will likely cause the glibc test to fail however
+it won't hang, which is a win.
+
+Upstream-Status: Pending
+
+Index: unfs3-0.11.0/nfs.c
+===================================================================
+--- unfs3-0.11.0.orig/nfs.c
++++ unfs3-0.11.0/nfs.c
+@@ -776,9 +776,11 @@ MKNOD3res *nfsproc3_mknod_3_svc(MKNOD3ar
+ 
+     PREP(path, argp->where.dir);
+     pre = get_pre_cached();
+-    result.status =
+-        join3(cat_name(path, argp->where.name, obj),
+-              mknod_args(argp->what, obj, &new_mode, &dev), exports_rw());
++    result.status = cat_name(path, argp->where.name, obj);
++    if (result.status == NFS3_OK)
++        result.status = mknod_args(argp->what, obj, &new_mode, &dev);
++    if (result.status == NFS3_OK)
++        result.status = exports_rw();
+ 
+     cluster_create(obj, rqstp, &result.status);
+ 
diff --git a/meta/recipes-devtools/unfs3/unfs3_0.11.0.bb b/meta/recipes-devtools/unfs3/unfs3_0.11.0.bb
index b8c235fb7cd..793f5c83ce5 100644
--- a/meta/recipes-devtools/unfs3/unfs3_0.11.0.bb
+++ b/meta/recipes-devtools/unfs3/unfs3_0.11.0.bb
@@ -9,7 +9,8 @@  LIC_FILES_CHKSUM = "file://LICENSE;md5=c1c621cd2786a3a1344a60a0d608c910"
 
 DEPENDS = "bison-native flex-native libtirpc"
 
-SRC_URI = "git://github.com/unfs3/unfs3.git;protocol=https;branch=master;tag=${BP}"
+SRC_URI = "git://github.com/unfs3/unfs3.git;protocol=https;branch=master;tag=${BP} \
+           file://fixrace.patch"
 SRCREV = "ec1660ba33c80d5c67131e163e68834c1a10e243"
 UPSTREAM_CHECK_GITTAGREGEX = "unfs3\-(?P<pver>\d+(\.\d+)+)"