forked from lix-project/lix
jade
917c9bdee7
This also bans various sneaking of negative numbers from the language
into unsuspecting builtins as was exposed while auditing the
consequences of changing the Nix language integer type to a newtype.
It's unlikely that this change comprehensively ensures correctness when
passing integers out of the Nix language and we should probably add a
checked-narrowing function or something similar, but that's out of scope
for the immediate change.
During the development of this I found a few fun facts about the
language:
- You could overflow integers by converting from unsigned JSON values.
- You could overflow unsigned integers by converting negative numbers
into them when going into Nix config, into fetchTree, and into flake
inputs.
The flake inputs and Nix config cannot actually be tested properly
since they both ban thunks, however, we put in checks anyway because
it's possible these could somehow be used to do such shenanigans some
other way.
Note that Lix has banned Nix language integer overflows since the very
first public beta, but threw a SIGILL about them because we run with
-fsanitize=signed-overflow -fsanitize-undefined-trap-on-error in
production builds. Since the Nix language uses signed integers, overflow
was simply undefined behaviour, and since we defined that to trap, it
did.
Trapping on it was a bad UX, but we didn't even entirely notice
that we had done this at all until it was reported as a bug a couple of
months later (which is, to be fair, that flag working as intended), and
it's got enough production time that, aside from code that is IMHO buggy
(and which is, in any case, not in nixpkgs) such as
lix-project/lix#445, we don't think
anyone doing anything reasonable actually depends on wrapping overflow.
Even for weird use cases such as doing funny bit crimes, it doesn't make
sense IMO to have wrapping behaviour, since two's complement arithmetic
overflow behaviour is so *aggressively* not what you want for *any* kind
of mathematics/algorithms. The Nix language exists for package
management, a domain where bit crimes are already only dubiously in
scope to begin with, and it makes a lot more sense for that domain for
the integers to never lose precision, either by throwing errors if they
would, or by being arbitrary-precision.
This change will be ported to CppNix as well, to maintain language
consistency.
Fixes: lix-project/lix#423
Change-Id:
|
||
---|---|---|
.. | ||
ca | ||
common | ||
config | ||
dyn-drv | ||
flakes | ||
lang | ||
nested-sandboxing | ||
plugins | ||
repl_characterization | ||
test-libstoreconsumer | ||
add.sh | ||
bad.tar.xz | ||
bash-profile.sh | ||
big-derivation-attr.nix | ||
binary-cache-build-remote.sh | ||
binary-cache.sh | ||
brotli.sh | ||
build-delete.sh | ||
build-dry.sh | ||
build-hook-ca-fixed.nix | ||
build-hook-ca-floating.nix | ||
build-hook.nix | ||
build-remote-content-addressed-fixed.sh | ||
build-remote-content-addressed-floating.sh | ||
build-remote-input-addressed.sh | ||
build-remote-trustless-after.sh | ||
build-remote-trustless-should-fail-0.sh | ||
build-remote-trustless-should-pass-0.sh | ||
build-remote-trustless-should-pass-1.sh | ||
build-remote-trustless-should-pass-2.sh | ||
build-remote-trustless-should-pass-3.sh | ||
build-remote-trustless.sh | ||
build-remote.sh | ||
build.sh | ||
ca-shell.nix | ||
case-hack.sh | ||
case.nar | ||
check-refs.nix | ||
check-refs.sh | ||
check-reqs.nix | ||
check-reqs.sh | ||
check.nix | ||
check.sh | ||
common.sh | ||
completions.sh | ||
compression-levels.sh | ||
compute-levels.sh | ||
config.nix.in | ||
config.sh | ||
db-migration.sh | ||
debugger.sh | ||
dependencies.builder0.sh | ||
dependencies.nix | ||
dependencies.sh | ||
derivation-json.sh | ||
dummy | ||
dump-db.sh | ||
eval-store.sh | ||
eval.nix | ||
eval.sh | ||
experimental-features.sh | ||
export-graph.nix | ||
export-graph.sh | ||
export.sh | ||
extra-sandbox-profile.nix | ||
extra-sandbox-profile.sh | ||
failing.nix | ||
fetchClosure.sh | ||
fetchGit.sh | ||
fetchGitRefs.sh | ||
fetchGitSubmodules.sh | ||
fetchMercurial.sh | ||
fetchPath.sh | ||
fetchTree-file.sh | ||
fetchurl.sh | ||
filter-source.nix | ||
filter-source.sh | ||
fixed.builder1.sh | ||
fixed.builder2.sh | ||
fixed.nix | ||
fixed.sh | ||
fmt.sh | ||
fmt.simple.sh | ||
fod-failing.nix | ||
function-trace.sh | ||
gc-auto.sh | ||
gc-concurrent.builder.sh | ||
gc-concurrent.nix | ||
gc-concurrent.sh | ||
gc-concurrent2.builder.sh | ||
gc-non-blocking.sh | ||
gc-runtime.nix | ||
gc-runtime.sh | ||
gc.sh | ||
hash-check.nix | ||
hash.sh | ||
hermetic.nix | ||
ifd.nix | ||
import-derivation.nix | ||
import-derivation.sh | ||
impure-derivations.nix | ||
impure-derivations.sh | ||
impure-eval.sh | ||
init.sh | ||
install-darwin.sh | ||
lang-test-infra.sh | ||
lang.sh | ||
legacy-ssh-store.sh | ||
linux-sandbox-cert-test.nix | ||
linux-sandbox.sh | ||
local-store.sh | ||
logging.sh | ||
meson.build | ||
misc.sh | ||
multiple-outputs.nix | ||
multiple-outputs.sh | ||
nar-access.nix | ||
nar-access.sh | ||
nested-sandboxing.sh | ||
nix-build-examples.nix | ||
nix-build.sh | ||
nix-channel.sh | ||
nix-collect-garbage-d.sh | ||
nix-collect-garbage-dry-run.sh | ||
nix-copy-ssh-common.sh | ||
nix-copy-ssh-ng.sh | ||
nix-copy-ssh.sh | ||
nix-daemon-untrusting.sh | ||
nix-profile.sh | ||
nix-shell.sh | ||
nix_path.sh | ||
optimise-store.sh | ||
output-normalization.sh | ||
parallel.builder.sh | ||
parallel.nix | ||
parallel.sh | ||
pass-as-file.sh | ||
path-from-hash-part.sh | ||
path.nix | ||
placeholders.sh | ||
plugins.sh | ||
post-hook.sh | ||
pure-eval.nix | ||
pure-eval.sh | ||
push-to-store-old.sh | ||
push-to-store.sh | ||
read-only-store.sh | ||
readfile-context.nix | ||
readfile-context.sh | ||
recursive.nix | ||
recursive.sh | ||
referrers.sh | ||
remote-store.sh | ||
repair.sh | ||
repl.sh | ||
restricted.nix | ||
restricted.sh | ||
search.nix | ||
search.sh | ||
secure-drv-outputs.nix | ||
secure-drv-outputs.sh | ||
selfref-gc.sh | ||
shell-hello.nix | ||
shell.nix | ||
shell.sh | ||
shell.shebang.nix | ||
shell.shebang.rb | ||
shell.shebang.sh | ||
signing.sh | ||
simple-failing.nix | ||
simple.builder.sh | ||
simple.nix | ||
simple.sh | ||
ssh-relay.sh | ||
store-ping.sh | ||
structured-attrs-shell.nix | ||
structured-attrs.nix | ||
structured-attrs.sh | ||
substitute-truncated-nar.sh | ||
substitute-with-invalid-ca.sh | ||
suggestions.sh | ||
supplementary-groups.sh | ||
symlink-derivation.nix | ||
tarball.sh | ||
test-infra.sh | ||
test-libstoreconsumer.sh | ||
test-repl-characterization.sh | ||
timeout.nix | ||
timeout.sh | ||
toString-path.sh | ||
undefined-variable.nix | ||
user-envs-migration.sh | ||
user-envs.builder.sh | ||
user-envs.nix | ||
user-envs.sh | ||
why-depends.sh | ||
zstd.sh |