Skip to content

Commit e675482

Browse files
committed
Merge tag 'mips_fixes_4.16_4' of git://git.kernel.org/pub/scm/linux/kernel/git/jhogan/mips
Pull MIPS fixes from James Hogan: "A miscellaneous pile of MIPS fixes for 4.16: - move put_compat_sigset() to evade hardened usercopy warnings (4.16) - select ARCH_HAVE_PC_{SERIO,PARPORT} for Loongson64 platforms (4.16) - fix kzalloc() failure handling in ath25 (3.19) and Octeon (4.0) - fix disabling of IPIs during BMIPS suspend (3.19)" * tag 'mips_fixes_4.16_4' of git://git.kernel.org/pub/scm/linux/kernel/git/jhogan/mips: MIPS: BMIPS: Do not mask IPIs during suspend MIPS: Loongson64: Select ARCH_MIGHT_HAVE_PC_SERIO MIPS: Loongson64: Select ARCH_MIGHT_HAVE_PC_PARPORT signals: Move put_compat_sigset to compat.h to silence hardened usercopy MIPS: OCTEON: irq: Check for null return on kzalloc allocation MIPS: ath25: Check for kzalloc allocation failure
2 parents 98577c6 + 06a3f0c commit e675482

File tree

6 files changed

+38
-25
lines changed

6 files changed

+38
-25
lines changed

arch/mips/ath25/board.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ int __init ath25_find_config(phys_addr_t base, unsigned long size)
135135
}
136136

137137
board_data = kzalloc(BOARD_CONFIG_BUFSZ, GFP_KERNEL);
138+
if (!board_data)
139+
goto error;
138140
ath25_board.config = (struct ath25_boarddata *)board_data;
139141
memcpy_fromio(board_data, bcfg, 0x100);
140142
if (broken_boarddata) {

arch/mips/cavium-octeon/octeon-irq.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2277,6 +2277,8 @@ static int __init octeon_irq_init_cib(struct device_node *ciu_node,
22772277
}
22782278

22792279
host_data = kzalloc(sizeof(*host_data), GFP_KERNEL);
2280+
if (!host_data)
2281+
return -ENOMEM;
22802282
raw_spin_lock_init(&host_data->lock);
22812283

22822284
addr = of_get_address(ciu_node, 0, NULL, NULL);

arch/mips/kernel/smp-bmips.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ static void bmips_prepare_cpus(unsigned int max_cpus)
168168
return;
169169
}
170170

171-
if (request_irq(IPI0_IRQ, bmips_ipi_interrupt, IRQF_PERCPU,
172-
"smp_ipi0", NULL))
171+
if (request_irq(IPI0_IRQ, bmips_ipi_interrupt,
172+
IRQF_PERCPU | IRQF_NO_SUSPEND, "smp_ipi0", NULL))
173173
panic("Can't request IPI0 interrupt");
174-
if (request_irq(IPI1_IRQ, bmips_ipi_interrupt, IRQF_PERCPU,
175-
"smp_ipi1", NULL))
174+
if (request_irq(IPI1_IRQ, bmips_ipi_interrupt,
175+
IRQF_PERCPU | IRQF_NO_SUSPEND, "smp_ipi1", NULL))
176176
panic("Can't request IPI1 interrupt");
177177
}
178178

arch/mips/loongson64/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ choice
77
config LEMOTE_FULOONG2E
88
bool "Lemote Fuloong(2e) mini-PC"
99
select ARCH_SPARSEMEM_ENABLE
10+
select ARCH_MIGHT_HAVE_PC_PARPORT
11+
select ARCH_MIGHT_HAVE_PC_SERIO
1012
select CEVT_R4K
1113
select CSRC_R4K
1214
select SYS_HAS_CPU_LOONGSON2E
@@ -33,6 +35,8 @@ config LEMOTE_FULOONG2E
3335
config LEMOTE_MACH2F
3436
bool "Lemote Loongson 2F family machines"
3537
select ARCH_SPARSEMEM_ENABLE
38+
select ARCH_MIGHT_HAVE_PC_PARPORT
39+
select ARCH_MIGHT_HAVE_PC_SERIO
3640
select BOARD_SCACHE
3741
select BOOT_ELF32
3842
select CEVT_R4K if ! MIPS_EXTERNAL_TIMER
@@ -62,6 +66,8 @@ config LEMOTE_MACH2F
6266
config LOONGSON_MACH3X
6367
bool "Generic Loongson 3 family machines"
6468
select ARCH_SPARSEMEM_ENABLE
69+
select ARCH_MIGHT_HAVE_PC_PARPORT
70+
select ARCH_MIGHT_HAVE_PC_SERIO
6571
select GENERIC_ISA_DMA_SUPPORT_BROKEN
6672
select BOOT_ELF32
6773
select BOARD_SCACHE

