]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.1/ib-hfi1-validate-fault-injection-opcode-user-input.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / queue-5.1 / ib-hfi1-validate-fault-injection-opcode-user-input.patch
1 From 5f90677ed31963abb184ee08ebee4a4a68225dd8 Mon Sep 17 00:00:00 2001
2 From: Kaike Wan <kaike.wan@intel.com>
3 Date: Fri, 7 Jun 2019 08:25:25 -0400
4 Subject: IB/hfi1: Validate fault injection opcode user input
5
6 From: Kaike Wan <kaike.wan@intel.com>
7
8 commit 5f90677ed31963abb184ee08ebee4a4a68225dd8 upstream.
9
10 The opcode range for fault injection from user should be validated before
11 it is applied to the fault->opcodes[] bitmap to avoid out-of-bound
12 error.
13
14 Cc: <stable@vger.kernel.org>
15 Fixes: a74d5307caba ("IB/hfi1: Rework fault injection machinery")
16 Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
17 Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
18 Signed-off-by: Kaike Wan <kaike.wan@intel.com>
19 Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
20 Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
21 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22
23 ---
24 drivers/infiniband/hw/hfi1/fault.c | 5 +++++
25 1 file changed, 5 insertions(+)
26
27 --- a/drivers/infiniband/hw/hfi1/fault.c
28 +++ b/drivers/infiniband/hw/hfi1/fault.c
29 @@ -153,6 +153,7 @@ static ssize_t fault_opcodes_write(struc
30 char *dash;
31 unsigned long range_start, range_end, i;
32 bool remove = false;
33 + unsigned long bound = 1U << BITS_PER_BYTE;
34
35 end = strchr(ptr, ',');
36 if (end)
37 @@ -178,6 +179,10 @@ static ssize_t fault_opcodes_write(struc
38 BITS_PER_BYTE);
39 break;
40 }
41 + /* Check the inputs */
42 + if (range_start >= bound || range_end >= bound)
43 + break;
44 +
45 for (i = range_start; i <= range_end; i++) {
46 if (remove)
47 clear_bit(i, fault->opcodes);