Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3731143pxb; Mon, 4 Oct 2021 08:25:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwO6j8xSR/Z0BFVtE6C6Bo9g4IYy6Eztq96IZq1sqlydYoqn7gsWEkr5i61rETzL8Tdv25g X-Received: by 2002:a17:90b:3b8b:: with SMTP id pc11mr31457934pjb.180.1633361135552; Mon, 04 Oct 2021 08:25:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633361135; cv=none; d=google.com; s=arc-20160816; b=NeeTaYFdqh+8RcxY4ehtOi7ozXpMPotHjGdoQxFxEWKEtZD1co7yhuHoCa+pdPCqrA SFB3nW+tK0qpmr5TSBdf4qdKqbBWwlaDiwHHXvJes1MS4E6o3a1jguVZXVpLuBLjVc5P dYOGAwz3WdlN/WriW9G6sAenWUnqFjJNsrDpGxK7MXhmVNrxgxyyRcN5Ml5jicCVwmd5 P2GZHvitKWYTPc8oDYXGGszty6CqPusMJCc79lSZkrHjNTxwUgAtPu8pBCM9QB+2Musp OsXQT5pohM74udS4J7uQoLNns0tY6laUvNKolGOzXwLmipzhXDd+BOglSqP20G5Zw/gi 6evw== 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=RkQ+WpJfRNhO5geNeAwLGmkqwSo2T/b9pIX4+bqTL98=; b=G5/v0jsEg7cbBwQXkwwnMf7WeD3c6AiLt4oNKvnmeiQnTYal5BXgDsiO7hjvf9d+G1 UcirSWDtsSNTJED11xy95BlJ+7QYvn0493gDOuNq/REjjOnfxfApEXDjd1ieQVkwNcIL y9NmGeY2fJayNLkKjpwRvn51exqAcORSfc7WFPLfKu+xZjjuShax2dkWoPdtICkdC+Aq KLG2EHMKtILhHVn4kFsu+S1d1Hhnk5WfrHXmpmZgaH86EFpSS86igxCx8K8d3Gbp35Um PZK/880RGLpoahDnTNrAo6K6b0ha2YHU62M9JGlpFAvd1gEIb03MgalrT/zjy38OQZez JYaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=isQq44Is; 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 n3si17869607pjh.74.2021.10.04.08.25.08; Mon, 04 Oct 2021 08:25:35 -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=isQq44Is; 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 S234399AbhJDNOa (ORCPT + 99 others); Mon, 4 Oct 2021 09:14:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:45730 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236006AbhJDNMg (ORCPT ); Mon, 4 Oct 2021 09:12:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 05B4961B68; Mon, 4 Oct 2021 13:04:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633352689; bh=IJ/xWMExeRjiEjLcaEn/r8Vwc9m2q6Ua5kPjkBc64LM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=isQq44Is37NH53mTJNzu4iz16qvHBZqQ27xj+8KVqrZLa1XHN8H6vKobzPwPC/zPN qGXdQDiUSqBFUM7AjbL4hNA4dvqwYc3pXlPv29Lul9/FPZ4RTidRSmk9xgpaWDZohD pXOtHJBDZlth8JrZELV/mMbB6VVTd0PZIadDagcQ= 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.19 82/95] net: udp: annotate data race around udp_sk(sk)->corkflag Date: Mon, 4 Oct 2021 14:52:52 +0200 Message-Id: <20211004125036.259497428@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125033.572932188@linuxfoundation.org> References: <20211004125033.572932188@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 @@ -935,7 +935,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; @@ -1243,7 +1243,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; @@ -2468,9 +2468,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); @@ -2583,7 +2583,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 @@ -1169,7 +1169,7 @@ int udpv6_sendmsg(struct sock *sk, struc int addr_len = msg->msg_namelen; bool connected = false; 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 is_udplite = IS_UDPLITE(sk); int (*getfrag)(void *, char *, int, int, int, struct sk_buff *);