Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3922612pxb; Mon, 4 Oct 2021 12:43:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgWoMpN76UWCzqvLwLJtnPw/TuqZS3qT2hFGWVrr7Li7R0QzXmdT0JuvQWJNgqOyF23RlM X-Received: by 2002:aa7:d9c3:: with SMTP id v3mr3950195eds.381.1633376619774; Mon, 04 Oct 2021 12:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633376619; cv=none; d=google.com; s=arc-20160816; b=WcEIuUWzhxPOgFs+5Uu1TMjPjf15MIX5WOlXomUeiLP1Z+KrhGGXbKpZxlvb1njPws 6dJBjtMRDZrV9MldyXUKWJmQC1xK7yBBBOhPDPnzUGqZj/DQBjk95Gvpr8E39WsycWLa zjl4Pqf5pgPLesm3KxX/gpbh4BoRf3hQ3Q6V5uYrG97xaZZQHNxdYxbrgUWmC0SFhsuc R5j/JvPbtsKqlibiVj75pFvTAwGRc5ycnwAkX3eWmjA7Cm+ZSTqlziiKqhEakg2vafkk gUE015DufpVaOLsUwlje+FnjGv3Bb9SrE2Uqen9wD8FiBaOsFo0M4ysixU9ihu11fg0G mxfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fD2jO1Ak4j9ZPF0Yj6ZsIA+FdmjX/1Y27jPepKD/Ci0=; b=v/lY0gnA6AxjezCYWPdgLfaAjIzPQ9X445hOtJt8HNq9xyfSySqq7iuETKEI1h8fJR 1U8TSxJxLUIvJrUApAfsqVLc7pdgfrQITbYG1FRZSC19MRsRdHyEJKISXon61ZMtDJUC YjzfU389tKAdh8KESQwf/hm3m2Nw44BAh1CrWvJwQFajjaco5Qw3+PsSdrmAIBQVUdQa iISZm14ve/+JSsQYHIFtf6cIx4F/rUtjrt9+lPq6A5IdBudcmKSQ1SzfANFrw6VuzUly W8dJmBqow8WCKdEoFMh0Y8aZqdyyE1U5qQZb+6slCE5WYdx86zJ2ubxOPkHJ8LZDuhFB Nzbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sfa4rSJ8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d3si19450217ejr.27.2021.10.04.12.43.16; Mon, 04 Oct 2021 12:43:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sfa4rSJ8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234941AbhJDNHQ (ORCPT + 99 others); Mon, 4 Oct 2021 09:07:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:39242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234934AbhJDNE4 (ORCPT ); Mon, 4 Oct 2021 09:04:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B44866137D; Mon, 4 Oct 2021 13:00:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633352436; bh=I4twkpA9yWUE5pIM4QzxI3aYM2GteOuhlVOrWPQ8iKs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sfa4rSJ8ch3I4KIxP4k8OywEDkGwjiAxVoo1z6CMIHYY/+OnMBxTOfx44xo4dVD40 xLtYcyfese0HmbopJb2LSvSYtjz/cZMV6avTlj+WuQzm9RqBEkHyW+fGrrNFHOuISN SZtwQ3CazfDzj4UigiOTxP4XrKpNToSyd3lo3nH0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , "David S. Miller" Subject: [PATCH 4.14 61/75] net: udp: annotate data race around udp_sk(sk)->corkflag Date: Mon, 4 Oct 2021 14:52:36 +0200 Message-Id: <20211004125033.575737377@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125031.530773667@linuxfoundation.org> References: <20211004125031.530773667@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet commit a9f5970767d11eadc805d5283f202612c7ba1f59 upstream. up->corkflag field can be read or written without any lock. Annotate accesses to avoid possible syzbot/KCSAN reports. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/udp.c | 10 +++++----- net/ipv6/udp.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -882,7 +882,7 @@ int udp_sendmsg(struct sock *sk, struct __be16 dport; u8 tos; int err, is_udplite = IS_UDPLITE(sk); - int corkreq = up->corkflag || msg->msg_flags&MSG_MORE; + int corkreq = READ_ONCE(up->corkflag) || msg->msg_flags&MSG_MORE; int (*getfrag)(void *, char *, int, int, int, struct sk_buff *); struct sk_buff *skb; struct ip_options_data opt_copy; @@ -1165,7 +1165,7 @@ int udp_sendpage(struct sock *sk, struct } up->len += size; - if (!(up->corkflag || (flags&MSG_MORE))) + if (!(READ_ONCE(up->corkflag) || (flags&MSG_MORE))) ret = udp_push_pending_frames(sk); if (!ret) ret = size; @@ -2373,9 +2373,9 @@ int udp_lib_setsockopt(struct sock *sk, switch (optname) { case UDP_CORK: if (val != 0) { - up->corkflag = 1; + WRITE_ONCE(up->corkflag, 1); } else { - up->corkflag = 0; + WRITE_ONCE(up->corkflag, 0); lock_sock(sk); push_pending_frames(sk); release_sock(sk); @@ -2482,7 +2482,7 @@ int udp_lib_getsockopt(struct sock *sk, switch (optname) { case UDP_CORK: - val = up->corkflag; + val = READ_ONCE(up->corkflag); break; case UDP_ENCAP: --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -1135,7 +1135,7 @@ int udpv6_sendmsg(struct sock *sk, struc struct ipcm6_cookie ipc6; int addr_len = msg->msg_namelen; int ulen = len; - int corkreq = up->corkflag || msg->msg_flags&MSG_MORE; + int corkreq = READ_ONCE(up->corkflag) || msg->msg_flags&MSG_MORE; int err; int connected = 0; int is_udplite = IS_UDPLITE(sk);