Skip to content

Commit 521d01c

Browse files
committed
Merge tag 'v5.6.2' into 5.6/master
This is the 5.6.2 stable release * tag 'v5.6.2': Linux 5.6.2 platform/x86: pmc_atom: Add Lex 2I385SW to critclk_systems DMI table vt: vt_ioctl: fix use-after-free in vt_in_use() vt: vt_ioctl: fix VT_DISALLOCATE freeing in-use virtual console vt: vt_ioctl: remove unnecessary console allocation checks vt: switch vt_dont_switch to bool vt: ioctl, switch VT_IS_IN_USE and VT_BUSY to inlines vt: selection, introduce vc_is_sel serial: sprd: Fix a dereference warning mac80211: fix authentication with iwlwifi/mvm bpf: update jmp32 test cases to fix range bound deduction
2 parents 93c70c5 + 9fbe5c8 commit 521d01c

9 files changed

Lines changed: 91 additions & 47 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22
VERSION = 5
33
PATCHLEVEL = 6
4-
SUBLEVEL = 1
4+
SUBLEVEL = 2
55
EXTRAVERSION = -zen
66
NAME = Tea Storm
77

drivers/platform/x86/pmc_atom.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,14 @@ static const struct dmi_system_id critclk_systems[] = {
383383
DMI_MATCH(DMI_PRODUCT_NAME, "3I380D"),
384384
},
385385
},
386+
{
387+
/* pmc_plt_clk* - are used for ethernet controllers */
388+
.ident = "Lex 2I385SW",
389+
.matches = {
390+
DMI_MATCH(DMI_SYS_VENDOR, "Lex BayTrail"),
391+
DMI_MATCH(DMI_PRODUCT_NAME, "2I385SW"),
392+
},
393+
},
386394
{
387395
/* pmc_plt_clk* - are used for ethernet controllers */
388396
.ident = "Beckhoff CB3163",

drivers/tty/serial/sprd_serial.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,14 +1132,13 @@ static int sprd_remove(struct platform_device *dev)
11321132
if (sup) {
11331133
uart_remove_one_port(&sprd_uart_driver, &sup->port);
11341134
sprd_port[sup->port.line] = NULL;
1135+
sprd_rx_free_buf(sup);
11351136
sprd_ports_num--;
11361137
}
11371138

11381139
if (!sprd_ports_num)
11391140
uart_unregister_driver(&sprd_uart_driver);
11401141

1141-
sprd_rx_free_buf(sup);
1142-
11431142
return 0;
11441143
}
11451144

drivers/tty/vt/selection.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ void clear_selection(void)
8888
}
8989
EXPORT_SYMBOL_GPL(clear_selection);
9090

91+
bool vc_is_sel(struct vc_data *vc)
92+
{
93+
return vc == sel_cons;
94+
}
95+
9196
/*
9297
* User settable table: what characters are to be considered alphabetic?
9398
* 128 bits. Locked by the console lock.

drivers/tty/vt/vt.c

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -890,8 +890,9 @@ static void hide_softcursor(struct vc_data *vc)
890890

891891
static void hide_cursor(struct vc_data *vc)
892892
{
893-
if (vc == sel_cons)
893+
if (vc_is_sel(vc))
894894
clear_selection();
895+
895896
vc->vc_sw->con_cursor(vc, CM_ERASE);
896897
hide_softcursor(vc);
897898
}
@@ -901,7 +902,7 @@ static void set_cursor(struct vc_data *vc)
901902
if (!con_is_fg(vc) || console_blanked || vc->vc_mode == KD_GRAPHICS)
902903
return;
903904
if (vc->vc_deccm) {
904-
if (vc == sel_cons)
905+
if (vc_is_sel(vc))
905906
clear_selection();
906907
add_softcursor(vc);
907908
if ((vc->vc_cursor_type & 0x0f) != 1)
@@ -1074,6 +1075,17 @@ static void visual_deinit(struct vc_data *vc)
10741075
module_put(vc->vc_sw->owner);
10751076
}
10761077

1078+
static void vc_port_destruct(struct tty_port *port)
1079+
{
1080+
struct vc_data *vc = container_of(port, struct vc_data, port);
1081+
1082+
kfree(vc);
1083+
}
1084+
1085+
static const struct tty_port_operations vc_port_ops = {
1086+
.destruct = vc_port_destruct,
1087+
};
1088+
10771089
int vc_allocate(unsigned int currcons) /* return 0 on success */
10781090
{
10791091
struct vt_notifier_param param;
@@ -1099,6 +1111,7 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */
10991111

11001112
vc_cons[currcons].d = vc;
11011113
tty_port_init(&vc->port);
1114+
vc->port.ops = &vc_port_ops;
11021115
INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK);
11031116

11041117
visual_init(vc, currcons, 1);
@@ -1207,7 +1220,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
12071220
}
12081221
}
12091222

1210-
if (vc == sel_cons)
1223+
if (vc_is_sel(vc))
12111224
clear_selection();
12121225

