]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.32.17/scsi-aacraid-eliminate-use-after-free.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.32.17 / scsi-aacraid-eliminate-use-after-free.patch
1 From 8a52da632ceb9d8b776494563df579e87b7b586b Mon Sep 17 00:00:00 2001
2 From: Julia Lawall <julia@diku.dk>
3 Date: Sat, 15 May 2010 11:46:12 +0200
4 Subject: SCSI: aacraid: Eliminate use after free
5
6 From: Julia Lawall <julia@diku.dk>
7
8 commit 8a52da632ceb9d8b776494563df579e87b7b586b upstream.
9
10 The debugging code using the freed structure is moved before the kfree.
11
12 A simplified version of the semantic match that finds this problem is as
13 follows: (http://coccinelle.lip6.fr/)
14
15 // <smpl>
16 @free@
17 expression E;
18 position p;
19 @@
20 kfree@p(E)
21
22 @@
23 expression free.E, subE<=free.E, E1;
24 position free.p;
25 @@
26
27 kfree@p(E)
28 ...
29 (
30 subE = E1
31 |
32 * E
33 )
34 // </smpl>
35
36 Signed-off-by: Julia Lawall <julia@diku.dk>
37 Signed-off-by: James Bottomley <James.Bottomley@suse.de>
38
39 ---
40 drivers/scsi/aacraid/commctrl.c | 4 ++--
41 1 file changed, 2 insertions(+), 2 deletions(-)
42
43 --- a/drivers/scsi/aacraid/commctrl.c
44 +++ b/drivers/scsi/aacraid/commctrl.c
45 @@ -655,9 +655,9 @@ static int aac_send_raw_srb(struct aac_d
46 /* Does this really need to be GFP_DMA? */
47 p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA);
48 if(!p) {
49 - kfree (usg);
50 - dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
51 + dprintk((KERN_DEBUG "aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
52 usg->sg[i].count,i,usg->count));
53 + kfree(usg);
54 rcode = -ENOMEM;
55 goto cleanup;
56 }