libuv1 calls readlink() with buffer size zero for /proc/self (nodejs test-case failure on s390x and LXD)

Bug #1792647 reported by Mauricio Faria de Oliveira
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libuv1 (Ubuntu)
Fix Released
Undecided
Mauricio Faria de Oliveira

Bug Description

The Debian patch 'path_max' causes failures when
readlink'ing symlinks that involve /proc/self
(and potentially other symlinks in /proc)
which report st_size == 0.

It uses st_size as a buffer size for readlink(),
which then fails with EINVAL.

This breaks the nodejs test-case test-fs-realpath-pipe.js
on s390x and LXD containers (which symlink /dev/stdin
to /proc/self/fd/0 vs. fd/0 as in amd64 non-container):

    $ strace -E LD_LIBRARY_PATH=/usr/local/lib/ -f -e lstat,readlink \
      node test/parallel/test-fs-realpath-pipe.js

    [pid 17785] lstat("/dev", {st_mode=S_IFDIR|0755, st_size=480, ...}) = 0
    [pid 17786] lstat("/dev/stdin", {st_mode=S_IFLNK|0777, st_size=15, ...}) = 0
    [pid 17788] lstat("/dev/stdin", {st_mode=S_IFLNK|0777, st_size=15, ...}) = 0
    [pid 17788] readlink("/dev/stdin", "/proc/self/fd/0", 15) = 15

    [pid 17785] lstat("/proc", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
    [pid 17786] lstat("/proc/self", {st_mode=S_IFLNK|0777, st_size=0, ...}) = 0
    [pid 17788] lstat("/proc/self", {st_mode=S_IFLNK|0777, st_size=0, ...}) = 0
    [pid 17788] readlink("/proc/self", 0x7f2a6c000b40, 0) = -1 EINVAL (Invalid argument)

I'll submit a patch shortly.

Tags: patch
Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote :

This has been verified on a PPA to resolve the nodejs test-case failure on s390x.

Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote :

This also fixes the problem in LXD on amd64:

Before:

$ node test/parallel/test-fs-realpath-pipe.js
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 1 === 2
    at Object.<anonymous> (/home/ubuntu/nodejs-8.11.2~dfsg/test/parallel/test-fs-realpath-pipe.js:44:10)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3

After:

$ wget https://launchpad.net/~mfo/+archive/ubuntu/sf189591-s390x-2/+files/libuv1_1.22.0-3ubuntu1_amd64.deb
$ sudo dpkg -i libuv1_1.22.0-3ubuntu1_amd64.deb

$ node test/parallel/test-fs-realpath-pipe.js
$

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "libuv1-path_max_zero_st_size.debdiff" seems to be a debdiff. The ubuntu-sponsors team has been subscribed to the bug report so that they can review and hopefully sponsor the debdiff. If the attachment isn't a patch, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are member of the ~ubuntu-sponsors, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issue please contact him.]

tags: added: patch
summary: - fix nodejs test-case failure on s390x and LXD
+ libuv1 calls readlink() with buffer size zero for /proc/self (nodejs
+ test-case failure on s390x and LXD)
Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote :

This is the same debdiff for Cosmic, now updated with Bug-Ubuntu and Bug-Debian tags (BTS 909011).

Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote :

This is applied in cosmic-proposed, version 1.22.0-3ubuntu1. Thanks!

Changed in libuv1 (Ubuntu):
status: New → Fix Committed
assignee: nobody → Mauricio Faria de Oliveira (mfo)
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package libuv1 - 1.22.0-3ubuntu1

---------------
libuv1 (1.22.0-3ubuntu1) cosmic; urgency=medium

  * debian/patches/path_max_zero_st_size: fix buffer size of zero
    for readlink() (EINVAL) when lstat() reports st_size == 0.
    This fixes nodejs test-case parallel/test-fs-realpath-pipe.js
    on s390x and in LXD on amd64. (LP: #1792647)

 -- Mauricio Faria de Oliveira <email address hidden> Fri, 14 Sep 2018 19:27:12 -0300

Changed in libuv1 (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.