Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2549973iof; Wed, 8 Jun 2022 07:18:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPSrtw6HTPVpkJe3AyrCMfzGjS/lIbGMDlXlmTxoDShvitFfXAYhxTjGgmdWuB6K6B6Qyu X-Received: by 2002:a63:fa15:0:b0:3fd:9170:9496 with SMTP id y21-20020a63fa15000000b003fd91709496mr16626953pgh.162.1654697896675; Wed, 08 Jun 2022 07:18:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654697896; cv=none; d=google.com; s=arc-20160816; b=v1kdzFdMTg+uhwKeBqIOF0mcQ5LEeg8sWXmZMgeer3lXag6DoPiuJoesShslk1e7Bm RP5Fsnnduy4Gakje5Mq5MBk8Eg+IeGlH45dAH1teuLPV/BWim3Ew8226xupAw5MoUrkD fSCe9EzOzmTLFSp0oA745myqzBJsAC4Krt1zxk1sFJPKesdaFKJ9S6OZ0tioR7oKa7a/ U653ACbClRMre5YV9eFrgy4fvMehnbLsyrb89AF5RQ2Oz6BeEjVJPEUx4vqrHW1Ibi7Z fpgeHnwYsZwLsdTOZ+TLDcDRVFk7dESKwuLhNdJXV62TUlVW9zchKw3h1Gs0qb3mDd26 OXXw== 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=EdG9PlC0R8OmQU19nk71zBCMMuRv8NZuw8mGqBcI480=; b=1E1l95u1cKmrwKJ2ZJtEdLJF4y+vDKhrBniEJ5L7DtUfAtIWnmM18uVCMIB7+4K8gf 6x5rJhY80X1sJDWa3mOXZ/aJknfJya3i28s7fpFiAW6Ift+qDYwGDYNXMNDEADDQ7JJC jtnZyRpLbhHGMIyvIe9YqNRRirYNmdgOqxAuFAQWyXLZI9H21MnufbHaxQBlnrPyFBU1 Y+lkf4acaWtb0eXXvm5BVJas/aQlHQMexmC6X0tDBNxPjW0xGh5Gg+iKQbh2sRgbIva2 Ijyia+b6o0JTycKIhbUxxoCSlUTZ+V2Bz3byta/9KFxjY6sUOrV2HYs8I3nAKKEQS/rv 5C/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=K2HoctTt; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id t34-20020a634462000000b0039db57e26c3si6425936pgk.509.2022.06.08.07.18.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 07:18:16 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=K2HoctTt; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 275BF66AC4; Wed, 8 Jun 2022 06:51:27 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240929AbiFHNvS (ORCPT + 99 others); Wed, 8 Jun 2022 09:51:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240883AbiFHNvQ (ORCPT ); Wed, 8 Jun 2022 09:51:16 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4050B62BEA; Wed, 8 Jun 2022 06:51:13 -0700 (PDT) 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 B8DBF21AA6; Wed, 8 Jun 2022 13:51:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1654696271; 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=EdG9PlC0R8OmQU19nk71zBCMMuRv8NZuw8mGqBcI480=; b=K2HoctTtt/KhX6+mXecsJdmxEuLMLk9zl0bFw6P8GQqwSvXX6slsZPsrN89QwI/uB+DzRk 2rc7JqmJgkntQCiSgzz+t+cOxr+UxCJIiMua+TwkAugUiSC+51i12hZ9WImmy5T6lsX3QU 4J2vUnC1M74rqwRGtY9bdo+zosQvGM8= 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 9363713A15; Wed, 8 Jun 2022 13:51:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Oi8kI0+poGKUZQAAMHmgww (envelope-from ); Wed, 08 Jun 2022 13:51:11 +0000 Date: Wed, 8 Jun 2022 15:51:10 +0200 From: Michal =?iso-8859-1?Q?Koutn=FD?= To: shisiyuan Cc: tj@kernel.org, hannes@cmpxchg.org, lizefan@huawei.com, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, shisiyuan Subject: Re: [PATCH] cgroup: handle cset multiidentity issue when migration Message-ID: <20220608135110.GA19399@blackbody.suse.cz> References: <1654187688-27411-1-git-send-email-shisiyuan@xiaomi.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1654187688-27411-1-git-send-email-shisiyuan@xiaomi.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Hello. On Fri, Jun 03, 2022 at 12:34:48AM +0800, shisiyuan wrote: > Bug code flow: > cset X's initial refcount is 1. > 1. cgroup_attach_task() > 2. [For thread1] > cgroup_migrate_add_src() > [For thread2] > cgroup_migrate_add_src() > cset X is thread2's src_cset , ref->2, > and its mg_preload_node is added to > mgctx->preloaded_src_csets. > 3. cgroup_migrate_prepare_dst() > [For thread1] > find_css_set() > cset X is thread1's dst_cset, ref->3 > put_css_set() > ref->2 because cset X's mg_preload_node is not > empty(already in mgctx->preloaded_src_csets). > [For thread2] > find_css_cset() > cset X is also thread2's dst_cset, ref->3 > then drop src_cset, ref->1 > [cgroup_free] ref->0 > 4. cgroup_migrate_execute > [For thread1] > ref -> 0xc0000000(UAF) I'm trying to understand when this happens. You migrate a process with two threads while one of them exits? This should be properly synchronized with cgroup_threadgroup_rwsem, so I don't understand where does the [cgroup_free] between 3. and 4. come from. Do you have a reproducer for this? Thanks, Michal