empty /proc/cpuinfo can cause segfault

Bug #2052360 reported by dann frazier
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cmake (Ubuntu)
Fix Released
Undecided
Unassigned
Jammy
Fix Released
Undecided
dann frazier
Mantic
Fix Released
Undecided
Unassigned
Noble
Fix Released
Undecided
Unassigned

Bug Description

[Impact]
cmake-extra's copyrighttest autopkgtest segfaults on armhf in our test infra:
  https://objectstorage.prodstack5.canonical.com/swift/v1/0f9aae918d5b4744bf7b827671c86842/autopkgtest-jammy/jammy/armhf/c/cmake-extras/20240118_231525_552d3@/log.gz

This is because /proc/cpuinfo appears to be empty, which triggers an underflow condition. This doesn't impact all architectures - it may be limited to armhf containers running on arm64 hosts.

This presumably impacts the building of any software using the CopyrightTest module provided by cmake-extra in a similar environment.

[Test Case]
Launch an armhf lxd jammy container and run the autopkgtest for cmake-extras within:

ubuntu@armhf:~/cmake-extras-1.6$ ./debian/tests/copyrighttest
+ set -ep
+ mktemp --tmpdir=/tmp -d
+ builddir=/tmp/tmp.106fU16BhF
+ trap rm -rf /tmp/tmp.106fU16BhF 0 INT QUIT ABRT PIPE TERM
+ pwd
+ srcdir=/home/ubuntu/cmake-extras-1.6/examples/copyrighttest-demo
+ cd /tmp/tmp.106fU16BhF
+ cmake /home/ubuntu/cmake-extras-1.6/examples/copyrighttest-demo
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
terminate called after throwing an instance of 'std::length_error'
  what(): basic_string::_M_replace_aux
Aborted (core dumped)
+ rm -rf /tmp/tmp.106fU16BhF
ubuntu@armhf:~/cmake-extras-1.6$

[What Could Go Wrong]
The upstream fix now emits an errors message when an empty /proc/cpuinfo file is found. This error message is not expected by cmake's built-in tests, causing those tests to fail. It may impact other tests as well. Though it should only be emitted in environments where cmake would otherwise crash.

CVE References

Revision history for this message
dann frazier (dannf) wrote :
Changed in cmake (Ubuntu):
status: New → Fix Released
Changed in cmake (Ubuntu Jammy):
assignee: nobody → dann frazier (dannf)
status: New → In Progress
Changed in cmake (Ubuntu Mantic):
status: New → Fix Released
Revision history for this message
dann frazier (dannf) wrote :

This was fixed in Debian in 3.26.4-2, resolving the issue for >= mantic:

cmake (3.26.4-2) experimental; urgency=medium

  * Tolerate empty /proc/cpuinfo

 -- Timo Röhling <XXX> Sun, 28 May 2023 13:14:04 +0200

dann frazier (dannf)
description: updated
Revision history for this message
Robie Basak (racb) wrote : Please test proposed package

Hello dann, or anyone else affected,

Accepted cmake into jammy-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/cmake/3.22.1-1ubuntu1.22.04.2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-jammy to verification-done-jammy. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-jammy. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in cmake (Ubuntu Jammy):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-jammy
Revision history for this message
Ubuntu SRU Bot (ubuntu-sru-bot) wrote : Autopkgtest regression report (cmake/3.22.1-1ubuntu1.22.04.2)

All autopkgtests for the newly accepted cmake (3.22.1-1ubuntu1.22.04.2) for jammy have finished running.
The following regressions have been reported in tests triggered by the package:

benchmark/1.6.1-1 (armhf)
llvm-toolchain-12/1:12.0.1-19ubuntu3 (arm64)
pybind11/2.9.1-2 (amd64, arm64, armhf, s390x)
tbb/2020.3-1ubuntu3 (armhf)

Please visit the excuses page listed below and investigate the failures, proceeding afterwards as per the StableReleaseUpdates policy regarding autopkgtest regressions [1].

https://people.canonical.com/~ubuntu-archive/proposed-migration/jammy/update_excuses.html#cmake

[1] https://wiki.ubuntu.com/StableReleaseUpdates#Autopkgtest_Regressions

