Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3993639pxb; Mon, 4 Oct 2021 14:42:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxw5AzFQkHbKuZL9fnBdXDbLRKLdZ4lH7zKETcqxDSSuHs+iY0tSxEwaTFBr/uLVX0HBFEh X-Received: by 2002:a17:90a:6b01:: with SMTP id v1mr39684380pjj.6.1633383725559; Mon, 04 Oct 2021 14:42:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633383725; cv=none; d=google.com; s=arc-20160816; b=oqqEaPmyiUnuDfTScGBGgd+K2somaq1PG8u+J0UrB1A1RD5+rJbCPUww+zOxDPk3+G OqcC00+muCkYxN4nHZkRWKM8cb0rW3l6j1UGaMcouxDvBv6ppWSgDiVhFzKipW+CLLUI YIC8LtXVQ0MuiDF2qesgT1gSGG89C62iXMFEpQaGXXSuECrUAbLDcfHLhRU9//+FfwEG UXMp9Ng6cXFUaCAipZLiY32mhCTqwQ0hOoIpN4CuiezdV2MT7JteANrzKV4TD4aTI4hK 54kGafh0eZnP7DIxM050lIB2bZPlH9H3A6u/CXTpX7Zkz/ndak2FtUwG9C51IQUqsKLy nxOQ== 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=uqlXU8/iN4alZ+Gpu2a05bGt8ZUxJHIoY/rP16N4Nyk=; b=w9wLqyWnW1GLXL79wULF87B0NGYFhVQ1LFcf+CTYLnCpFu3+CUnk7sleKs7MGD2EFC /qcI6AWFFdsrwiyj/5JWTgWhcp2i3sJ9zTbijh/JN6LpQLgnmBuZk4V70Fuc+8+k1VY9 pBuvJ/EH0t89jdBPYHCUiEk9pDHrW/dQVyBVlDTedO8Wy/lhN2AVrLJK8ENgBpNdf5A4 Dd2cUw5/DC8q7a6hSRE8YqsinQ0ynI5wH3qzJ1B5/2X43rISwQUaaJfh3AIrV2+JoxQW VGGMmISEukOSs2+3gYM3/9248iiZULEYBds6B/DKAeoiwKCCTGfrK+owkBLXIN3b7QkO 3WMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y2DHWFlN; 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 b10si13055261pgl.641.2021.10.04.14.41.52; Mon, 04 Oct 2021 14:42:05 -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=Y2DHWFlN; 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 S238729AbhJDNmR (ORCPT + 99 others); Mon, 4 Oct 2021 09:42:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:52280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238438AbhJDNk1 (ORCPT ); Mon, 4 Oct 2021 09:40:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 210D56324C; Mon, 4 Oct 2021 13:18:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633353521; bh=EMV0BO4WkbCyK2UzgFMNMPCHKceVyxffuyrhsxFJhnM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y2DHWFlNzipHlBwtMj4UqlCHMDOQ+U4d6BPmZEzhuV1T1vNhtEoDQD/f9WuxbuJjo Oq3gXeTlCs87MYRyYDyWA1Z4PD6xSLjIVXeiDjihJkW+AFmvo3hH0DfXPcRuMP9hdH L2+cq5Aeb6Zv9mX/Hjy5DWRsS3aFDZ8bdYp4///g= 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 5.14 160/172] net: udp: annotate data race around udp_sk(sk)->corkflag Date: Mon, 4 Oct 2021 14:53:30 +0200 Message-Id: <20211004125050.135125962@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125044.945314266@linuxfoundation.org> References: <20211004125044.945314266@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 @@ -1053,7 +1053,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; @@ -1361,7 +1361,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; @@ -2662,9 +2662,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); @@ -2787,7 +2787,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 @@ -1303,7 +1303,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 *);