From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BAE0611B for ; Sun, 28 May 2023 19:39:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1551AC433D2; Sun, 28 May 2023 19:39:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1685302794; bh=ngzSCm+RyY5SbriAOJwKsvK1ljhOGsUJtRjHu0X1A9A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MenSLdIHmac/waeMAsgUIkzPkbiMTCKKBikDXVuE34ecvE6eFigssei0UWAnG2wMS 6f770TmSUqplTfmzp3x/IdeG7GJ+/EkzbuhSNpwaZT64SvWjBy/mTz9zFrs6UE0cn3 iO/6ln/1NZaHBLTbQ+XkKy5nyfC4TmxorgFZXJsk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eric Dumazet , syzbot , Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 009/211] net: annotate sk->sk_err write from do_recvmmsg() Date: Sun, 28 May 2023 20:08:50 +0100 Message-Id: <20230528190843.754262673@linuxfoundation.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230528190843.514829708@linuxfoundation.org> References: <20230528190843.514829708@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Eric Dumazet [ Upstream commit e05a5f510f26607616fecdd4ac136310c8bea56b ] do_recvmmsg() can write to sk->sk_err from multiple threads. As said before, many other points reading or writing sk_err need annotations. Fixes: 34b88a68f26a ("net: Fix use after free in the recvmmsg exit path") Signed-off-by: Eric Dumazet Reported-by: syzbot Reviewed-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/socket.c b/net/socket.c index 8657112a687a4..84223419da862 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2764,7 +2764,7 @@ static int do_recvmmsg(int fd, struct mmsghdr __user *mmsg, * error to return on the next call or if the * app asks about it using getsockopt(SO_ERROR). */ - sock->sk->sk_err = -err; + WRITE_ONCE(sock->sk->sk_err, -err); } out_put: fput_light(sock->file, fput_needed); -- 2.39.2