Commit b6250dc
hypervisor: kvm: aarch64: fix get_device_attr() UB
DeviceFd::get_device_attr should be marked as unsafe, because it
allows writing to an arbitrary address. I have opened a kvm-ioctls
PR[1] to fix this. The hypervisor crate was using the function
unsafely by passing it addresses of immutable variables. I noticed
this because an optimisation change[2] in Rust 1.80.0 caused the
kvm::aarch64::gic::tests::test_get_set_icc_regs test to start failing
when built in release mode.
To fix this, I've broken up the _access functions into _set and _get
variants, with the _get variant using a pointer to a mutable variable.
This has the side effect of making these functions a bit nicer to use,
because the caller now has no need to use references at all, for
either getting or setting.
[1]: rust-vmm/kvm#273
[2]: rust-lang/rust@d2d24e3
Signed-off-by: Alyssa Ross <hi@alyssa.is>
(cherry picked from commit 02f146f)1 parent b495d2a commit b6250dc
File tree
4 files changed
+144
-128
lines changed- hypervisor/src/kvm/aarch64/gic
4 files changed
+144
-128
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
81 | | - | |
| 80 | + | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
96 | 92 | | |
97 | 93 | | |
98 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
99 | 114 | | |
100 | 115 | | |
101 | | - | |
102 | | - | |
103 | | - | |
| 116 | + | |
104 | 117 | | |
105 | 118 | | |
106 | 119 | | |
107 | 120 | | |
108 | | - | |
| 121 | + | |
109 | 122 | | |
110 | 123 | | |
111 | 124 | | |
112 | | - | |
| 125 | + | |
113 | 126 | | |
114 | 127 | | |
115 | 128 | | |
116 | 129 | | |
117 | | - | |
| 130 | + | |
118 | 131 | | |
119 | 132 | | |
| 133 | + | |
| 134 | + | |
120 | 135 | | |
121 | 136 | | |
122 | 137 | | |
| |||
158 | 173 | | |
159 | 174 | | |
160 | 175 | | |
161 | | - | |
162 | | - | |
| 176 | + | |
163 | 177 | | |
164 | 178 | | |
165 | 179 | | |
| |||
175 | 189 | | |
176 | 190 | | |
177 | 191 | | |
178 | | - | |
179 | | - | |
180 | | - | |
| 192 | + | |
181 | 193 | | |
182 | 194 | | |
183 | 195 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
83 | | - | |
| 82 | + | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
98 | 94 | | |
99 | 95 | | |
100 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
101 | 116 | | |
102 | 117 | | |
103 | 118 | | |
| |||
107 | 122 | | |
108 | 123 | | |
109 | 124 | | |
110 | | - | |
111 | 125 | | |
112 | 126 | | |
113 | | - | |
| 127 | + | |
114 | 128 | | |
115 | 129 | | |
116 | 130 | | |
| |||
130 | 144 | | |
131 | 145 | | |
132 | 146 | | |
133 | | - | |
134 | | - | |
| 147 | + | |
135 | 148 | | |
136 | 149 | | |
137 | 150 | | |
138 | 151 | | |
139 | 152 | | |
140 | 153 | | |
141 | 154 | | |
142 | | - | |
143 | | - | |
| 155 | + | |
144 | 156 | | |
145 | 157 | | |
146 | | - | |
147 | | - | |
| 158 | + | |
148 | 159 | | |
149 | 160 | | |
150 | 161 | | |
| |||
165 | 176 | | |
166 | 177 | | |
167 | 178 | | |
168 | | - | |
| 179 | + | |
169 | 180 | | |
170 | 181 | | |
171 | 182 | | |
| |||
176 | 187 | | |
177 | 188 | | |
178 | 189 | | |
179 | | - | |
| 190 | + | |
180 | 191 | | |
181 | 192 | | |
182 | 193 | | |
183 | 194 | | |
184 | | - | |
| 195 | + | |
185 | 196 | | |
186 | 197 | | |
187 | 198 | | |
| |||
0 commit comments