Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2502866imm; Mon, 24 Sep 2018 05:34:10 -0700 (PDT) X-Google-Smtp-Source: ACcGV61G/bklzD2IG00qrWrbaZKptJSt4zZVIeBc1rE0rclTdZLHi61jwmBwJCTQK217wbWZ7IKf X-Received: by 2002:a65:4242:: with SMTP id d2-v6mr8437805pgq.265.1537792450011; Mon, 24 Sep 2018 05:34:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537792449; cv=none; d=google.com; s=arc-20160816; b=qMpy1Dm9GJoqL2uyEg3HExoS7NIctZzELjNCVUhiN2jdkOVraYyymtTD9KZlfrQHgE Lu2tU9DCKfUPtkcLwdtBdnp+fJMFxBt21VKnNU4JVTSuqiZA1mbAhDlHf+fGsNieg91r qK8bS45PCHBYav2oT0AKqsZIZE2kAtAEPOG4KNhXHRU1kVNmx+rAZuvm2xFZLIxBJNhw wNHHXWvgPSwN+13cNxk/WPRoSOPdS0wvZkUn3sJWHSakcUlRRaGUed2modbIX8Pfsb3W HZfI453ALleTaOqxkJuhWBkIk7o6Nkop3VxkF+fLAP6HMHRMWZbA1OEDP9GAUUWpTr8q qp5Q== 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; bh=pz3NO5/t5JyIAJ5dxiYO7HSDOaFtubHQ9cVdCTHEnhc=; b=mCppl5j54nPoioJYbsG2qLdX4611/IIulGAhK95T3kl2uS20Z1DQUK7DAYazuiQ5Gq I6KTFtu1y6L3stKwyNETJqC44i6pdSdcOZcmRSBNYInvBnBkF62/f5YAAtpgRCekJ4pi WkThCm3zjd77SVeh6kJ+Di6pY1NAiCTU8jtczDQofOEYwwoGqDjwxeqKDCBSTxGX8Gk+ SNhKZxHtJfbN42ZijaLTuGsBn73gO4Zt6iJTicD1lla++H7YhPNfBytw58P6QFQCaG2K EXqy10MCtfkhunliivokWBJ9YNIQi/oiAca0PDjz8MS6F47q7pMlvj9FNxxslGSSpI69 GcdA== ARC-Authentication-Results: i=1; mx.google.com; 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 h6-v6si32472918pls.150.2018.09.24.05.33.54; Mon, 24 Sep 2018 05:34:09 -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; 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 S2388255AbeIXSez (ORCPT + 99 others); Mon, 24 Sep 2018 14:34:55 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58320 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388231AbeIXSey (ORCPT ); Mon, 24 Sep 2018 14:34:54 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 5AC381018; Mon, 24 Sep 2018 12:32:59 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julian Wiedmann , "David S. Miller" , Sasha Levin Subject: [PATCH 4.18 082/235] s390/qeth: fix race in used-buffer accounting Date: Mon, 24 Sep 2018 13:51:08 +0200 Message-Id: <20180924113113.242696894@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Julian Wiedmann [ Upstream commit a702349a4099cd5a7bab0904689d8e0bf8dcd622 ] By updating q->used_buffers only _after_ do_QDIO() has completed, there is a potential race against the buffer's TX completion. In the unlikely case that the TX completion path wins, qeth_qdio_output_handler() would decrement the counter before qeth_flush_buffers() even incremented it. Signed-off-by: Julian Wiedmann Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/s390/net/qeth_core_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -3530,13 +3530,14 @@ static void qeth_flush_buffers(struct qe qdio_flags = QDIO_FLAG_SYNC_OUTPUT; if (atomic_read(&queue->set_pci_flags_count)) qdio_flags |= QDIO_FLAG_PCI_OUT; + atomic_add(count, &queue->used_buffers); + rc = do_QDIO(CARD_DDEV(queue->card), qdio_flags, queue->queue_no, index, count); if (queue->card->options.performance_stats) queue->card->perf_stats.outbound_do_qdio_time += qeth_get_micros() - queue->card->perf_stats.outbound_do_qdio_start_time; - atomic_add(count, &queue->used_buffers); if (rc) { queue->card->stats.tx_errors += count; /* ignore temporary SIGA errors without busy condition */