Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp810668lqz; Sat, 30 Mar 2024 23:26:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVingxBPlQK/APFC1/AKIg+7CKbP7aa/G107AGnO538186K6Mi2ZeLm3UDOJDkhh3rjuKw5nyWiWIyjtCJx7DApk1iR+Pc4wLGRdFGCHw== X-Google-Smtp-Source: AGHT+IEwPC6lu8BhXewtMs+5d/1qo2UW7k6ylPvEfOd/yHmlRqkQhIyykPLH8fRF/N7k1V+EBVkh X-Received: by 2002:a05:6808:1416:b0:3c3:ce24:e771 with SMTP id w22-20020a056808141600b003c3ce24e771mr8099966oiv.8.1711866389837; Sat, 30 Mar 2024 23:26:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711866389; cv=pass; d=google.com; s=arc-20160816; b=I3U8zHpiozE9QGEc6FmWJKPaRntQfT1fI/EPLh+dZzGwnndDrb/duVCNBQu4NpHP5G mREDuUNvkWpyWLnaTCSEh5DoQ4hKdUaq2tUmTWSQ4Jc0fJyDnw8TNCfMpDMu4bFCKh2R g7KOeKqOnaVgTyejdF1CS3LO7/tqISeL6HpwG4eiDu9YOK+zcMUPFNoRz6aD+LpCij9C TzX4ebG7b3UPRydqedIXydlLBDqGPea9q/ykWiqi+Q7JLetutgdbPCMa/K8Cv5KbnpzB HMp8eeyLICCkz5j3PVz2LhAjC0jy548MXb92/vtmaAv6O0tCdlm1rDN653kT7v+FibaL x5pg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=vsv+og0ZEM7dE0Ae14QDsM7BpYMYKyOUfpftiMF3Amg=; fh=fO7ir7LqOuojfvPuTveScZes6ET16i0orph4aT4EazI=; b=w5cc2PDfS3MlQtfj38/HXfXrLfL0jEsk4C4vsMHFbDLVw4+g9F5YiXfnao4+kOExpB lW60BCg12Xwpp2Bh/ICdZBlqUWFShVPg3b02h2Y5/klaSl/13p/pehnin9blnR6i/9Nk UEQvrjaRxt31vBOOz7QNuLx3fz2Vw10vsOFYpkwQv9JRU9/yR7dRNq7EmROAOQ5qwzld d3He7syt5GHF7M/RnsxVG6KVv0xB63xgq/edz5EJAqMW1DwYkrGvDFCjjtPn+DMdO0gT vtNjK++jLNlEqLsMqxo4H3SGpAwZ/skcPsRSFroJSrx9kjYK0be2lIrD1AmTBGcevqY1 /w/A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-125968-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125968-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id g27-20020a63375b000000b005dc48827a3asi7000269pgn.227.2024.03.30.23.26.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Mar 2024 23:26:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-125968-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-125968-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125968-linux.lists.archive=gmail.com@vger.kernel.org" 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 4CE5FB2140C for ; Sun, 31 Mar 2024 06:26:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A588479F6; Sun, 31 Mar 2024 06:26:12 +0000 (UTC) Received: from mail114-241.sinamail.sina.com.cn (mail114-241.sinamail.sina.com.cn [218.30.114.241]) (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 93DFD7490 for ; Sun, 31 Mar 2024 06:26:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.114.241 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711866372; cv=none; b=LaqTbeno/fnzT1OnBSfQjhnHN5rIUFN0SkZP3DJ0m+MOGApZ3XtpgYhDSprXAn2PUnwY+UtR8t2hlOZBDpqox+nOFKQH+SPy0O+26ofWbGxPMCSfUlBn244EVgPa3NNXKWKkHMZJ0enWoP5zYTF9bjf2UN968ILnoBoG+BAHjl0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711866372; c=relaxed/simple; bh=rGn4vL9+asmP70dMTI/LIUbfHclY24B3bM9CP8QSGHk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AWCR86RLbU9TQesl2oCZ3cVCRcv3o+Lci5z3/cXmZ8+fF9mEKmiAiwPsKvFslLfLWmR5AS+B7ZN9qa3xmDqKWPI3uJAmNlXEBj/XvPa8FKSEs6SGt+T/Y7/KFnG7mRug4UKVoY6Zx64+sfKoc45O68F0xOIJ4yRNdyDI0Ss5Aec= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; arc=none smtp.client-ip=218.30.114.241 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([113.118.64.152]) by sina.com (172.16.235.24) with ESMTP id 6609015C00007CD6; Sun, 31 Mar 2024 14:23:31 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 29318145089346 X-SMAIL-UIID: F8131F5289424113AB8638F7DD5264EF-20240331-142331-1 From: Hillf Danton To: Uladzislau Rezki Cc: syzbot , Alexei Starovoitov , "Paul E. McKenney" , linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [bpf?] possible deadlock in kvfree_call_rcu Date: Sun, 31 Mar 2024 14:23:14 +0800 Message-Id: <20240331062314.3394-1-hdanton@sina.com> In-Reply-To: References: <000000000000f2f0c0061494e610@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Sat, 30 Mar 2024 18:55:41 +0100 Uladzislau Rezki > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index d9642dd06c25..8867aac3668c 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -3467,19 +3467,19 @@ void kvfree_call_rcu(struct rcu_head *head, void *ptr) > */ > kmemleak_ignore(ptr); > > - // Set timer to drain after KFREE_DRAIN_JIFFIES. > - if (rcu_scheduler_active == RCU_SCHEDULER_RUNNING) > - schedule_delayed_monitor_work(krcp); > - This is not enough at least WRT run_page_cache_worker() [1] [1] https://lore.kernel.org/lkml/0000000000007a44120614e27cb7@google.com/ while the reason why syzbot failed to catch the zone->per_cpu_pageset in setup_zone_pageset() in mm/page_alloc.c is trylock [2] [2] https://lore.kernel.org/lkml/000000000000a5ee4e0614ee586e@google.com/ > unlock_return: > krc_this_cpu_unlock(krcp, flags); > > - /* > - * Inline kvfree() after synchronize_rcu(). We can do > - * it from might_sleep() context only, so the current > - * CPU can pass the QS state. > - */ > - if (!success) { > + if (success) { > + // Set timer to drain after KFREE_DRAIN_JIFFIES. > + if (rcu_scheduler_active == RCU_SCHEDULER_RUNNING) > + schedule_delayed_monitor_work(krcp); > + } else { > + /* > + * Inline kvfree() after synchronize_rcu(). We can do > + * it from might_sleep() context only, so the current > + * CPU can pass the QS state. > + */ > debug_rcu_head_unqueue((struct rcu_head *) ptr); > synchronize_rcu(); > kvfree(ptr); > > > --