Commit 8f88c6e
committed
vmm: preserved FDs: prevent usage of same FD multiple times
Allowing the same file descriptor (FD) to be preserved more than once
can lead to severe issues. Consider the case where management software
adds two virtio-net devices at runtime, both backed by the same
externally provided FD.
When the first device is removed during runtime, the FD for the second
device becomes invalid [0].
To avoid misconfigurations, we now prevent multiple preservation
attempts of the same FD.
This however has some caveats: In the current model, external FDs are
added to the list of preserved FDs after the corresponding device has
been created successfully. Now assume the following:
- VM boots
- VM config has no preserved FDs
- We add a device to the VM that uses an external FD for its Tap dev
- The device is successfully initialized
- VM config is extended with the preserved FDs
- VM reboots
- VM config already has preserved FDs
- Same as above
- CRASH
Therefore, we need to know for every preserved FD whether it is "cold",
i.e., only has been part of a former VmConfig without associated device,
or "hot", i.e., it is currently also actively in use. This allows state
transitions from cold->hot in which case we won't throw an error for a
reused FD. Otherwise, we throw errors.
This requires that on shutdown, all preserved FDs are marked as cold.
[0] cloud-hypervisor#7371
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com1 parent a16080d commit 8f88c6e
File tree
7 files changed
+221
-50
lines changed- fuzz/fuzz_targets
- src
- vmm/src
7 files changed
+221
-50
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
192 | 193 | | |
193 | 194 | | |
194 | 195 | | |
195 | | - | |
| 196 | + | |
196 | 197 | | |
197 | 198 | | |
198 | 199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
904 | 904 | | |
905 | 905 | | |
906 | 906 | | |
| 907 | + | |
907 | 908 | | |
908 | 909 | | |
909 | 910 | | |
| |||
1028 | 1029 | | |
1029 | 1030 | | |
1030 | 1031 | | |
1031 | | - | |
| 1032 | + | |
1032 | 1033 | | |
1033 | 1034 | | |
1034 | 1035 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
364 | 372 | | |
365 | 373 | | |
366 | 374 | | |
| |||
3058 | 3066 | | |
3059 | 3067 | | |
3060 | 3068 | | |
3061 | | - | |
| 3069 | + | |
3062 | 3070 | | |
3063 | 3071 | | |
3064 | 3072 | | |
| |||
3131 | 3139 | | |
3132 | 3140 | | |
3133 | 3141 | | |
| 3142 | + | |
| 3143 | + | |
| 3144 | + | |
| 3145 | + | |
| 3146 | + | |
3134 | 3147 | | |
3135 | 3148 | | |
3136 | | - | |
3137 | | - | |
3138 | | - | |
| 3149 | + | |
| 3150 | + | |
| 3151 | + | |
| 3152 | + | |
| 3153 | + | |
| 3154 | + | |
| 3155 | + | |
| 3156 | + | |
| 3157 | + | |
| 3158 | + | |
| 3159 | + | |
| 3160 | + | |
| 3161 | + | |
| 3162 | + | |
| 3163 | + | |
| 3164 | + | |
| 3165 | + | |
| 3166 | + | |
| 3167 | + | |
| 3168 | + | |
| 3169 | + | |
| 3170 | + | |
3139 | 3171 | | |
3140 | | - | |
3141 | | - | |
| 3172 | + | |
| 3173 | + | |
| 3174 | + | |
| 3175 | + | |
| 3176 | + | |
| 3177 | + | |
| 3178 | + | |
| 3179 | + | |
| 3180 | + | |
| 3181 | + | |
| 3182 | + | |
| 3183 | + | |
| 3184 | + | |
| 3185 | + | |
| 3186 | + | |
| 3187 | + | |
| 3188 | + | |
3142 | 3189 | | |
| 3190 | + | |
| 3191 | + | |
3143 | 3192 | | |
3144 | | - | |
3145 | | - | |
| 3193 | + | |
| 3194 | + | |
| 3195 | + | |
| 3196 | + | |
| 3197 | + | |
| 3198 | + | |
| 3199 | + | |
| 3200 | + | |
| 3201 | + | |
| 3202 | + | |
| 3203 | + | |
| 3204 | + | |
| 3205 | + | |
| 3206 | + | |
| 3207 | + | |
| 3208 | + | |
| 3209 | + | |
| 3210 | + | |
| 3211 | + | |
3146 | 3212 | | |
3147 | | - | |
3148 | | - | |
| 3213 | + | |
3149 | 3214 | | |
3150 | 3215 | | |
3151 | 3216 | | |
| |||
3188 | 3253 | | |
3189 | 3254 | | |
3190 | 3255 | | |
3191 | | - | |
| 3256 | + | |
3192 | 3257 | | |
3193 | | - | |
3194 | | - | |
3195 | | - | |
3196 | | - | |
3197 | | - | |
3198 | | - | |
3199 | | - | |
3200 | | - | |
3201 | | - | |
3202 | | - | |
| 3258 | + | |
| 3259 | + | |
3203 | 3260 | | |
3204 | 3261 | | |
3205 | 3262 | | |
| |||
3210 | 3267 | | |
3211 | 3268 | | |
3212 | 3269 | | |
3213 | | - | |
3214 | | - | |
3215 | | - | |
3216 | | - | |
3217 | | - | |
3218 | | - | |
| 3270 | + | |
| 3271 | + | |
| 3272 | + | |
| 3273 | + | |
| 3274 | + | |
| 3275 | + | |
| 3276 | + | |
3219 | 3277 | | |
3220 | 3278 | | |
3221 | 3279 | | |
| |||
3994 | 4052 | | |
3995 | 4053 | | |
3996 | 4054 | | |
3997 | | - | |
| 4055 | + | |
3998 | 4056 | | |
3999 | 4057 | | |
4000 | 4058 | | |
| |||
4207 | 4265 | | |
4208 | 4266 | | |
4209 | 4267 | | |
4210 | | - | |
| 4268 | + | |
4211 | 4269 | | |
4212 | 4270 | | |
4213 | 4271 | | |
| |||
4829 | 4887 | | |
4830 | 4888 | | |
4831 | 4889 | | |
4832 | | - | |
| 4890 | + | |
4833 | 4891 | | |
4834 | 4892 | | |
4835 | 4893 | | |
4836 | 4894 | | |
4837 | | - | |
4838 | | - | |
4839 | | - | |
4840 | | - | |
| 4895 | + | |
| 4896 | + | |
| 4897 | + | |
4841 | 4898 | | |
4842 | 4899 | | |
| 4900 | + | |
| 4901 | + | |
| 4902 | + | |
| 4903 | + | |
| 4904 | + | |
| 4905 | + | |
| 4906 | + | |
| 4907 | + | |
| 4908 | + | |
| 4909 | + | |
| 4910 | + | |
| 4911 | + | |
| 4912 | + | |
| 4913 | + | |
| 4914 | + | |
| 4915 | + | |
| 4916 | + | |
| 4917 | + | |
| 4918 | + | |
| 4919 | + | |
| 4920 | + | |
| 4921 | + | |
| 4922 | + | |
| 4923 | + | |
| 4924 | + | |
| 4925 | + | |
| 4926 | + | |
| 4927 | + | |
| 4928 | + | |
| 4929 | + | |
| 4930 | + | |
| 4931 | + | |
| 4932 | + | |
| 4933 | + | |
| 4934 | + | |
| 4935 | + | |
| 4936 | + | |
| 4937 | + | |
| 4938 | + | |
| 4939 | + | |
| 4940 | + | |
| 4941 | + | |
4843 | 4942 | | |
4844 | 4943 | | |
4845 | 4944 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
667 | 667 | | |
668 | 668 | | |
669 | 669 | | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
670 | 673 | | |
671 | 674 | | |
672 | 675 | | |
| |||
2955 | 2958 | | |
2956 | 2959 | | |
2957 | 2960 | | |
2958 | | - | |
2959 | | - | |
2960 | | - | |
2961 | | - | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
2962 | 2966 | | |
2963 | 2967 | | |
2964 | 2968 | | |
| |||
4542 | 4546 | | |
4543 | 4547 | | |
4544 | 4548 | | |
4545 | | - | |
4546 | | - | |
| 4549 | + | |
| 4550 | + | |
4547 | 4551 | | |
4548 | 4552 | | |
4549 | 4553 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2253 | 2253 | | |
2254 | 2254 | | |
2255 | 2255 | | |
2256 | | - | |
2257 | 2256 | | |
2258 | 2257 | | |
2259 | 2258 | | |
| 2259 | + | |
| 2260 | + | |
| 2261 | + | |
| 2262 | + | |
| 2263 | + | |
| 2264 | + | |
| 2265 | + | |
| 2266 | + | |
2260 | 2267 | | |
2261 | 2268 | | |
2262 | 2269 | | |
| |||
2593 | 2600 | | |
2594 | 2601 | | |
2595 | 2602 | | |
| 2603 | + | |
| 2604 | + | |
2596 | 2605 | | |
2597 | 2606 | | |
2598 | 2607 | | |
| |||
2693 | 2702 | | |
2694 | 2703 | | |
2695 | 2704 | | |
2696 | | - | |
| 2705 | + | |
2697 | 2706 | | |
2698 | 2707 | | |
2699 | 2708 | | |
| |||
0 commit comments