Skip to content

Commit ddde3c1

Browse files
committed
vt: More locking checks
I honestly have no idea what the subtle differences between con_is_visible, con_is_fg (internal to vt.c) and con_is_bound are. But it looks like both vc->vc_display_fg and con_driver_map are protected by the console_lock, so probably better if we hold that when checking this. To do that I had to deinline the con_is_visible function. Signed-off-by: Daniel Vetter <[email protected]> Reviewed-by: Sam Ravnborg <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Reviewed-by: Maarten Lankhorst <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Nicolas Pitre <[email protected]> Cc: Martin Hostettler <[email protected]> Cc: Adam Borowski <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Mikulas Patocka <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent a135513 commit ddde3c1

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

drivers/tty/vt/vt.c

+16
Original file line numberDiff line numberDiff line change
@@ -3822,6 +3822,8 @@ int con_is_bound(const struct consw *csw)
38223822
{
38233823
int i, bound = 0;
38243824

3825+
WARN_CONSOLE_UNLOCKED();
3826+
38253827
for (i = 0; i < MAX_NR_CONSOLES; i++) {
38263828
if (con_driver_map[i] == csw) {
38273829
bound = 1;
@@ -3833,6 +3835,20 @@ int con_is_bound(const struct consw *csw)
38333835
}
38343836
EXPORT_SYMBOL(con_is_bound);
38353837

3838+
/**
3839+
* con_is_visible - checks whether the current console is visible
3840+
* @vc: virtual console
3841+
*
3842+
* RETURNS: zero if not visible, nonzero if visible
3843+
*/
3844+
bool con_is_visible(const struct vc_data *vc)
3845+
{
3846+
WARN_CONSOLE_UNLOCKED();
3847+
3848+
return *vc->vc_display_fg == vc;
3849+
}
3850+
EXPORT_SYMBOL(con_is_visible);
3851+
38363852
/**
38373853
* con_debug_enter - prepare the console for the kernel debugger
38383854
* @sw: console driver

include/linux/console_struct.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,6 @@ extern void vc_SAK(struct work_struct *work);
168168

169169
#define CUR_DEFAULT CUR_UNDERLINE
170170

171-
static inline bool con_is_visible(const struct vc_data *vc)
172-
{
173-
return *vc->vc_display_fg == vc;
174-
}
171+
bool con_is_visible(const struct vc_data *vc);
175172

176173
#endif /* _LINUX_CONSOLE_STRUCT_H */

0 commit comments

Comments
 (0)