Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp672787img; Fri, 22 Mar 2019 06:19:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyODoHGGk05mgQDN0aLcyC7+kD4QjbhB/YWEXC3TyF9ao0LK99pDdejHwq2PrHCqqK6IZXO X-Received: by 2002:a65:648f:: with SMTP id e15mr8901201pgv.249.1553260776058; Fri, 22 Mar 2019 06:19:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553260776; cv=none; d=google.com; s=arc-20160816; b=QpMJrYTJs1lT0+evrZOZ3aUiTOwRKu0FRYWeavsZRt0s3I+VQlCQUhzKeV1V80ogCh LSd06EgOAlhgLyit8q6k+fzs6vJGpN5Q4MhzbSXH4oDVVMsamv9YBLClSbB1rC5WI2aU r0RRHaPObaLahERCjbP4weKI1IMfSWhe/GvmKRHLSXgC6Wi830fM1DL+ahOV+VV2XJg+ hZBogs7gNQ/LsojEOKBD9CSRXlnE5CmwrtOB/TUjvPUnTpwo8sNXfFrx5PrzU1SwxYWJ P9qAvZhPOpMFOp8sSAAj8UabR2VaicZ7sYhT6wGab98JeKk1H2Y75grdOf8RCIc1VJUr kCHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aAfmcttcDYd4dQkkh7K4OTZiWsK4QOs8QejTUBjLCD8=; b=dt9PqMmBCYN937cmhfaJxs+3FujFIJa4MIg3f28nrWb4lRVwV+kI48SxnJCQPzgAFx LenDfrrKaBhWh8x8D0sy9znZMOtwMLm1Luh51bY5N/1//gU1I99hTk8s2x1L4JtlnTHS D2GUmPQTL5DNv1pLaj2B0rM49kAe2ASAwnuiRE+6WZwHEySCHp/wyiRzgk/EEc2NuAAf LU8pYYsVIQER704fPHRdFz5sD+Ka3e3bkNeq8mks+ZKRNmTPqAa+I1Jryic2O0pHgNHo RsQVJ2law52sxdCF17oNogM2lUoFlTZ+s8ZdPSceQnEGd1xuVHXCbEMTKZkX4MWNPsp4 VN4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FlEnQLDx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n12si6518462pgp.165.2019.03.22.06.19.20; Fri, 22 Mar 2019 06:19:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FlEnQLDx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728959AbfCVLXY (ORCPT + 99 others); Fri, 22 Mar 2019 07:23:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:50226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728946AbfCVLXS (ORCPT ); Fri, 22 Mar 2019 07:23:18 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6AC7C218D4; Fri, 22 Mar 2019 11:23:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553253797; bh=rPO+3wBoT77RZ8MlX+97o8Fy0qGhAcUACyAQwytCeAg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FlEnQLDxJVhnbHOwHhucmjWnK4JYIEXXqr/pohxc+CkoCfSwawVbqgZKRKpInfSRx BcJcWJrIKl0qMmwez16GFMpfMHsR7ObyCibHItnCyVSWdDhFPx55CSbAOEPD+PQJ5b sI4wQ2H6NSIu+PynYywyVDH3vxZXZi/glP7GYkIA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julian Wiedmann , Alexandra Winter , "David S. Miller" , Sasha Levin Subject: [PATCH 3.18 075/134] s390/qeth: fix use-after-free in error path Date: Fri, 22 Mar 2019 12:14:48 +0100 Message-Id: <20190322111215.509030089@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111210.465931067@linuxfoundation.org> References: <20190322111210.465931067@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit afa0c5904ba16d59b0454f7ee4c807dae350f432 ] The error path in qeth_alloc_qdio_buffers() that takes care of cleaning up the Output Queues is buggy. It first frees the queue, but then calls qeth_clear_outq_buffers() with that very queue struct. Make the call to qeth_clear_outq_buffers() part of the free action (in the correct order), and while at it fix the naming of the helper. Fixes: 0da9581ddb0f ("qeth: exploit asynchronous delivery of storage blocks") Signed-off-by: Julian Wiedmann Reviewed-by: Alexandra Winter Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/s390/net/qeth_core_main.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 2ac6d6665834..a874b821d239 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -2423,11 +2423,12 @@ static int qeth_init_qdio_out_buf(struct qeth_qdio_out_q *q, int bidx) return rc; } -static void qeth_free_qdio_out_buf(struct qeth_qdio_out_q *q) +static void qeth_free_output_queue(struct qeth_qdio_out_q *q) { if (!q) return; + qeth_clear_outq_buffers(q, 1); qdio_free_buffers(q->qdio_bufs, QDIO_MAX_BUFFERS_PER_Q); kfree(q); } @@ -2500,10 +2501,8 @@ static int qeth_alloc_qdio_buffers(struct qeth_card *card) card->qdio.out_qs[i]->bufs[j] = NULL; } out_freeoutq: - while (i > 0) { - qeth_free_qdio_out_buf(card->qdio.out_qs[--i]); - qeth_clear_outq_buffers(card->qdio.out_qs[i], 1); - } + while (i > 0) + qeth_free_output_queue(card->qdio.out_qs[--i]); kfree(card->qdio.out_qs); card->qdio.out_qs = NULL; out_freepool: @@ -2536,10 +2535,8 @@ static void qeth_free_qdio_buffers(struct qeth_card *card) qeth_free_buffer_pool(card); /* free outbound qdio_qs */ if (card->qdio.out_qs) { - for (i = 0; i < card->qdio.no_out_queues; ++i) { - qeth_clear_outq_buffers(card->qdio.out_qs[i], 1); - qeth_free_qdio_out_buf(card->qdio.out_qs[i]); - } + for (i = 0; i < card->qdio.no_out_queues; i++) + qeth_free_output_queue(card->qdio.out_qs[i]); kfree(card->qdio.out_qs); card->qdio.out_qs = NULL; } -- 2.19.1