1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-24 22:11:15 +02:00
Commit graph

20295 commits

Author SHA1 Message Date
Eelco Dolstra
448cfb71ea Merge remote-tracking branch 'cve/fod-cves-master' 2025-06-24 16:02:58 +02:00
Robert Hensing
f9afc1e68c
Merge pull request #13393 from egorkonovalov/patch-1
Fix typo: remove an extra word
2025-06-23 16:07:14 +02:00
Egor Konovalov
df21f24987
Fix link
Remove extra `realise`
2025-06-23 11:26:59 +02:00
Robert Hensing
6a74590063
Merge pull request #13388 from NaN-git/opt-string_view
libexpr: further removal of `std::string` copies
2025-06-23 09:05:28 +02:00
Eelco Dolstra
37685b1c9c Fix Darwin test failure in repl.sh
Fixes

  error:
         … while processing sandbox path '/private/tmp/nix-shell.0MDgyx/nix-test/ca/repl/store/nix/var/nix/builds/nix-build-simple.drv-65916-3910734210' (/private/tmp/nix-shell.0MDgyx/nix-test/ca/repl/store)

         error: 'nix' is too short to be a valid store path

which happened because we were now putting the build directory
underneath the store directory.
2025-06-22 16:49:44 +02:00
Eelco Dolstra
2e2fe4cb07 Cleanup 2025-06-22 16:49:44 +02:00
Eelco Dolstra
5acf50a327 Disallow the build directory having world-writable parents 2025-06-22 16:49:44 +02:00
eldritch horrors
88b7db1ba4 libstore: Don't default build-dir to temp-dir, store setting
If a build directory is accessible to other users it is possible to
smuggle data in and out of build directories. Usually this is only
a build purity problem, but in combination with other issues it can
be used to break out of a build sandbox. to prevent this we default
to using a subdirectory of nixStateDir (which is more restrictive).

(cherry picked from pennae Lix commit 55b416f6897fb0d8a9315a530a9b7f0914458ded)
(store setting done by roberth)
2025-06-22 16:49:44 +02:00
Eelco Dolstra
9af4c267c6 Chown structured attr files safely 2025-06-22 16:48:34 +02:00
Eelco Dolstra
a4b5584fb1 Replace 'bool sync' with an enum for clarity
And drop writeFileAndSync().
2025-06-22 16:48:34 +02:00
Eelco Dolstra
479c356510 Drop guessOrInventPathFromFD()
No need to do hacky stuff like that when we already know the original path.
2025-06-22 16:48:34 +02:00
Eelco Dolstra
e5dc3e84f0 Tweak comment 2025-06-22 16:48:34 +02:00
Raito Bezarius
4ea4813753 libstore: ensure that temporary directory is always 0o000 before deletion
In the case the deletion fails, we should ensure that the temporary
directory cannot be used for nefarious purposes.

Change-Id: I498a2dd0999a74195d13642f44a5de1e69d46120
Signed-off-by: Raito Bezarius <raito@lix.systems>
2025-06-22 16:48:33 +02:00
Raito Bezarius
5ec047f348 libutil: ensure that _deletePath does NOT use absolute paths with dirfds
When calling `_deletePath` with a parent file descriptor, `openat` is
made effective by using relative paths to the directory file descriptor.

To avoid the problem, the signature is changed to resist misuse with an
assert in the prologue of the function.

Change-Id: I6b3fc766bad2afe54dc27d47d1df3873e188de96
Signed-off-by: Raito Bezarius <raito@lix.systems>
2025-06-22 16:48:33 +02:00
Raito Bezarius
4e59d3fdb2 libstore: ensure that passAsFile is created in the original temp dir
This ensures that `passAsFile` data is created inside the expected
temporary build directory by `openat()` from the parent directory file
descriptor.

This avoids a TOCTOU which is part of the attack chain of CVE-????.

Change-Id: Ie5273446c4a19403088d0389ae8e3f473af8879a
Signed-off-by: Raito Bezarius <raito@lix.systems>
2025-06-22 16:48:33 +02:00
Raito Bezarius
034f59bbb9 libutil: writeFile variant for file descriptors
`writeFile` lose its `sync` boolean flag to make things simpler.

A new `writeFileAndSync` function is created and all call sites are
converted to it.

Change-Id: Ib871a5283a9c047db1e4fe48a241506e4aab9192
Signed-off-by: Raito Bezarius <raito@lix.systems>
2025-06-22 16:48:33 +02:00
Raito Bezarius
002d202653 libstore: chown to builder variant for file descriptors
We use it immediately for the build temporary directory.

Change-Id: I180193c63a2b98721f5fb8e542c4e39c099bb947
Signed-off-by: Raito Bezarius <raito@lix.systems>
2025-06-22 16:48:33 +02:00
Raito Bezarius
6a5b6ad3b7 libstore: open build directory as a dirfd as well
We now keep around a proper AutoCloseFD around the temporary directory
which we plan to use for openat operations and avoiding the build
directory being swapped out while we are doing something else.

Change-Id: I18d387b0f123ebf2d20c6405cd47ebadc5505f2a
Signed-off-by: Raito Bezarius <raito@lix.systems>
2025-06-22 16:48:33 +02:00
Raito Bezarius
7226a116a0 libutil: guess or invent a path from file descriptors
This is useful for certain error recovery paths (no pun intended) that
does not thread through the original path name.

