Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1045421pxj; Fri, 21 May 2021 05:19:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyylaQBfkcnLTT/cx0eyw6w+PFOnGTe5StB/FxjKa0tZkMbgUSNd8Ff0nSlIOI/IC2KMlJR X-Received: by 2002:a17:907:b09:: with SMTP id h9mr9742896ejl.430.1621599597643; Fri, 21 May 2021 05:19:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621599597; cv=none; d=google.com; s=arc-20160816; b=yfNVcDNO7WRF3pPSRzW1RVVZXgT4kmb/6v8FFB9+gkY3idorBJ4EbIQJ03aNdycbGH RBZ+WgS+1rX8od1sCmmFcHnoWjUbaZ8UtkNPM442Pyypm4pRyY1uQfl6a2MQefwvhEBy ilXp6z414dNT2p3LKDoOX+xo5PtnbhT/22zGl1RL47bdiduY/YaT9EaCHreQuVEaoKVq bF6GsFVg0jNtRygfvQ9DD5qGX58wDuRDy8MTDl+o0xOk6a9XNnGtA5Ji3kZCe3wm1fFA MbdIUFIMdhh7qXaOzcBAkr1IvhveKm9hlR64MBze0JxFTH3gIby7hXONOMpF4GEmao4M fOCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=dveRi8qXK4S7Aqj22wKeIeoH5nCdLs5ianbPWuy39fQ=; b=y+6fmAW2tlNa6csgj/M/KKFX9SMOmK/IkSEz4dMIVyGVHdu6yYbFP4nZ3IeHKzxQhr ljbrGHKSGdYqAhtmtu+CApKDLLLHsYv2TUVb1MMFdtScoafi32dY414652jc0ryqQmcs EP++2/poyPNc1OvPKHQalo/krnQH19B3AhrCVad/ZbEsbwt/Ap/UNyMjMfo+/yiDF/lj d5ORtXbh1p1kUOMLTUXYJBfJ9BxwjphzsMvZI9e3Y0ZFHYnQ/aHoGsgvim3fEbKzea8p maXXeQx9JmsFRLjcP8lZ9ZzJjzhx+ngkKDl5Cp3gOT6cOP6i64UF9CQJC2WYM/+5gQIf 60qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=L2VxvYel; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w17si6716242ejb.702.2021.05.21.05.19.34; Fri, 21 May 2021 05:19:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=L2VxvYel; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230084AbhEULMH (ORCPT + 99 others); Fri, 21 May 2021 07:12:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbhEULMG (ORCPT ); Fri, 21 May 2021 07:12:06 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4A09C061574 for ; Fri, 21 May 2021 04:10:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=dveRi8qXK4S7Aqj22wKeIeoH5nCdLs5ianbPWuy39fQ=; b=L2VxvYelKHVRJ6huw7XbvW4Wt7 GOtFQVQ2kn4YiaqPTRlD19SSm2NzMzF3WM6KjLf14D8rSSn/1HB7NEfiUk26eE9/tDNdIKohR8/X8 QaTZonlhsNB7OqbjZWsa9xBuuIb6IUTjrQQgl3uWnmq0xxkk0mzlx6uteInq4blh7/I4kePWNrHOl K1jxcDxuTbwCl1XZ1zQRuf9vpc6CEfvyseTyccwlS5YzXWnJgspbXMJCJPM6JS4XoRwascY5qAtb0 M0amu3jwAa8BysZeCQXVSJnldK1pl98eaz3Xblu59Ke76As4xD86Dp1MVLkKqq+3zTJZ7+QxlUvRt tE6PyV2g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1lk32o-0056gw-My; Fri, 21 May 2021 11:10:18 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 4DEA9300103; Fri, 21 May 2021 13:10:17 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 260803119BA4E; Fri, 21 May 2021 13:10:17 +0200 (CEST) Date: Fri, 21 May 2021 13:10:17 +0200 From: Peter Zijlstra To: Suren Baghdasaryan Cc: Huangzhaoyang , Johannes Weiner , Zhaoyang Huang , Ziwei Dai , Ke Wang , LKML , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira Subject: Re: [PATCH v6] psi: fix race between psi_trigger_create/destroy Message-ID: References: <1621562754-8158-1-git-send-email-huangzhaoyang@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 20, 2021 at 07:11:08PM -0700, Suren Baghdasaryan wrote: > On Thu, May 20, 2021 at 7:07 PM Huangzhaoyang wrote: > > > > From: Zhaoyang Huang > > > > Race detected between psi_trigger_destroy/create as shown below, which > > cause panic by accessing invalid psi_system->poll_wait->wait_queue_entry > > and psi_system->poll_timer->entry->next. Under this modification, the > > race window is removed by initialising poll_wait and poll_timer in > > group_init which are executed only once at beginning. > > > > psi_trigger_destroy psi_trigger_create > > mutex_lock(trigger_lock); > > rcu_assign_pointer(poll_task, NULL); > > mutex_unlock(trigger_lock); > > mutex_lock(trigger_lock); > > if (!rcu_access_pointer(group->poll_task)) { > > > > timer_setup(poll_timer, poll_timer_fn, 0); > > > > rcu_assign_pointer(poll_task, task); > > } > > mutex_unlock(trigger_lock); > > > > synchronize_rcu(); > > del_timer_sync(poll_timer); <-- poll_timer has been reinitialized by > > psi_trigger_create > > > > So, trigger_lock/RCU correctly protects destruction of group->poll_task but > > misses this race affecting poll_timer and poll_wait. > > > > Fixes: 461daba06bdc ("psi: eliminate kthread_worker from psi trigger > > scheduling mechanism") > > > > Signed-off-by: ziwei.dai > > Signed-off-by: ke.wang > > Signed-off-by: Zhaoyang Huang This is not a valid SoB chain though; please (re)read Documentation/process/submitting-patches.rst. > Looks good. Thanks! > Reviewed-by: Suren Baghdasaryan