Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp912983ybl; Fri, 24 Jan 2020 11:51:36 -0800 (PST) X-Google-Smtp-Source: APXvYqw7mslaG+fTw5KNShEOTTyjgqcD4NaghGRmq6fW0iW2RlaFdcEw/whtd9o53LDJOFcK0nio X-Received: by 2002:aca:fdd1:: with SMTP id b200mr314662oii.133.1579895496568; Fri, 24 Jan 2020 11:51:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579895496; cv=none; d=google.com; s=arc-20160816; b=YdLIs+OXV4OzJDGcwW4V3Zz/9MOgRK0OCh2usSNLpbGvctF2R0wQ007BE6C+Cz8Itl NVBS9v32Uw3FcPRKGwFujjNlGMCxxGbsRTT7RiQv2Aw60p/NgfzxMpRB967X2Ihy5TwY M8DQIDpJOYXSYyF1aoSoLfW6FILzT2q9CySvMS5lYjIFY5j2JN/k2JcIXtIlHcdm58L9 V5ssTNzTuLAiIPmvjTcARWBQZ2Z7o6kV2dW5utXNkR0Uep6CfFH/xn/h8YoLcZmWTBeb TSRJguhq368eY1jep+MEI2olXU6trxJK2+q19GJbVbeSP8ZX6glpmkToKCaBNcXp9iuO okRw== 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=QjVqJ2V6tUUOVXggcVG5N6/ahzcymBp6o4FoMgmFbD0=; b=Ir87M8LTfTDj7X7oQ4y7uTwleWg65W2vtxRahEaQcLaNxBOLQh6HKouOhzhicNO1YW vCxOc4iqC6lQozWDDl2jvlystH+55JLJ7HdLl+A/T5M8SMoKjz1YP5jnRplWq6re9K6I fp8eV15gzMwkXvlVdIj5mN+eXI7D2VYs/kmGKimdZX0jR8ctQ87ZuB0JH6YPlDDKaW0g zzw7mMdnO6JRkUsgdcmYyLwupraGpPiZCrsbFXs8gzTnPpOrNO15R74IeKNsLsuok+HV CA9x0cHCrEXWMUxCb5wm8mlrAzAlihBwS3hfK+KXDwRPWFaLJKB3AXDH3xCzDJ3TIAf1 XWBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=whpvaHrR; 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 v24si3366604otq.87.2020.01.24.11.51.23; Fri, 24 Jan 2020 11:51:36 -0800 (PST) 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=whpvaHrR; 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 S2404775AbgAXLe6 (ORCPT + 99 others); Fri, 24 Jan 2020 06:34:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:54802 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404554AbgAXLex (ORCPT ); Fri, 24 Jan 2020 06:34:53 -0500 Received: from localhost (ip-213-127-102-57.ip.prioritytelecom.net [213.127.102.57]) (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 CBC6C214AF; Fri, 24 Jan 2020 11:34:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579865692; bh=RnK0clrflBBggThoG4uISv/QqeNSFR3wcuNyFj/d9vg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=whpvaHrRJK0YZzNXMDAbZHp7dF2TfwCH/RqVqCCqUqQ2yIPw8HifO+2WG9uasmLUN 6hCcZ9kHZ3LZ3Mp1I3eiMP5ZpW2y6oBlFJ92ff4sSS3lc5QeZMZ3HRbIabYRo9H3Fj +brR/tOFPfOK4YHdYfjMURd/qKW522f+cUJb5/z0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Jakub Kicinski , Sasha Levin Subject: [PATCH 4.19 600/639] net: add {READ|WRITE}_ONCE() annotations on ->rskq_accept_head Date: Fri, 24 Jan 2020 10:32:50 +0100 Message-Id: <20200124093204.549014591@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124093047.008739095@linuxfoundation.org> References: <20200124093047.008739095@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Eric Dumazet [ Upstream commit 60b173ca3d1cd1782bd0096dc17298ec242f6fb1 ] reqsk_queue_empty() is called from inet_csk_listen_poll() while other cpus might write ->rskq_accept_head value. Use {READ|WRITE}_ONCE() to avoid compiler tricks and potential KCSAN splats. Fixes: fff1f3001cc5 ("tcp: add a spinlock to protect struct request_sock_queue") Signed-off-by: Eric Dumazet Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/xen/pvcalls-back.c | 2 +- include/net/request_sock.h | 4 ++-- net/ipv4/inet_connection_sock.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/xen/pvcalls-back.c b/drivers/xen/pvcalls-back.c index d4ea33581ac26..b3fbfed28682f 100644 --- a/drivers/xen/pvcalls-back.c +++ b/drivers/xen/pvcalls-back.c @@ -784,7 +784,7 @@ static int pvcalls_back_poll(struct xenbus_device *dev, mappass->reqcopy = *req; icsk = inet_csk(mappass->sock->sk); queue = &icsk->icsk_accept_queue; - data = queue->rskq_accept_head != NULL; + data = READ_ONCE(queue->rskq_accept_head) != NULL; if (data) { mappass->reqcopy.cmd = 0; ret = 0; diff --git a/include/net/request_sock.h b/include/net/request_sock.h index 347015515a7de..1653435f18f5c 100644 --- a/include/net/request_sock.h +++ b/include/net/request_sock.h @@ -183,7 +183,7 @@ void reqsk_fastopen_remove(struct sock *sk, struct request_sock *req, static inline bool reqsk_queue_empty(const struct request_sock_queue *queue) { - return queue->rskq_accept_head == NULL; + return READ_ONCE(queue->rskq_accept_head) == NULL; } static inline struct request_sock *reqsk_queue_remove(struct request_sock_queue *queue, @@ -195,7 +195,7 @@ static inline struct request_sock *reqsk_queue_remove(struct request_sock_queue req = queue->rskq_accept_head; if (req) { sk_acceptq_removed(parent); - queue->rskq_accept_head = req->dl_next; + WRITE_ONCE(queue->rskq_accept_head, req->dl_next); if (queue->rskq_accept_head == NULL) queue->rskq_accept_tail = NULL; } diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index 636a11c56cf5a..79320858e7196 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -937,7 +937,7 @@ struct sock *inet_csk_reqsk_queue_add(struct sock *sk, req->sk = child; req->dl_next = NULL; if (queue->rskq_accept_head == NULL) - queue->rskq_accept_head = req; + WRITE_ONCE(queue->rskq_accept_head, req); else queue->rskq_accept_tail->dl_next = req; queue->rskq_accept_tail = req; -- 2.20.1