Commit 482330f
drm, fbcon, vga_switcheroo: Avoid race condition in fbcon setup
[ Upstream commit eb76d0f ]
Protect vga_switcheroo_client_fb_set() with console lock. Avoids OOB
access in fbcon_remap_all(). Without holding the console lock the call
races with switching outputs.
VGA switcheroo calls fbcon_remap_all() when switching clients. The fbcon
function uses struct fb_info.node, which is set by register_framebuffer().
As the fb-helper code currently sets up VGA switcheroo before registering
the framebuffer, the value of node is -1 and therefore not a legal value.
For example, fbcon uses the value within set_con2fb_map() [1] as an index
into an array.
Moving vga_switcheroo_client_fb_set() after register_framebuffer() can
result in VGA switching that does not switch fbcon correctly.
Therefore move vga_switcheroo_client_fb_set() under fbcon_fb_registered(),
which already holds the console lock. Fbdev calls fbcon_fb_registered()
from within register_framebuffer(). Serializes the helper with VGA
switcheroo's call to fbcon_remap_all().
Although vga_switcheroo_client_fb_set() takes an instance of struct fb_info
as parameter, it really only needs the contained fbcon state. Moving the
call to fbcon initialization is therefore cleaner than before. Only amdgpu,
i915, nouveau and radeon support vga_switcheroo. For all other drivers,
this change does nothing.
Signed-off-by: Thomas Zimmermann <[email protected]>
Link: https://elixir.bootlin.com/linux/v6.17/source/drivers/video/fbdev/core/fbcon.c#L2942 # [1]
Fixes: 6a9ee8a ("vga_switcheroo: initial implementation (v15)")
Acked-by: Javier Martinez Canillas <[email protected]>
Acked-by: Alex Deucher <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: <[email protected]> # v2.6.34+
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>1 parent 1ba6da6 commit 482330f
File tree
4 files changed
+9
-17
lines changed- drivers
- gpu/drm
- i915/display
- radeon
- video/fbdev/core
4 files changed
+9
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | 33 | | |
35 | | - | |
36 | 34 | | |
37 | 35 | | |
38 | 36 | | |
| |||
1637 | 1635 | | |
1638 | 1636 | | |
1639 | 1637 | | |
1640 | | - | |
1641 | | - | |
1642 | | - | |
1643 | | - | |
1644 | 1638 | | |
1645 | 1639 | | |
1646 | 1640 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
589 | 589 | | |
590 | 590 | | |
591 | 591 | | |
592 | | - | |
593 | | - | |
594 | 592 | | |
595 | 593 | | |
596 | | - | |
597 | 594 | | |
598 | 595 | | |
599 | 596 | | |
| |||
620 | 617 | | |
621 | 618 | | |
622 | 619 | | |
623 | | - | |
624 | 620 | | |
625 | 621 | | |
626 | 622 | | |
| |||
634 | 630 | | |
635 | 631 | | |
636 | 632 | | |
637 | | - | |
638 | | - | |
639 | 633 | | |
640 | 634 | | |
641 | 635 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
303 | | - | |
304 | 303 | | |
305 | 304 | | |
306 | | - | |
307 | 305 | | |
308 | 306 | | |
309 | 307 | | |
| |||
325 | 323 | | |
326 | 324 | | |
327 | 325 | | |
328 | | - | |
329 | 326 | | |
330 | 327 | | |
331 | 328 | | |
| |||
342 | 339 | | |
343 | 340 | | |
344 | 341 | | |
345 | | - | |
346 | | - | |
347 | 342 | | |
348 | 343 | | |
349 | 344 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| |||
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| 81 | + | |
80 | 82 | | |
81 | 83 | | |
82 | 84 | | |
| |||
2894 | 2896 | | |
2895 | 2897 | | |
2896 | 2898 | | |
| 2899 | + | |
| 2900 | + | |
| 2901 | + | |
2897 | 2902 | | |
2898 | 2903 | | |
2899 | 2904 | | |
| |||
3027 | 3032 | | |
3028 | 3033 | | |
3029 | 3034 | | |
| 3035 | + | |
| 3036 | + | |
| 3037 | + | |
| 3038 | + | |
3030 | 3039 | | |
3031 | 3040 | | |
3032 | 3041 | | |
| |||
0 commit comments