From patchwork Fri Jul 31 09:26:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11694573 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA4041392 for ; Fri, 31 Jul 2020 09:38:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 70D4C20829 for ; Fri, 31 Jul 2020 09:38:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=web.de header.i=@web.de header.b="i3GwPA/l" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70D4C20829 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=web.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:33908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1RV6-0007yp-IF for patchwork-qemu-devel@patchwork.kernel.org; Fri, 31 Jul 2020 05:38:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1RJZ-0007hp-Nv; Fri, 31 Jul 2020 05:26:58 -0400 Received: from mout.web.de ([212.227.15.4]:48459) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1RJX-0003H8-FI; Fri, 31 Jul 2020 05:26:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1596187610; bh=7v/Mv0F5waUUMT/mHpp598uQEuJxOezfSzawUfXZvyU=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=i3GwPA/lZ+CV2VmYt/ISKai+dXHY+N3dmPBj8e6yEDQShWMUoo67bK14XSVERVAjn d2mL+cDMFWhcSaY2gN0VIGoBr6wqFQiGjjCKXyOrT1QcXDY6XiTNjyq07f4O2YhRKL hzSZ3AEtdsp89zPUo7gfwc/Le7ouj0hv/dGf+0KU= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([88.130.61.42]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1M91LW-1k6PO81z4o-006AMq; Fri, 31 Jul 2020 11:26:50 +0200 Date: Fri, 31 Jul 2020 11:26:49 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v6 5/9] io/channel-tls.c: make qio_channel_tls_shutdown thread-safe Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:3oBWF9KpN6NLJMkfUcQJJaqq1/J8stWp7K7+rPwYLgnffevZjCi EM05jsyLChGltRbG9HdPzthPtNxXAj/i/Iyup+TgUVyqJKG4Z5IXLtDHI1QIaeSQtMV//fO gJP9eve9xgKQ0lExQomQAB5WV3RHA2Nx4hfTnCfSqgjQ1aUUU41nndobvmKfyP7q/GLk94L ZpGysaK5pJuDmlWu/Ok5w== X-UI-Out-Filterresults: notjunk:1;V03:K0:pk9OdU03prE=:ZCQwh0CnBWXyZ75pCWVyE0 5pgEqVJumIGTIScoTDKenXVpKUAM0Wjm928gJYeayHqgKfutqtAg94jdH17VBSvKc216WKsEN J7fEHpR1gld4ll/yxuAH3z4Sz6ZKnAVObfl27NEExtZQ4CRX4guDjH6rzcxzqm7jWz9O5gcHT yZkWkMevOCa6W0DUdUCEQUMwTKR6S4ItZ9KQkQvBWjhQ/q6WLQ+UKh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1vw== Received-SPF: pass client-ip=212.227.15.4; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/31 05:26:39 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , "Daniel P. =?utf-8?b?QmVycmFuZ8Op?= " , qemu-block , Juan Quintela , "Dr. David Alan Gilbert" , Max Reitz , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9?= Lureau Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Make qio_channel_tls_shutdown thread-safe by using atomics when accessing tioc->shutdown. Signed-off-by: Lukas Straub Reviewed-by: Daniel P. Berrangé Acked-by: Stefan Hajnoczi --- io/channel-tls.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/io/channel-tls.c b/io/channel-tls.c index 7ec8ceff2f..b350c84640 100644 --- a/io/channel-tls.c +++ b/io/channel-tls.c @@ -23,6 +23,7 @@ #include "qemu/module.h" #include "io/channel-tls.h" #include "trace.h" +#include "qemu/atomic.h" static ssize_t qio_channel_tls_write_handler(const char *buf, @@ -277,7 +278,8 @@ static ssize_t qio_channel_tls_readv(QIOChannel *ioc, return QIO_CHANNEL_ERR_BLOCK; } } else if (errno == ECONNABORTED && - (tioc->shutdown & QIO_CHANNEL_SHUTDOWN_READ)) { + (atomic_load_acquire(&tioc->shutdown) & + QIO_CHANNEL_SHUTDOWN_READ)) { return 0; } @@ -361,7 +363,7 @@ static int qio_channel_tls_shutdown(QIOChannel *ioc, { QIOChannelTLS *tioc = QIO_CHANNEL_TLS(ioc); - tioc->shutdown |= how; + atomic_or(&tioc->shutdown, how); return qio_channel_shutdown(tioc->master, how, errp); }