payload: {"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/miri/issues/873","repository_url":"https://api.github.com/repos/rust-lang/miri","labels_url":"https://api.github.com/repos/rust-lang/miri/issues/873/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/miri/issues/873/comments","events_url":"https://api.github.com/repos/rust-lang/miri/issues/873/events","html_url":"https://github.com/rust-lang/miri/issues/873","id":476047519,"node_id":"MDU6SXNzdWU0NzYwNDc1MTk=","number":873,"title":"Make pointer::align_offset exploit allocation alignment","user":{"login":"RalfJung","id":330628,"node_id":"MDQ6VXNlcjMzMDYyOA==","avatar_url":"https://avatars1.githubusercontent.com/u/330628?v=4","gravatar_id":"","url":"https://api.github.com/users/RalfJung","html_url":"https://github.com/RalfJung","followers_url":"https://api.github.com/users/RalfJung/followers","following_url":"https://api.github.com/users/RalfJung/following{/other_user}","gists_url":"https://api.github.com/users/RalfJung/gists{/gist_id}","starred_url":"https://api.github.com/users/RalfJung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RalfJung/subscriptions","organizations_url":"https://api.github.com/users/RalfJung/orgs","repos_url":"https://api.github.com/users/RalfJung/repos","events_url":"https://api.github.com/users/RalfJung/events{/privacy}","received_events_url":"https://api.github.com/users/RalfJung/received_events","type":"User","site_admin":false},"labels":[{"id":1130831860,"node_id":"MDU6TGFiZWwxMTMwODMxODYw","url":"https://api.github.com/repos/rust-lang/miri/labels/A-shims","name":"A-shims","color":"f7e101","default":false},{"id":285997301,"node_id":"MDU6TGFiZWwyODU5OTczMDE=","url":"https://api.github.com/repos/rust-lang/miri/labels/C-enhancement","name":"C-enhancement","color":"f5f1fd","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2019-08-02T07:54:48Z","updated_at":"2019-10-24T14:43:58Z","closed_at":null,"author_association":"MEMBER","body":"Miri's [implementation of `align_offset`](https://github.com/rust-lang/miri/blob/5bbf6733ea3d253740f2b78360c20f05781cfa11/src/shims/mod.rs#L28) currently always says \"nope, can't do that\". We could do better than that in case the alignment of the allocation of the argument pointer is at least the requested alignment. In that case, we can basically run the real implementation of `align_offset` from libcore.\r\n\r\nTestcase by @shepmaster:\r\n```rust\r\nuse std::mem;\r\n\r\n#[derive(Debug, Default)]\r\n#[repr(align(8))]\r\nstruct AlignToU64<T>(T);\r\n\r\nconst BYTE_LEN: usize = mem::size_of::<[u64; 4]>();\r\ntype Data = AlignToU64<[u8; BYTE_LEN]>;\r\n\r\nfn example(data: &Data) {\r\n    let (head, u64_arrays, tail) = unsafe { data.0.align_to::<[u64; 4]>() };\r\n\r\n    assert!(head.is_empty(), \"buffer was not aligned for 64-bit numbers\");\r\n    assert_eq!(u64_arrays.len(), 1, \"buffer was not long enough\");\r\n    assert!(tail.is_empty(), \"buffer was too long\");\r\n\r\n    let u64_array = &u64_arrays[0];\r\n    let _val = u64_array[0]; // make sure we can actually load this\r\n}\r\n\r\nfn main() {\r\n    example(&Data::default());\r\n}\r\n```\r\n\r\nThere should also be another testcase where the modulo stuff becomes more interesting (`align_offset` returns an offset in units of `size_of::<T>()`, not bytes)."},"comment":{"url":"https://api.github.com/repos/rust-lang/miri/issues/comments/545952184","html_url":"https://github.com/rust-lang/miri/issues/873#issuecomment-545952184","issue_url":"https://api.github.com/repos/rust-lang/miri/issues/873","id":545952184,"node_id":"MDEyOklzc3VlQ29tbWVudDU0NTk1MjE4NA==","user":{"login":"christianpoveda","id":31802960,"node_id":"MDQ6VXNlcjMxODAyOTYw","avatar_url":"https://avatars3.githubusercontent.com/u/31802960?v=4","gravatar_id":"","url":"https://api.github.com/users/christianpoveda","html_url":"https://github.com/christianpoveda","followers_url":"https://api.github.com/users/christianpoveda/followers","following_url":"https://api.github.com/users/christianpoveda/following{/other_user}","gists_url":"https://api.github.com/users/christianpoveda/gists{/gist_id}","starred_url":"https://api.github.com/users/christianpoveda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christianpoveda/subscriptions","organizations_url":"https://api.github.com/users/christianpoveda/orgs","repos_url":"https://api.github.com/users/christianpoveda/repos","events_url":"https://api.github.com/users/christianpoveda/events{/privacy}","received_events_url":"https://api.github.com/users/christianpoveda/received_events","type":"User","site_admin":false},"created_at":"2019-10-24T14:43:58Z","updated_at":"2019-10-24T14:43:58Z","author_association":"CONTRIBUTOR","body":"I think this was solved (at least partially) by https://github.com/rust-lang/miri/pull/945\r\n"}}
other: {"actor":{"display_login":"christianpoveda"}}