12131226
old_rows = vc->vc_rows;
@@ -3253,6 +3266,7 @@ static int con_install(struct tty_driver *driver, struct tty_struct *tty)
32533266

32543267
tty->driver_data = vc;
32553268
vc->port.tty = tty;
3269+
tty_port_get(&vc->port);
32563270

32573271
if (!tty->winsize.ws_row && !tty->winsize.ws_col) {
32583272
tty->winsize.ws_row = vc_cons[currcons].d->vc_rows;
@@ -3288,6 +3302,13 @@ static void con_shutdown(struct tty_struct *tty)
32883302
console_unlock();
32893303
}
32903304

3305+
static void con_cleanup(struct tty_struct *tty)
3306+
{
3307+
struct vc_data *vc = tty->driver_data;
3308+
3309+
tty_port_put(&vc->port);
3310+
}
3311+
32913312
static int default_color = 7; /* white */
32923313
static int default_italic_color = 2; // green (ASCII)
32933314
static int default_underline_color = 3; // cyan (ASCII)
@@ -3413,7 +3434,8 @@ static const struct tty_operations con_ops = {
34133434
.throttle = con_throttle,
34143435
.unthrottle = con_unthrottle,
34153436
.resize = vt_resize,
3416-
.shutdown = con_shutdown
3437+
.shutdown = con_shutdown,
3438+
.cleanup = con_cleanup,
34173439
};
34183440

34193441
static struct cdev vc0_cdev;

drivers/tty/vt/vt_ioctl.c

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,32 @@
3939
#include <linux/kbd_diacr.h>
4040
#include <linux/selection.h>
4141

42-
char vt_dont_switch;
43-
extern struct tty_driver *console_driver;
42+
bool vt_dont_switch;
4443

45-
#define VT_IS_IN_USE(i) (console_driver->ttys[i] && console_driver->ttys[i]->count)
46-
#define VT_BUSY(i) (VT_IS_IN_USE(i) || i == fg_console || vc_cons[i].d == sel_cons)
44+
static inline bool vt_in_use(unsigned int i)
45+
{
46+
const struct vc_data *vc = vc_cons[i].d;
47+
48+
/*
49+
* console_lock must be held to prevent the vc from being deallocated
50+
* while we're checking whether it's in-use.
51+
*/
52+
WARN_CONSOLE_UNLOCKED();
53+
54+
return vc && kref_read(&vc->port.kref) > 1;
55+
}
56+
57+
static inline bool vt_busy(int i)
58+
{
59+
if (vt_in_use(i))
60+
return true;
61+
if (i == fg_console)
62+
return true;
63+
if (vc_is_sel(vc_cons[i].d))
64+
return true;
65+
66+
return false;
67+
}
4768

4869
/*
4970
* Console (vt and kd) routines, as defined by USL SVR4 manual, and by
@@ -289,16 +310,14 @@ static int vt_disallocate(unsigned int vc_num)
289310
int ret = 0;
290311

291312
console_lock();
292-
if (VT_BUSY(vc_num))
313+
if (vt_busy(vc_num))
293314
ret = -EBUSY;
294315
else if (vc_num)
295316
vc = vc_deallocate(vc_num);
296317
console_unlock();
297318

298-
if (vc && vc_num >= MIN_NR_CONSOLES) {
299-
tty_port_destroy(&vc->port);
300-
kfree(vc);
301-
}
319+
if (vc && vc_num >= MIN_NR_CONSOLES)
320+
tty_port_put(&vc->port);
302321

303322
return ret;
304323
}
@@ -311,17 +330,15 @@ static void vt_disallocate_all(void)
311330

312331
console_lock();
313332
for (i = 1; i < MAX_NR_CONSOLES; i++)
314-
if (!VT_BUSY(i))
333+
if (!vt_busy(i))
315334
vc[i] = vc_deallocate(i);
316335
else
317336
vc[i] = NULL;
318337
console_unlock();
319338

320339
for (i = 1; i < MAX_NR_CONSOLES; i++) {
321-
if (vc[i] && i >= MIN_NR_CONSOLES) {
322-
tty_port_destroy(&vc[i]->port);
323-
kfree(vc[i]);
324-
}
340+
if (vc[i] && i >= MIN_NR_CONSOLES)
341+
tty_port_put(&vc[i]->port);
325342
}
326343
}
327344

@@ -335,22 +352,13 @@ int vt_ioctl(struct tty_struct *tty,
335352
{
336353
struct vc_data *vc = tty->driver_data;
337354
struct console_font_op op; /* used in multiple places here */
338-
unsigned int console;
355+
unsigned int console = vc->vc_num;
339356
unsigned char ucval;
340357
unsigned int uival;
341358
void __user *up = (void __user *)arg;
342359
int i, perm;
343360
int ret = 0;
344361

