Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3511840pxb; Wed, 13 Oct 2021 07:29:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5CLeqlblxf74YgKA5S6VVZxhBQ4ElVeGABCR569wA/0soTg15yINqFxD/0ObDvXDROrSt X-Received: by 2002:a17:90a:9f95:: with SMTP id o21mr13489571pjp.21.1634135386107; Wed, 13 Oct 2021 07:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634135386; cv=none; d=google.com; s=arc-20160816; b=tmt2Tw+cARDRvbPa37VZRuAYyb6DbJUqQN/v5gi1yE9a3ZyUXA9bsoRw5DNgobc7UG zsO60v/KmRt4DacjuC1TIy2rFI8RJqYGCTFCSYhDPDL5PFqSacDavULE5Mi3b3lhw9wZ 0q4bsIZTeN/Jblh0Adk8ySegSCGgpHXKAOOPKaF9QG3q4R0eaVPDvwBEY63hBwENVpTE ua3RgBD3zKQqnjLkI56w465YPiQJoU+Q9jENgGCN45DnVL5/goEdVAjwUH4SL9e5j++q SHXu8bF/99+Xx0ux4GbHKg16yiQMBBGkIDlvbtJRjz3L9mh1DOUTL692rCD0fRrInrWU BXWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=YMu5WsltBSxCakMJcGg6n0yfN/pBnvFmXIBjYygrFJM=; b=Lpy4PqffaZAUMXCEZEC/Jzf8JNAPEu1MQMklmctXajgot9c/IU4PaNXu2znxN8FLkA MMkIy0f+j1hr5mVrl1F6LkHaZU3sGfw5i2SSPwJkOGCs0yge0KGXCAIw7rOd6D0nL3AU K39VxHp85i+BVc13Rc6/VS7sq/MY45cOO924sIyueiK7UiJTy5xRcwpD0R4ZKLLNb2Qs EAB0P0rUX6tam9XOrOtw0KYBYP63OqnoYTvpkzJb944n1W0D90c35AVOwDMIf45MdBj8 VPSirC82AN8Ch6yyot3HgtwFQ75w7A+BvGPfw9W5IW9mBwpGp2uBjq0j33OxFCTPMQKE rfYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=JNZmW3+s; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c17si18394072pls.182.2021.10.13.07.29.31; Wed, 13 Oct 2021 07:29:46 -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=@suse.com header.s=susede1 header.b=JNZmW3+s; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233699AbhJMO2v (ORCPT + 99 others); Wed, 13 Oct 2021 10:28:51 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:45634 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233149AbhJMO2t (ORCPT ); Wed, 13 Oct 2021 10:28:49 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7744921963; Wed, 13 Oct 2021 14:26:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1634135205; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YMu5WsltBSxCakMJcGg6n0yfN/pBnvFmXIBjYygrFJM=; b=JNZmW3+sfkxw2zvc+FCxwg6d0Xr7FyW09kyooDQsj3ro3TM5r58LTcVPyB/qEziIrHihT+ v+0IwrKSHeBce/z7z2TEXO224e8HS5S/RPRRPBUGc6iJxUTIylaSfic22fYYt79XrgtRED 7fYb0WpOfu72fPjCkwIlfg12A8203Mc= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4CE2213CEC; Wed, 13 Oct 2021 14:26:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 17U7EqXsZmHoTwAAMHmgww (envelope-from ); Wed, 13 Oct 2021 14:26:45 +0000 Date: Wed, 13 Oct 2021 16:26:43 +0200 From: Michal =?iso-8859-1?Q?Koutn=FD?= To: Vincent Guittot Cc: linux-kernel , Ingo Molnar , Peter Zijlstra , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Odin Ugedal Subject: Re: [PATCH] sched/fair: Use rq->lock when checking cfs_rq list presence Message-ID: <20211013142643.GA48428@blackbody.suse.cz> References: <20211011172236.11223-1-mkoutny@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 13, 2021 at 09:57:17AM +0200, Vincent Guittot wrote: > Furthermore, list_del_leaf_cfs_rq() starts with the same test on of > cfs_rq->on_list. Yes, the same check but synchronized with rq->lock. > The problem is that the cfs_rq can be added during or > after the test. Removing it should not be enough because we do the > same test under rq lock which only ensures that both the test and the > add on the list will not happen simultaneously. This is what I overlooked when I was looking for explanation of the UAF on the leaf list. > This seems to closes the race window in your case but this could still > happen AFAICT. You seem to be right. Hopefully, I'll be able to collect more data evaluating this. > What about your patchset about adding a cfs in the list only when > there is a runnable task ? The patches I had sent previously [1] avoid adding cfs_rq to the list when it's under a throttled ancestor (namely 4/5). The runnable condition is rather orthogonal. (Not sure it's the patchset you were referring to.) > Wouldn't this fix the problem ? FWIW, the "reliable" fix so far is a revert of the commit a7b359fc6a37 ("sched/fair: Correctly insert cfs_rq's to list on unthrottle"). Therefore my hypothesis about racy adding from tg_unthrottle_up(), so I think the other patches won't affect the issue. Thanks for your feedback. Let me examine the problem some more before continuing with this patch. Michal [1] https://lore.kernel.org/all/20210819175034.4577-1-mkoutny@suse.com/