Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3333256iob; Mon, 16 May 2022 19:45:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQHUGa0SKdEo5b8iZ4/iy4iOHVoBgnVgi2cciz/1Bojau8Ub39YIQSNrspnBaNdEDDR6Cm X-Received: by 2002:a63:2365:0:b0:3db:8691:4fb9 with SMTP id u37-20020a632365000000b003db86914fb9mr17388526pgm.261.1652755523016; Mon, 16 May 2022 19:45:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652755523; cv=none; d=google.com; s=arc-20160816; b=Ko98+Gt2SYMLxKXNionTW5ee0WkYdYjapJLa2Rwm4JAsx8CQlfsr/11GjEO+3iMDtQ z1J7SEAPukJ6qmZAv8Oe26Ibj9DpnP3r5FDXK6zVr1i7c3gWQDELozUyx2y5MEFG0yZu jOiRghPV/kDNjAS0yUPe6L2/4zl/uhWrCuGKSG2MXtCDJKkr+RvJonHKPpFQH3FmsTU9 O5I7psKOxq4OpgMrfMt0Z0R0tkH5Itu5mSwl9931CqNyk8fhat1Lg+vaM4dX51kowInM xNaIDA52DtLC6bs9dcs2OYCE9LXGaSDdC4X7Kb5Qy80vi4M5TiVTGBkOL1UfUsY9Werg LEhQ== 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=v/bVsLq1q/yMI6fagryNeLbau2Tm1PdTxshZK1A1E8o=; b=zbY1peDoe53mDSCPnXo5CIszToNI7IsbatOCoZcIlNksvo0q1e/hfnlJ7+9313WTyl jIGRCY9e7O9rs4b1s4XAr2skSQezYdQLninyN27kKhwPb6kHuqaXw+zgLO/oOMRPnfr8 JiublSozqbBPV38WuMx7NCDX/e5FjMZIfI1ng9L44ok632z3doCii+rKNhan2DTdO5IR qHHy1STzOUgKbJyu9xQpu2NmcLLObbcHqT7nfc+I4fBOTkiebaTAzHFsx9vd5Rw+Scje tXca6/9m11n1hVbgBfPT5oqqal7otja87Wc5Kp6txNh6aAZC8dYxDGgEBVDNueNBZcWT f+ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wpkM1sWp; 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 z16-20020a056a00241000b0051057863777si16360000pfh.260.2022.05.16.19.45.11; Mon, 16 May 2022 19:45:23 -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=wpkM1sWp; 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 S1345618AbiEPTjH (ORCPT + 99 others); Mon, 16 May 2022 15:39:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345594AbiEPTih (ORCPT ); Mon, 16 May 2022 15:38:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 443C33EF12; Mon, 16 May 2022 12:38:31 -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 D582E614B6; Mon, 16 May 2022 19:38:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB528C34100; Mon, 16 May 2022 19:38:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652729910; bh=9qxzXmWzDaSC6JFM5nKZ6C0UEuZ0OTnCGnCsKyfPyGc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wpkM1sWpTT1k6qkNtpPFpHf5z5krw7/qoBKebs17lkX59YHbWm3rAx6FjhmyIIB0t mNfe3GU/6t+GkyOWhP2x+oDWN7c60nrDTy671gj2AcZ+t/0s96FLyWtoNL2osu3Y1x g0dCuYAgPiP2UQl1TSCe/I+Mzkg6Gflmgj9GnBXQ= 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.9 03/19] netlink: do not reset transport header in netlink_recvmsg() Date: Mon, 16 May 2022 21:36:16 +0200 Message-Id: <20220516193613.601433126@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220516193613.497233635@linuxfoundation.org> References: <20220516193613.497233635@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 a8674e9ff37b..47b1631bf14c 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -1929,7 +1929,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