include/linux/compat.h

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/if.h>
1818
#include <linux/fs.h>
1919
#include <linux/aio_abi.h> /* for aio_context_t */
20+
#include <linux/uaccess.h>
2021
#include <linux/unistd.h>
2122

2223
#include <asm/compat.h>
@@ -550,8 +551,29 @@ asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv,
550551
asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
551552

552553
extern int get_compat_sigset(sigset_t *set, const compat_sigset_t __user *compat);
553-
extern int put_compat_sigset(compat_sigset_t __user *compat,
554-
const sigset_t *set, unsigned int size);
554+
555+
/*
556+
* Defined inline such that size can be compile time constant, which avoids
557+
* CONFIG_HARDENED_USERCOPY complaining about copies from task_struct
558+
*/
559+
static inline int
560+
put_compat_sigset(compat_sigset_t __user *compat, const sigset_t *set,
561+
unsigned int size)
562+
{
563+
/* size <= sizeof(compat_sigset_t) <= sizeof(sigset_t) */
564+
#ifdef __BIG_ENDIAN
565+
compat_sigset_t v;
566+
switch (_NSIG_WORDS) {
567+
case 4: v.sig[7] = (set->sig[3] >> 32); v.sig[6] = set->sig[3];
568+
case 3: v.sig[5] = (set->sig[2] >> 32); v.sig[4] = set->sig[2];
569+
case 2: v.sig[3] = (set->sig[1] >> 32); v.sig[2] = set->sig[1];
570+
case 1: v.sig[1] = (set->sig[0] >> 32); v.sig[0] = set->sig[0];
571+
}
572+
return copy_to_user(compat, &v, size) ? -EFAULT : 0;
573+
#else
574+
return copy_to_user(compat, set, size) ? -EFAULT : 0;
575+
#endif
576+
}
555577

556578
asmlinkage long compat_sys_migrate_pages(compat_pid_t pid,
557579
compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes,

kernel/compat.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -488,25 +488,6 @@ get_compat_sigset(sigset_t *set, const compat_sigset_t __user *compat)
488488
}
489489
EXPORT_SYMBOL_GPL(get_compat_sigset);
490490

491-
int
492-
put_compat_sigset(compat_sigset_t __user *compat, const sigset_t *set,
493-
unsigned int size)
494-
{
495-
/* size <= sizeof(compat_sigset_t) <= sizeof(sigset_t) */
496-
#ifdef __BIG_ENDIAN
497-
compat_sigset_t v;
498-
switch (_NSIG_WORDS) {
499-
case 4: v.sig[7] = (set->sig[3] >> 32); v.sig[6] = set->sig[3];
500-
case 3: v.sig[5] = (set->sig[2] >> 32); v.sig[4] = set->sig[2];
501-
case 2: v.sig[3] = (set->sig[1] >> 32); v.sig[2] = set->sig[1];
502-
case 1: v.sig[1] = (set->sig[0] >> 32); v.sig[0] = set->sig[0];
503-
}
504-
return copy_to_user(compat, &v, size) ? -EFAULT : 0;
505-
#else
506-
return copy_to_user(compat, set, size) ? -EFAULT : 0;
507-
#endif
508-
}
509-
510491
#ifdef CONFIG_NUMA
511492
COMPAT_SYSCALL_DEFINE6(move_pages, pid_t, pid, compat_ulong_t, nr_pages,
512493
compat_uptr_t __user *, pages32,

0 commit comments

Comments
 (0)