Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3317626iob; Mon, 16 May 2022 19:12:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSgYOPbmH4nSwsp//6Hkds+1fZkG7TY9pYIwf80isXzIth/ooUn2wMv1ixhDdTV2BF59fb X-Received: by 2002:a17:90b:1c92:b0:1dd:10ff:8f13 with SMTP id oo18-20020a17090b1c9200b001dd10ff8f13mr33318504pjb.54.1652753522638; Mon, 16 May 2022 19:12:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652753522; cv=none; d=google.com; s=arc-20160816; b=SH/fvIWH41YVRtXb5FIu/VCs9zen3XvJYhbRqFn48/OOScsntfpne0+0h+I9fsfn9w Mw5rL6ldZMNTlgCGBdRgQVMQygqyT9+xLDP3o7ixbT/iG0E6WBXzqaSuzPV3EsA0jaFT t6WJv2nqgN2wZz0dGxa9p8vAU3gG7f6M2c7Wrh6++vrza8lYs/2G0zo7Frpeh7MSB1ge QbBh9pmxMagG1dRnrICqVY2CqJoXx3z7exh/8jiNqtRGcxt98hk2cMYZp0Q7ygLc0L1+ jl+kKtEDkTuydgo8jo+XktefdRKEGcoORa8dK96oNQE2xrw44wvD4LKf4QE/h1dbl3al Nm4w== 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=vU97Jm9i5YRD4TzXQbo3+bYh15I+dXyMh4zkEDi9XSA=; b=0gC1KDI1OqDjgVodLdp63Zuh658u3RnDudgdLmkHblqPF33OxuUYH4iB/hy8Iwpjdr eHr1p/gb9J/2YG7gO/m7ei0IMtwhCUhTmu54D0tpn/pcgjkwWGIODA84V6bUj5QAdAUk yZkNMH55ifJ5Dlm2kFBFzDrSF/P8A5XlsIp409mFAkFncAfA2khLb5flNBTejcNA2tvR WzZ6ffgCDSw8t40tcGnECiOFCgZvSgbrnF23mIEskVbC0nxDTFR5GjraeS7FtLvJ0J4x vFE56ZWrOcnA6ABANW/kGmyRF3MLo5KExH4veWII9Elb1jrTMcc5HP62I1eWKudjc8Wj 4/Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ttl4ofi3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q21-20020a170902c75500b0016179fd2770si5522013plq.392.2022.05.16.19.11.47; Mon, 16 May 2022 19:12:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ttl4ofi3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1345888AbiEPTpU (ORCPT + 99 others); Mon, 16 May 2022 15:45:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346053AbiEPTmt (ORCPT ); Mon, 16 May 2022 15:42:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94D623F880; Mon, 16 May 2022 12:41:17 -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 2877761551; Mon, 16 May 2022 19:41:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 183D4C385AA; Mon, 16 May 2022 19:41:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652730076; bh=Dq4jw3rOfRZiDJlt/p0HFwwO1NVtikxEFBXkzYc2rgU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ttl4ofi3VfI9PYe5Lv9i9Il18UjXaSp1yb+YyyQxwOx2cuCiFUtyBlZxHkiPoc/J4 BEAWXlMB9W7obQGCnC4paBB5bQloDPxysUcgTrylCt4hd9k5o956ehIfLkQ/zWFJ7Y dTVnmhJkJ2ekAfNDwVbXBQszqcewDf22HNKHR1n4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , syzbot , Jakub Kicinski , Sasha Levin Subject: [PATCH 4.19 05/32] netlink: do not reset transport header in netlink_recvmsg() Date: Mon, 16 May 2022 21:36:19 +0200 Message-Id: <20220516193614.936557267@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220516193614.773450018@linuxfoundation.org> References: <20220516193614.773450018@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet [ Upstream commit d5076fe4049cadef1f040eda4aaa001bb5424225 ] netlink_recvmsg() does not need to change transport header. If transport header was needed, it should have been reset by the producer (netlink_dump()), not the consumer(s). The following trace probably happened when multiple threads were using MSG_PEEK. BUG: KCSAN: data-race in netlink_recvmsg / netlink_recvmsg write to 0xffff88811e9f15b2 of 2 bytes by task 32012 on cpu 1: skb_reset_transport_header include/linux/skbuff.h:2760 [inline] netlink_recvmsg+0x1de/0x790 net/netlink/af_netlink.c:1978 sock_recvmsg_nosec net/socket.c:948 [inline] sock_recvmsg net/socket.c:966 [inline] __sys_recvfrom+0x204/0x2c0 net/socket.c:2097 __do_sys_recvfrom net/socket.c:2115 [inline] __se_sys_recvfrom net/socket.c:2111 [inline] __x64_sys_recvfrom+0x74/0x90 net/socket.c:2111 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae write to 0xffff88811e9f15b2 of 2 bytes by task 32005 on cpu 0: skb_reset_transport_header include/linux/skbuff.h:2760 [inline] netlink_recvmsg+0x1de/0x790 net/netlink/af_netlink.c:1978 ____sys_recvmsg+0x162/0x2f0 ___sys_recvmsg net/socket.c:2674 [inline] __sys_recvmsg+0x209/0x3f0 net/socket.c:2704 __do_sys_recvmsg net/socket.c:2714 [inline] __se_sys_recvmsg net/socket.c:2711 [inline] __x64_sys_recvmsg+0x42/0x50 net/socket.c:2711 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae value changed: 0xffff -> 0x0000 Reported by Kernel Concurrency Sanitizer on: CPU: 0 PID: 32005 Comm: syz-executor.4 Not tainted 5.18.0-rc1-syzkaller-00328-ge1f700ebd6be-dirty #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Eric Dumazet Reported-by: syzbot Link: https://lore.kernel.org/r/20220505161946.2867638-1-eric.dumazet@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/netlink/af_netlink.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index e2120221b957..6ffa83319d08 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -1978,7 +1978,6 @@ static int netlink_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, copied = len; } - skb_reset_transport_header(data_skb); err = skb_copy_datagram_msg(data_skb, 0, msg, copied); if (msg->msg_name) { -- 2.35.1