Skip to content

Commit 4b70dd5

Browse files
Jiri Slabygregkh
authored andcommitted
vt: selection, push console lock down
We need to nest the console lock in sel_lock, so we have to push it down a bit. Fortunately, the callers of set_selection_* just lock the console lock around the function call. So moving it down is easy. In the next patch, we switch the order. Signed-off-by: Jiri Slaby <[email protected]> Fixes: 07e6124 ("vt: selection, close sel_buffer race") Cc: stable <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f8788d8 commit 4b70dd5

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

drivers/staging/speakup/selection.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ static void __speakup_set_selection(struct work_struct *work)
5151
goto unref;
5252
}
5353

54-
console_lock();
5554
set_selection_kernel(&sel, tty);
56-
console_unlock();
5755

5856
unref:
5957
tty_kref_put(tty);

drivers/tty/vt/selection.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ int set_selection_user(const struct tiocl_selection __user *sel,
181181
return set_selection_kernel(&v, tty);
182182
}
183183

184-
int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
184+
static int __set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
185185
{
186186
struct vc_data *vc = vc_cons[fg_console].d;
187187
int new_sel_start, new_sel_end, spc;
@@ -343,6 +343,17 @@ int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
343343
mutex_unlock(&sel_lock);
344344
return ret;
345345
}
346+
347+
int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
348+
{
349+
int ret;
350+
351+
console_lock();
352+
ret = __set_selection_kernel(v, tty);
353+
console_unlock();
354+
355+
return ret;
356+
}
346357
EXPORT_SYMBOL_GPL(set_selection_kernel);
347358

348359
/* Insert the contents of the selection buffer into the

drivers/tty/vt/vt.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3046,10 +3046,8 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
30463046
switch (type)
30473047
{
30483048
case TIOCL_SETSEL:
3049-
console_lock();
30503049
ret = set_selection_user((struct tiocl_selection
30513050
__user *)(p+1), tty);
3052-
console_unlock();
30533051
break;
30543052
case TIOCL_PASTESEL:
30553053
ret = paste_selection(tty);

0 commit comments

Comments
 (0)