Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp237981rdb; Thu, 18 Jan 2024 01:56:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWAw7xD5/g8wWBP7afHWml2/xrwvTfnTdU3hYkdc4fKfKjks+Ocvo68C/f2a04JFVvqk+c X-Received: by 2002:a05:6214:19cd:b0:681:98b8:3512 with SMTP id j13-20020a05621419cd00b0068198b83512mr83257qvc.126.1705571796521; Thu, 18 Jan 2024 01:56:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705571796; cv=pass; d=google.com; s=arc-20160816; b=0kisKflrwTPSu3B/04Uw6FHj4cydc2hfWU3DXRooxsNJmpCnrzfrq6hDYvA1Ly0641 wGDbvZSwfGY8CYRiXke6TnOEKsieKEob+aJWTpJCd1zLxU2RLHsazGYya1AfcozLOwb/ 8WAD+4GVOPyNJJthir89Ei5tUI/1A+8GU4fuhTjCLupScfmNLbsopusYyqduAtdXL4MH YYNahN8eLAvUp+Zewm2aCa8hQLbHv8xn3yLLJLVLpS5XFcRHFf2UmuDT5Bxcn8o0XyuM mYckl3KhBEihM3qHcRBFTJkafjgkBkWgIqMfe8Hwt6o/f38W7JBMRwaFATE7DYBqdWE0 4DxQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=qh+wH52rq1O19pUhbRYFfC3OyLYjJldAfdQgu6VbbCk=; fh=0IbKzzgbQHIeENPCMu3t5IovABUV2qnzTeGzADSjYAA=; b=ZxCLuaaIweyop1YJ9zbF09FkqlKyatLpFMEicq1X7TUPIa/rYBUz6DHa9yaXWCEd9b +U1WkWtIDzBnCsPqC0/LyW5hFCpXYHpCmblUJH9Qls/fjw2pJkOzkriaLh8IgKRtuTLF dUFYExcC5Cy925hYy0dCFFlkIFBpIv17rcib5ZpsCkvpqHQIUvb8yIFzp6IOdCCnaPJ1 rdSkLkxhuPvXQ6qPnuM1BLK1NFhwD2LbPMumQGvpzpUog7Z4R7OrODLAwpan0EEUqKVm F3Jx5Hn1xsKF39QK7U+DAO8lABATOV71WzZNA0kZ/6OdjxDgMzaIjLtHd8TYMA7smz9k uXMA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CZQWPCiL; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-29987-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29987-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id m10-20020a0cac4a000000b006816c0b1f82si4906958qvb.446.2024.01.18.01.56.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 01:56:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29987-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CZQWPCiL; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-29987-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29987-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 45BD01C24EB4 for ; Thu, 18 Jan 2024 09:56:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3A96D2033C; Thu, 18 Jan 2024 09:56:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CZQWPCiL" Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09C89200AC; Thu, 18 Jan 2024 09:56:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705571786; cv=none; b=sNAOAtGlKkl/BP+vMxrtnkxKJNpCDpb3qju82o92amsPu+jFL2PJ/NHxfn24U2S4KUlxOOSEYzF72S/M9rwpcA6zTBoVNh4WfE4pAUo/p+EPHx8M5L8+4NPhE3tICDuStClae/nudbN6WXG4EmHyYtiHE7/OCXF3ab9A1SdVLu4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705571786; c=relaxed/simple; bh=hWuuTgxcPQhYy8iWEJv2hwI1bR5CzV0o5I3xGjHNOwY=; h=Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Google-Smtp-Source:X-Received:Received:Date: From:To:Cc:Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=pGgnE956J8c1Kyim1HO2/K1ZQWCuBSq8iMyANSHePqdy6O9B61G5Odo/60UMKHQxYwHHGXU2Igm0+5UwpMLFNERUPU4aL2yW1BsRLbhho0UBvoRUbM3I+VY/4+XFFty+QG8S3cIQaIrhNklABwUr/4DuqrJPE24LYI0bMWVbW9A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CZQWPCiL; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1d4414ec9c7so62679915ad.0; Thu, 18 Jan 2024 01:56:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705571780; x=1706176580; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=qh+wH52rq1O19pUhbRYFfC3OyLYjJldAfdQgu6VbbCk=; b=CZQWPCiLmUlH1kW/Ru2Q+TW8z83dfsoCIoi/ynaC+1TCRQ3cBvBKodx/6RmlzD6r7i KKZEzfZMVJ7HrtvgbTPUmxwO5h+xWfqAISCeWt/LtwcJIEWMjiElgwzBYqPQVGbm1hLR ufIDdAs+HFS39yBacPWmaKR1pKqMCS4cwxWgh3GDu3wuSc0qNCROTmXcG6tZtSKyp5LY onoCwKrXORLaXuWwvhkz1vPIOQ+e6Vo/Ah8TOmshhMoxQmI8YQrkJkfLEuwRcMayYvZx EFZOsNw3o/hc0ubJ4ft5Mh5QGmq99uez74gnH7uKbrK9GCInNz/opzgDPRF/odL4tIWC rP+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705571780; x=1706176580; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qh+wH52rq1O19pUhbRYFfC3OyLYjJldAfdQgu6VbbCk=; b=kn7CV21voxiYWUuEYNPHbgqpw37sf4oo3KBQjPSHs9gk5ZQCePxVCiXxWStubpnuZT TDqpUI/Kn6++5uFiyGk3pk4pGpWFaR5LBl4ew/AzI74GeIiK4Y1XEjrkz2hBrg2WO0Lx 5FXcrFOf7bUWweUjvUvomEP+Xx4TeDMilmm/EhSidHzrpQ/vaVyTwbkI1b3HvGQJn2qT Lw85sta96TD/bodLlBt4rbvoL0Z3H9TwLHjuZjoPwyZF5nJo7P4Vxs3f3fZf71WGvqug SUw9bTxXRNgpqKmirLjr8FPiI+T5iBsgt85DL9H0M9bzoD1EiPAOhMCHQmMoq2Ld7yEt M0wQ== X-Gm-Message-State: AOJu0Yy3IMEuhP8JrOCo0s9xOuXythA99CWn20szo38Z32mSIrmK/Bxm PQHS6SkCUWVnb//Rcqee/bZenQft98jqb840g+FjGrHz1jdWwwUz X-Received: by 2002:a17:902:d4cf:b0:1d5:4b75:f2da with SMTP id o15-20020a170902d4cf00b001d54b75f2damr532208plg.108.1705571780257; Thu, 18 Jan 2024 01:56:20 -0800 (PST) Received: from Laptop-X1 ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id q11-20020a170902c9cb00b001d70eb36dd9sm385185pld.279.2024.01.18.01.56.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 01:56:19 -0800 (PST) Date: Thu, 18 Jan 2024 17:56:15 +0800 From: Hangbin Liu To: Nikita Zhandarovich Cc: "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Taehee Yoo , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+a9400cabb1d784e49abf@syzkaller.appspotmail.com Subject: Re: [PATCH net] ipv6: mcast: fix data-race in ipv6_mc_down / mld_ifc_work Message-ID: References: <20240117172102.12001-1-n.zhandarovich@fintech.ru> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240117172102.12001-1-n.zhandarovich@fintech.ru> On Wed, Jan 17, 2024 at 09:21:02AM -0800, Nikita Zhandarovich wrote: > idev->mc_ifc_count can be written over without proper locking. > > Originally found by syzbot [1], fix this issue by encapsulating calls > to mld_ifc_stop_work() (and mld_gq_stop_work() for good measure) with > mutex_lock() and mutex_unlock() accordingly as these functions > should only be called with mc_lock per their declarations. > > [1] > BUG: KCSAN: data-race in ipv6_mc_down / mld_ifc_work > > write to 0xffff88813a80c832 of 1 bytes by task 3771 on cpu 0: > mld_ifc_stop_work net/ipv6/mcast.c:1080 [inline] > ipv6_mc_down+0x10a/0x280 net/ipv6/mcast.c:2725 > addrconf_ifdown+0xe32/0xf10 net/ipv6/addrconf.c:3949 > addrconf_notify+0x310/0x980 > notifier_call_chain kernel/notifier.c:93 [inline] > raw_notifier_call_chain+0x6b/0x1c0 kernel/notifier.c:461 > __dev_notify_flags+0x205/0x3d0 > dev_change_flags+0xab/0xd0 net/core/dev.c:8685 > do_setlink+0x9f6/0x2430 net/core/rtnetlink.c:2916 > rtnl_group_changelink net/core/rtnetlink.c:3458 [inline] > __rtnl_newlink net/core/rtnetlink.c:3717 [inline] > rtnl_newlink+0xbb3/0x1670 net/core/rtnetlink.c:3754 > rtnetlink_rcv_msg+0x807/0x8c0 net/core/rtnetlink.c:6558 > netlink_rcv_skb+0x126/0x220 net/netlink/af_netlink.c:2545 > rtnetlink_rcv+0x1c/0x20 net/core/rtnetlink.c:6576 > netlink_unicast_kernel net/netlink/af_netlink.c:1342 [inline] > netlink_unicast+0x589/0x650 net/netlink/af_netlink.c:1368 > netlink_sendmsg+0x66e/0x770 net/netlink/af_netlink.c:1910 > ... > > write to 0xffff88813a80c832 of 1 bytes by task 22 on cpu 1: > mld_ifc_work+0x54c/0x7b0 net/ipv6/mcast.c:2653 > process_one_work kernel/workqueue.c:2627 [inline] > process_scheduled_works+0x5b8/0xa30 kernel/workqueue.c:2700 > worker_thread+0x525/0x730 kernel/workqueue.c:2781 > ... > > Fixes: 2d9a93b4902b ("mld: convert from timer to delayed work") > Reported-by: syzbot+a9400cabb1d784e49abf@syzkaller.appspotmail.com > Link: https://lore.kernel.org/all/000000000000994e09060ebcdffb@google.com/ > Signed-off-by: Nikita Zhandarovich > --- > net/ipv6/mcast.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c > index b75d3c9d41bb..bc6e0a0bad3c 100644 > --- a/net/ipv6/mcast.c > +++ b/net/ipv6/mcast.c > @@ -2722,8 +2722,12 @@ void ipv6_mc_down(struct inet6_dev *idev) > synchronize_net(); > mld_query_stop_work(idev); > mld_report_stop_work(idev); > + > + mutex_lock(&idev->mc_lock); > mld_ifc_stop_work(idev); > mld_gq_stop_work(idev); > + mutex_unlock(&idev->mc_lock); > + > mld_dad_stop_work(idev); > } > Reviewed-by: Hangbin Liu