Repository navigation
EnvironmentTest crashes when /proc is unavailable #45901
Copy link
Copy link
Closed
Description
Version
16.15.0, but able to produce with Git head as well
Platform
Linux ember.foxkit.us 5.15.44-mc2-easy #1 SMP Wed Aug 17 20:37:04 UTC 2022 i686 GNU/Linux
Subsystem
env
What steps will reproduce the bug?
- Ensure
/proc/self/exedoes not exist. - Run
cctest/make test-onlyon a Linux host.
How often does it reproduce? Is there a required condition?
Always reproducible when /proc is not mounted (i.e. in a container) or when /proc/self/exe does not exist.
What is the expected behavior?
Test passing.
What do you see instead?
Core was generated by `out/Release/cctest --gtest_filter=*'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0xf7524644 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /usr/lib/libstdc++.so.6
[Current thread is 1 (LWP 4574)]
(gdb) bt
#0 0xf7524644 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /usr/lib/libstdc++.so.6
#1 0x56da0c64 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::assign (__str=...,
this=0xf2d7d424) at /usr/include/c++/8.5.0/bits/basic_string.h:1370
#2 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator= (__str=..., this=0xf2d7d424)
at /usr/include/c++/8.5.0/bits/basic_string.h:699
#3 node::GetExecPath (argv=...) at ../../src/env.cc:313
#4 0x56dab741 in node::Environment::Environment (this=<optimized out>, isolate_data=<optimized out>, isolate=<optimized out>,
args=..., exec_args=..., env_info=<optimized out>, flags=<optimized out>, thread_id=...) at ../../src/env.cc:359
#5 0x56dad8ac in node::Environment::Environment (this=0xf2d7d020, isolate_data=0xf569e9c0, context=..., args=...,
exec_args=..., env_info=0x0, flags=node::EnvironmentFlags::kDefaultFlags, thread_id=...) at ../../src/env.cc:436
#6 0x56d5e2da in node::CreateEnvironment (isolate_data=isolate_data@entry=0xf569e9c0, context=context@entry=..., args=...,
exec_args=..., flags=node::EnvironmentFlags::kDefaultFlags, thread_id=..., inspector_parent_handle=...)
at ../../src/api/environment.cc:345
#7 0x56d101b9 in EnvironmentTest_NestedMicrotaskQueue_Test::TestBody (this=0xf2e8a370)
at ../../test/cctest/test_environment.cc:677
This is because argv is accessed in node::GetExecPath without checking the length first.
Additional information
I'm not sure if Node tests are meant to pass without /proc mounted on Linux systems, but it seems good to avoid a nullptr dereference when possible.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
cjihrig commentedon Dec 18, 2022
We should fix this if possible. Would you like to send a patch?
src: check size of args before using for exec_path
src: check size of args before using for exec_path
src: check size of args before using for exec_path
src: check size of args before using for exec_path
src: check size of args before using for exec_path
src: check size of args before using for exec_path