summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Wellving <andreas.wellving@enea.com>2019-07-10 11:03:10 +0200
committerAdrian Stratulat <adrian.stratulat@enea.com>2019-07-12 14:12:49 +0200
commit86b3d79e95edbf9d95f39717ec4d03503c34fe4d (patch)
treed1268dde3591ef8a6b938d3026577878aa6ac7f4
parent3250015618781f92395eed977f46421d9845c7db (diff)
downloadenea-kernel-cache-86b3d79e95edbf9d95f39717ec4d03503c34fe4d.tar.gz
scsi: CVE-2018-20836
scsi: libsas: fix a race condition when smp task timeout References: https://nvd.nist.gov/vuln/detail/CVE-2018-20836 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.9.y&id=41b5d3eee4af6a4ea488a1735ed82e4e593eec0d Change-Id: Ia6fdf5358291e2e803c8795607759ad553ac9271 Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
-rw-r--r--patches/cve/4.9.x.scc3
-rw-r--r--patches/cve/CVE-2018-20836-scsi-libsas-fix-a-race-condition-when-smp-task-timeo.patch71
2 files changed, 74 insertions, 0 deletions
diff --git a/patches/cve/4.9.x.scc b/patches/cve/4.9.x.scc
index 8748db7..76d3db0 100644
--- a/patches/cve/4.9.x.scc
+++ b/patches/cve/4.9.x.scc
@@ -40,3 +40,6 @@ patch CVE-2019-8980-exec-Fix-mem-leak-in-kernel_read_file.patch
40 40
41#CVEs fixed in 4.9.169: 41#CVEs fixed in 4.9.169:
42patch CVE-2019-11815-net-rds-force-to-destroy-connection-if-t_sock-is-NUL.patch 42patch CVE-2019-11815-net-rds-force-to-destroy-connection-if-t_sock-is-NUL.patch
43
44#CVEs fixed in 4.9.175:
45patch CVE-2018-20836-scsi-libsas-fix-a-race-condition-when-smp-task-timeo.patch
diff --git a/patches/cve/CVE-2018-20836-scsi-libsas-fix-a-race-condition-when-smp-task-timeo.patch b/patches/cve/CVE-2018-20836-scsi-libsas-fix-a-race-condition-when-smp-task-timeo.patch
new file mode 100644
index 0000000..dc9f8f8
--- /dev/null
+++ b/patches/cve/CVE-2018-20836-scsi-libsas-fix-a-race-condition-when-smp-task-timeo.patch
@@ -0,0 +1,71 @@
1From 41b5d3eee4af6a4ea488a1735ed82e4e593eec0d Mon Sep 17 00:00:00 2001
2From: Jason Yan <yanaijie@huawei.com>
3Date: Tue, 25 Sep 2018 10:56:54 +0800
4Subject: [PATCH] scsi: libsas: fix a race condition when smp task timeout
5
6commit b90cd6f2b905905fb42671009dc0e27c310a16ae upstream.
7
8When the lldd is processing the complete sas task in interrupt and set the
9task stat as SAS_TASK_STATE_DONE, the smp timeout timer is able to be
10triggered at the same time. And smp_task_timedout() will complete the task
11wheter the SAS_TASK_STATE_DONE is set or not. Then the sas task may freed
12before lldd end the interrupt process. Thus a use-after-free will happen.
13
14Fix this by calling the complete() only when SAS_TASK_STATE_DONE is not
15set. And remove the check of the return value of the del_timer(). Once the
16LLDD sets DONE, it must call task->done(), which will call
17smp_task_done()->complete() and the task will be completed and freed
18correctly.
19
20CVE: CVE-2018-20836
21Upstream-Status: Backport [https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.9.y&id=41b5d3eee4af6a4ea488a1735ed82e4e593eec0d]
22
23Reported-by: chenxiang <chenxiang66@hisilicon.com>
24Signed-off-by: Jason Yan <yanaijie@huawei.com>
25CC: John Garry <john.garry@huawei.com>
26CC: Johannes Thumshirn <jthumshirn@suse.de>
27CC: Ewan Milne <emilne@redhat.com>
28CC: Christoph Hellwig <hch@lst.de>
29CC: Tomas Henzl <thenzl@redhat.com>
30CC: Dan Williams <dan.j.williams@intel.com>
31CC: Hannes Reinecke <hare@suse.com>
32Reviewed-by: Hannes Reinecke <hare@suse.com>
33Reviewed-by: John Garry <john.garry@huawei.com>
34Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
35Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
36Cc: Guenter Roeck <linux@roeck-us.net
37Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
38Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
39---
40 drivers/scsi/libsas/sas_expander.c | 9 ++++-----
41 1 file changed, 4 insertions(+), 5 deletions(-)
42
43diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
44index 7be581f7c35d..1a6f65db615e 100644
45--- a/drivers/scsi/libsas/sas_expander.c
46+++ b/drivers/scsi/libsas/sas_expander.c
47@@ -47,17 +47,16 @@ static void smp_task_timedout(unsigned long _task)
48 unsigned long flags;
49
50 spin_lock_irqsave(&task->task_state_lock, flags);
51- if (!(task->task_state_flags & SAS_TASK_STATE_DONE))
52+ if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) {
53 task->task_state_flags |= SAS_TASK_STATE_ABORTED;
54+ complete(&task->slow_task->completion);
55+ }
56 spin_unlock_irqrestore(&task->task_state_lock, flags);
57-
58- complete(&task->slow_task->completion);
59 }
60
61 static void smp_task_done(struct sas_task *task)
62 {
63- if (!del_timer(&task->slow_task->timer))
64- return;
65+ del_timer(&task->slow_task->timer);
66 complete(&task->slow_task->completion);
67 }
68
69--
702.20.1
71