Thank you!

Revision history for this message
Gianfranco Costamagna (costamagnagianfranco) wrote :

Regressions are now fixed.

Revision history for this message
dann frazier (dannf) wrote :
tags: added: verification-done verification-done-jammy
removed: verification-needed verification-needed-jammy
Revision history for this message
dann frazier (dannf) wrote :
Download full text (5.9 KiB)

Also verified in a local lxd container, since that was the test case I described:

Package: cmake
Version: 3.22.1-1ubuntu1.22.04.2

ubuntu@cmake-extras:~/cmake-extras-1.6$ ./debian/tests/copyrighttest
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/tmp.5907bUALIK
+ status=0
+ ctest -V -R must_fail_1
UpdateCTestConfiguration from :/tmp/tmp.5907bUALIK/DartConfiguration.tcl
Parse Config file:/tmp/tmp.5907bUALIK/DartConfiguration.tcl
UpdateCTestConfiguration from :/tmp/tmp.5907bUALIK/DartConfiguration.tcl
Parse Config file:/tmp/tmp.5907bUALIK/DartConfiguration.tcl
Test project /tmp/tmp.5907bUALIK
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 1
    Start 1: must_fail_1

1: Test command: /usr/bin/gmake "must_fail_1_test"
1: Test timeout computed to be: 1500
1: [100%] Generating run_always_must_fail_1, must_fail_1.log, must_fail_1_filtered.log
1: /home/ubuntu/cmake-extras-1.6/examples/copyrighttest-demo/no_copyright.cpp: *No copyright* UNKNOWN
1: /home/ubuntu/cmake-extras-1.6/examples/copyrighttest-demo/no_copyright.h: *No copyright* UNKNOWN
1: gmake[3]: *** [CMakeFiles/must_fail_1_test.dir/build.make:73: run_always_must_fail_1] Error 1
1: gmake[2]: *** [CMakeFiles/Makefile2:842: CMakeFiles/must_fail_1_test.dir/all] Error 2
1: gmake[1]: *** [CMakeFiles/Makefile2:849: CMakeFiles/must_fail_1_test.dir/rule] Error 2
1: gmake: *** [Makefile:498: must_fail_1_test] Error 2
1/1 Test #1: must_fail_1 ......................***Failed 5.52 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) = 5.52 sec

The following tests FAILED:
   1 - must_fail_1 (Failed)
Errors while running CTest
Output from these tests are in: /tmp/tmp.5907bUALIK/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.
+ ctest -V -R must_fail_4
UpdateCTestConfiguration from :/tmp/tmp.5907bUALIK/DartConfiguration.tcl
Parse Config file:/tmp/tmp.5907bUALIK/DartConfiguration.tcl
UpdateCTestConfiguration from :/tmp/tmp.5907bUALIK/DartConfiguration.tcl
Parse Config file:/tmp/tmp.5907bUALIK/DartConfiguration.tcl
Test project /tmp/tmp.5907bUALIK
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 2
    Start 2: must_fail_4

2: Test command: /usr/bin/gmake "must_fail_4_test"
2: Test timeout computed to be: 1500
2: [100%] Generating run_always_must_fail_4, must_fail_4.log, ...

Read more...

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

The "No data in /proc/cpuinfo" text did not appear in your local lxd build, but it did appear in the log from autopkgtest.u.c. My guess is that is due to differences in how the armhf container is setup on the arm64 host in autopkgtest.u.c.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cmake - 3.22.1-1ubuntu1.22.04.2

---------------
cmake (3.22.1-1ubuntu1.22.04.2) jammy; urgency=medium

  * Cherry pick upstream fix to avoid a segfault when encountering
    an empty /proc/cpuinfo (LP: #2052360).
  * Cherry pick upstream fix for test failure caused by git setting
    protocol.file.allow=user by default to mitigate CVE-2022-39253
    (LP: #2052362).

 -- dann frazier <email address hidden> Sat, 03 Feb 2024 16:33:56 -0700

Changed in cmake (Ubuntu Jammy):
status: Fix Committed → Fix Released
Revision history for this message
Andreas Hasenack (ahasenack) wrote : Update Released

The verification of the Stable Release Update for cmake has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

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.