]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
s390/qdio: fix access to uninitialized qdio_q fields
authorJulian Wiedmann <jwi@linux.ibm.com>
Wed, 2 May 2018 06:48:43 +0000 (08:48 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Tue, 15 May 2018 05:40:36 +0000 (07:40 +0200)
Ever since CQ/QAOB support was added, calling qdio_free() straight after
qdio_alloc() results in qdio_release_memory() accessing uninitialized
memory (ie. q->u.out.use_cq and q->u.out.aobs). Followed by a
kmem_cache_free() on the random AOB addresses.

For older kernels that don't have 6e30c549f6ca, the same applies if
qdio_establish() fails in the DEV_STATE_ONLINE check.

While initializing q->u.out.use_cq would be enough to fix this
particular bug, the more future-proof change is to just zero-alloc the
whole struct.

Fixes: 104ea556ee7f ("qdio: support asynchronous delivery of storage blocks")
Cc: <stable@vger.kernel.org> #v3.2+
Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/cio/qdio_setup.c

index 439991d71b146698c90540c5633cfdd0fbe1bc16..22ddb49e0f50043c14b891a6f6511f6d7c4cca6e 100644 (file)
@@ -141,7 +141,7 @@ static int __qdio_allocate_qs(struct qdio_q **irq_ptr_qs, int nr_queues)
        int i;
 
        for (i = 0; i < nr_queues; i++) {
-               q = kmem_cache_alloc(qdio_q_cache, GFP_KERNEL);
+               q = kmem_cache_zalloc(qdio_q_cache, GFP_KERNEL);
                if (!q)
                        return -ENOMEM;