Change-Id: I2d800740cb4f9912e64c923120d3f977c58ccb7e
Signed-off-by: Raito Bezarius <raito@lix.systems>
2025-06-22 16:48:33 +02:00
John Ericson
b9b510d692
Merge pull request #13383 from xokdvium/meson-format-multiline
Restore multiline formatting of lists in meson files
2025-06-20 18:19:03 -04:00
Sergei Zimmerman
a4dcce36c9
Merge pull request #13382 from synalice/patch-3
Update docs
2025-06-20 23:18:11 +03:00
Sergei Zimmerman
6ef683cb2a
Restore multiline formatting of lists in meson files
Applies a workaround to enforce multiline formatting
of lists to reduce code churn introduced in 93a42a5971.
2025-06-20 23:12:36 +03:00
Nikita Krasnov
785f3867fd
Update docs 2025-06-20 21:19:13 +03:00
Robert Hensing
42ea2724a8
Merge pull request #13353 from lucperkins/messages-present-tense
Rework future tense in user-facing messages
2025-06-20 10:43:03 +02:00
Luc Perkins
3132aba8e4
Fix broken test 2025-06-19 15:23:10 -07:00
Luc Perkins
9c120596ec
Merge remote-tracking branch 'upstream/master' into messages-present-tense 2025-06-19 10:51:50 -07:00
Jörg Thalheim
aa1629ca35
Merge pull request #13378 from NixOS/improve-rosetta-hint
Improve the Rosetta installation hint
2025-06-19 16:38:10 +02:00
Jörg Thalheim
a8a5537109
Merge pull request #13376 from NixOS/use-magic-nix-cache
Revert "Drop magic-nix-cache"
2025-06-19 14:10:55 +02:00
Eelco Dolstra
20ba6be749 Improve the Rosetta installation hint
The Nix daemon detects supported system types at start time, so it
needs to be restarted to detect x86_64-darwin support.
2025-06-19 13:58:51 +02:00
John Ericson
d254c840b5
Merge pull request #13349 from obsidiansystems/structured-attrs-json
Introduce top-level `structuredAttrs` field in JSON derivation format
2025-06-18 16:35:42 -04:00
Eelco Dolstra
9b57573bae Revert "Drop magic-nix-cache"
This reverts commit 9cc8be2674 since
magic-nix-cache works again (thanks @jchv).
2025-06-18 18:06:24 +02:00
Eelco Dolstra
fc47178d0d
Merge pull request #13372 from synalice/patch-1
Fix broken link
2025-06-18 17:54:04 +02:00
Eelco Dolstra
197484ce1f
Merge pull request #13373 from synalice/patch-2
Fix typo
2025-06-18 17:52:38 +02:00
Luc Perkins
d6710b4c04
Merge remote-tracking branch 'upstream/master' into messages-present-tense 2025-06-18 08:24:23 -07:00
Luc Perkins
d2a25fbe51
Fix Nix formatting changes 2025-06-18 08:23:37 -07:00
Eelco Dolstra
cd97c545d9
Merge pull request #13371 from vcunat/p/jq-1.8.0_master
tests: fixup with jq-1.8.0
2025-06-18 17:17:24 +02:00
Nikita Krasnov
86dda9884a
Fix typo 2025-06-18 12:46:53 +03:00
Nikita Krasnov
da76bc0cac
Fix broken link 2025-06-18 12:40:07 +03:00
Vladimír Čunát
77f6b6532f
tests: fixup with jq-1.8.0 2025-06-18 10:11:50 +02:00
Eelco Dolstra
bb32fcdf30
Merge pull request #13368 from wolfgangwalther/race-state-creation
libstore: fix race condition when creating state directories
2025-06-17 11:33:29 +02:00
Wolfgang Walther
d64c922164
libstore: fix race condition when creating state directories
Running parallel nix in nix can lead to multiple instances trying to
create the state directories and failing on the `createSymlink` step,
because the link already exists.

`replaceSymlink` is already idempotent, so let's use that.

Resolves #2706
2025-06-17 08:45:29 +02:00
John Ericson
cdb417854b
Merge pull request #13366 from drupol/push-smvorxlvxusx
docker: add basics OpenContainers labels
2025-06-16 18:11:53 -04:00
tomberek
af01fea5d6
Merge pull request #12623 from xokdvium/ord-safe-sort
Switch builtins.sort to a custom stable PeekSort
2025-06-16 05:11:23 -04:00
Pol Dellaiera
bb44347fac docker: expose config.Cmd as parameter 2025-06-16 08:16:39 +02:00
Pol Dellaiera
18dc96269d docker: add basics OpenContainers labels 2025-06-16 08:16:39 +02:00
Philipp Otterbein
c1aaa970c7 libexpr: further removal of std::string copies 2025-06-15 21:56:45 +02:00
Sergei Zimmerman
f9170a84f6
tests/functional/lang: Add sort stability test for lists langer than 16 elements
libstdc++'s std::stable_sort and new builtins.sort implementation
special-case ranges with length less than or equal to 16 and delegate
to insertionsort.

Having a larger e2e test would allow catching sort stability issues
at functional level as well.
2025-06-15 16:52:08 +00:00
Sergei Zimmerman
ddcfc81ff1
libexpr: Document requirements for comparator passed to builtins.sort 2025-06-15 16:52:05 +00:00
Sergei Zimmerman
351d898c43
libexpr: Switch builtins.sort primop to use peeksort
This prevents C++ level undefined behavior from affecting
the evaluator. Stdlib implementation details should not affect
eval, regardless of the build platform. Even erroneous usage
of `builtins.sort` should not make it possible to crash the
evaluator or produce results that depend on the host platform.
2025-06-15 16:52:03 +00:00
Sergei Zimmerman
b2596a7615
libutil: Add custom PeekSort implementation
Unlike std::sort and std::stable_sort, this implementation
does not lead to out-of-bounds memory reads or other undefined
behavior when the predicate is not strict weak ordering.

This makes it possible to use this function in libexpr for
builtins.sort, where an incorrectly implemented comparator
in the user nix code currently can crash and burn the evaluator
by invoking C++ UB.
2025-06-15 16:52:01 +00:00