345-
console = vc->vc_num;
346-
347-
348-
if (!vc_cons_allocated(console)) { /* impossible? */
349-
ret = -ENOIOCTLCMD;
350-
goto out;
351-
}
352-
353-
354362
/*
355363
* To have permissions to do most of the vt ioctls, we either have
356364
* to be the owner of the tty, or have CAP_SYS_TTY_CONFIG.
@@ -641,15 +649,16 @@ int vt_ioctl(struct tty_struct *tty,
641649
struct vt_stat __user *vtstat = up;
642650
unsigned short state, mask;
643651

644-
/* Review: FIXME: Console lock ? */
645652
if (put_user(fg_console + 1, &vtstat->v_active))
646653
ret = -EFAULT;
647654
else {
648655
state = 1; /* /dev/tty0 is always open */
656+
console_lock(); /* required by vt_in_use() */
649657
for (i = 0, mask = 2; i < MAX_NR_CONSOLES && mask;
650658
++i, mask <<= 1)
651-
if (VT_IS_IN_USE(i))
659+
if (vt_in_use(i))
652660
state |= mask;
661+
console_unlock();
653662
ret = put_user(state, &vtstat->v_state);
654663
}
655664
break;
@@ -659,10 +668,11 @@ int vt_ioctl(struct tty_struct *tty,
659668
* Returns the first available (non-opened) console.
660669
*/
661670
case VT_OPENQRY:
662-
/* FIXME: locking ? - but then this is a stupid API */
671+
console_lock(); /* required by vt_in_use() */
663672
for (i = 0; i < MAX_NR_CONSOLES; ++i)
664-
if (! VT_IS_IN_USE(i))
673+
if (!vt_in_use(i))
665674
break;
675+
console_unlock();
666676
uival = i < MAX_NR_CONSOLES ? (i+1) : -1;
667677
goto setint;
668678

@@ -1011,12 +1021,12 @@ int vt_ioctl(struct tty_struct *tty,
10111021
case VT_LOCKSWITCH:
10121022
if (!capable(CAP_SYS_TTY_CONFIG))
10131023
return -EPERM;
1014-
vt_dont_switch = 1;
1024+
vt_dont_switch = true;
10151025
break;
10161026
case VT_UNLOCKSWITCH:
10171027
if (!capable(CAP_SYS_TTY_CONFIG))
10181028
return -EPERM;
1019-
vt_dont_switch = 0;
1029+
vt_dont_switch = false;
10201030
break;
10211031
case VT_GETHIFONTMASK:
10221032
ret = put_user(vc->vc_hi_font_mask,
@@ -1180,14 +1190,9 @@ long vt_compat_ioctl(struct tty_struct *tty,
11801190
{
11811191
struct vc_data *vc = tty->driver_data;
11821192
struct console_font_op op; /* used in multiple places here */
1183-
unsigned int console = vc->vc_num;
11841193
void __user *up = compat_ptr(arg);
11851194
int perm;
11861195

1187-
1188-
if (!vc_cons_allocated(console)) /* impossible? */
1189-
return -ENOIOCTLCMD;
1190-
11911196
/*
11921197
* To have permissions to do most of the vt ioctls, we either have
11931198
* to be the owner of the tty, or have CAP_SYS_TTY_CONFIG.

include/linux/selection.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#include <linux/tiocl.h>
1212
#include <linux/vt_buffer.h>
1313

14-
extern struct vc_data *sel_cons;
1514
struct tty_struct;
15+
struct vc_data;
1616

1717
extern void clear_selection(void);
1818
extern int set_selection_user(const struct tiocl_selection __user *sel,
@@ -24,6 +24,8 @@ extern int sel_loadlut(char __user *p);
2424
extern int mouse_reporting(void);
2525
extern void mouse_report(struct tty_struct * tty, int butt, int mrx, int mry);
2626

27+
bool vc_is_sel(struct vc_data *vc);
28+
2729
extern int console_blanked;
2830

2931
extern const unsigned char color_table[];

include/linux/vt_kern.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ extern int do_unbind_con_driver(const struct consw *csw, int first, int last,
135135
int deflt);
136136
int vty_init(const struct file_operations *console_fops);
137137

138-
extern char vt_dont_switch;
138+
extern bool vt_dont_switch;
139139
extern int default_utf8;
140140
extern int global_cursor_default;
141141

tools/testing/selftests/bpf/verifier/jmp32.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,8 @@
783783
},
784784
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
785785
.fixup_map_hash_48b = { 4 },
786-
.result = ACCEPT,
786+
.result = REJECT,
787+
.errstr = "R8 unbounded memory access",
787788
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
788789
},
789790
{
@@ -811,7 +812,8 @@
811812
},
812813
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
813814
.fixup_map_hash_48b = { 4 },
814-
.result = ACCEPT,
815+
.result = REJECT,
816+
.errstr = "R8 unbounded memory access",
815817
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
816818
},
817819
{
@@ -839,6 +841,7 @@
839841
},
840842
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
841843
.fixup_map_hash_48b = { 4 },
842-
.result = ACCEPT,
844+
.result = REJECT,
845+
.errstr = "R8 unbounded memory access",
843846
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
844847
},

0 commit comments

Comments
 (0)