-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shims for vararg functions: check that we get the right number of "fixed" arguments #4013
Comments
This sounds interesting :) @rustbot claim |
In fact we probably want to pass that down instead of the
Great. :D |
Do we really want to remove passing |
That should be changed to check the calling convention stored in |
Pass FnAbi to find_mir_or_eval_fn rust-lang/miri#4013 needs information from ``FnAbi``, hence it is passed to ``find_mir_or_eval_fn``. r? `@RalfJung`
Pass FnAbi to find_mir_or_eval_fn rust-lang/miri#4013 needs information from ``FnAbi``, hence it is passed to ``find_mir_or_eval_fn``. r? ``@RalfJung``
Pass FnAbi to find_mir_or_eval_fn rust-lang/miri#4013 needs information from ``FnAbi``, hence it is passed to ``find_mir_or_eval_fn``. r? `@RalfJung`
Rollup merge of rust-lang#133103 - tiif:fnabi, r=RalfJung Pass FnAbi to find_mir_or_eval_fn rust-lang/miri#4013 needs information from ``FnAbi``, hence it is passed to ``find_mir_or_eval_fn``. r? `@RalfJung`
Pass FnAbi to find_mir_or_eval_fn rust-lang#4013 needs information from ``FnAbi``, hence it is passed to ``find_mir_or_eval_fn``. r? `@RalfJung`
This is currently the next thing on my queue, but I am on a break for a few days, so this probably won't be resumed until 2025 ^^. |
Most Miri shims use
check_shim
to ensure they are called with the right ABI and right number of arguments. However, some shims emulate vararg functions. There, we currently separately callcheck_abi_and_shim_symbol_clash
and thencheck_min_arg_count
,however, that misses potential UB: when a function, likeopen
, is declared with 2 fixed args followed by varargs, then it is crucial that the caller uses a signature that actually involves 2 fixed args followed by varargs. If someone were to, say, declare this function asand then call it as
open(path, flags)
, that is Undefined Behavior!Similarly, non-vararg shims can actually currently be invoked with a vararg import, which should also be detected as UB.
Unfortunately,
emulate_foreign_item
is not even given enough information to detect this -- we are given a slice ofargs
, but we don't learn how many of those were passed as fixed args vs varargs. So this requires changing the rustc side of this to pass more information tofind_mir_or_eval_fn
-- basically, we should pass down the fullFnAbi
.The text was updated successfully, but these errors were encountered: