From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F21BAC77B73 for ; Mon, 22 May 2023 19:38:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235069AbjEVTiZ (ORCPT ); Mon, 22 May 2023 15:38:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235075AbjEVTiI (ORCPT ); Mon, 22 May 2023 15:38:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15EEAE4D for ; Mon, 22 May 2023 12:37:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0BA3262965 for ; Mon, 22 May 2023 19:37:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28C79C433D2; Mon, 22 May 2023 19:37:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1684784252; bh=bpNz9U5KwDqt6mylltlHsYFDuW8G6eZ94IPs7OcLcbM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FYJ7qJfbKk6+8x/UmfHOgqfVAYBXF3wdLwOfzAgq5ktP69kX2K7zj+41X++KaYgRh H7DMhBTHxnDt8cBw0DshDiOBZhkeVeRzRqrSdalsjnF5+7oMFp3SBfZeDU2wojaztn jP3zqDAPtetqnE1RJdLMXgtoQiePaiLCYDrXIK0U= 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 6.3 020/364] net: annotate sk->sk_err write from do_recvmmsg() Date: Mon, 22 May 2023 20:05:25 +0100 Message-Id: <20230522190413.334627371@linuxfoundation.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230522190412.801391872@linuxfoundation.org> References: <20230522190412.801391872@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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 9c92c0e6c4da8..263fab8e49010 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2909,7 +2909,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