Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3165748rdb; Thu, 16 Nov 2023 01:56:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IHiM3ZXj3SB6JKQjvLzq0lc//WhOCK3erFZtfaF+OvGBFSrpEz7f+OOMD5n0WvfC2HjIHH6 X-Received: by 2002:a05:6358:528e:b0:16b:5cc3:612f with SMTP id g14-20020a056358528e00b0016b5cc3612fmr9206654rwa.18.1700128571465; Thu, 16 Nov 2023 01:56:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700128571; cv=none; d=google.com; s=arc-20160816; b=B66AXeZC6QBqjl239XeNPRoTlqP9CO/QoizfFrOAMhtGoCOu+7laMDRvYtP1LqF0/k oSvCh9uBEcLTkGI7cYKUZ68ktXUxa/HZ/0qQQtD3J8jxQbeQoR6127CdvTmk+mdrITFa wma+6vBtnPcVW5EoCDKPDGX0OGxC41eTM/qN+wHOq9t1hgEvOLN6+C5EgQvRChZlojbb oTNlD/ZDwOS7tBBez2UFZjDXcJF11s0RRaFtjHdF1YAsBkObRfHokA8n/4H06MGs3yMg xxiGGciq0kzKIBuib0XxZeSnttt7UStBSgs8cJEatixxafjFAo3NVvtAga/jjQdBMVtm 8nMg== 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=qXY1rZA1LxkMIb59EiEw9jOuJO4zWvPkFM9jnM+8Krc=; fh=jyfu6Gueau3713nNQpgKwQg1G+5GHUHGswwrNlciNQ0=; b=JFw4Sfsy2ABx0KxiSVTmrruLXC3KGLmvu/oSjcqoS1JjKtBYLc7LCHN7+2IAjlpNEh o7eLZrsELht1caB6MEMV85XFdKjd1DgxOrZueu5k2WAYr1XIPDrNPnS1xwgfB6vkEwsX y6AqUx/+CxBIthITFH/PnWjP/0gwVNw+EsdDGYKvTCr9xmrRe1+toSESBoV0Uh+A2T0M +ggtqXkBjjCAKzQdJWFoyuEQA24mlMiaDvsB6lJU+Rnp4orG9vM+gZ0x2DAXeX7Wm3HK UfSISibnL7g8KKmiLhOSk9GMQ/quBGIC1l5cZDfSreFcpL+oLv6Nij9Dky9DF/IFffjx mYxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=U46HiH70; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id t12-20020a65554c000000b005859a7d38f9si11787521pgr.703.2023.11.16.01.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 01:56:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=U46HiH70; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 648478080E3A; Thu, 16 Nov 2023 01:56:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230235AbjKPJzz (ORCPT + 99 others); Thu, 16 Nov 2023 04:55:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229749AbjKPJzy (ORCPT ); Thu, 16 Nov 2023 04:55:54 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A472DC5 for ; Thu, 16 Nov 2023 01:55:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700128549; h=from:from:reply-to:subject:subject: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=qXY1rZA1LxkMIb59EiEw9jOuJO4zWvPkFM9jnM+8Krc=; b=U46HiH70P0qIwzWM/KGqr7lsN0a9xiY2MWri2h099IuBRBbtDIPURXw3ky1/Soz7XAjWm2 0/GOuMtKW7DJaREcJp2nUOngRwaN/odjWsS+bdLQrBY0LbqCJ6AlYa1x0OcwR12wRTv8vt H3il1W2Jqc5lS74uUT3iShh9ZUmGARQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-509-LgmwkCdWMbaa22VvNbTSRA-1; Thu, 16 Nov 2023 04:55:46 -0500 X-MC-Unique: LgmwkCdWMbaa22VvNbTSRA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C829E8007B3; Thu, 16 Nov 2023 09:55:45 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.226.23]) by smtp.corp.redhat.com (Postfix) with SMTP id EBD58C27E84; Thu, 16 Nov 2023 09:55:43 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Thu, 16 Nov 2023 10:54:42 +0100 (CET) Date: Thu, 16 Nov 2023 10:54:39 +0100 From: Oleg Nesterov To: Yonghong Song Cc: Alexei Starovoitov , Chuyi Zhou , Daniel Borkmann , Kui-Feng Lee , linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH 0/3] bpf: kernel/bpf/task_iter.c: don't abuse next_thread() Message-ID: <20231116095439.GC18748@redhat.com> References: <20231114163211.GA874@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 16 Nov 2023 01:56:08 -0800 (PST) On 11/15, Yonghong Song wrote: > > On 11/14/23 11:32 AM, Oleg Nesterov wrote: > >Compile tested. > > > >Every lockless usage of next_thread() was wrong, bpf/task_iter.c is > >the last user and is no exception. > > It would be great if you can give more information in the commit message > about why the usage of next_thread() is wrong in bpf/task_iter.c. I tried to explain the problems in the changelogs: 1/3: task_group_seq_get_next() can return the group leader twice if it races with mt-thread exec which changes the group->leader's pid. 2/3: bpf_iter_task_next() can loop forever, "kit->pos == kit->task" can never happen if kit->pos execs. > IIUC, some information is presented in : > https://lore.kernel.org/all/20230824143112.GA31208@redhat.com/ Yes, Linus and Eric suggest to simply kill next_thread(). I am not sure, this needs another discussion. But as for bpf/task_iter.c... Even _if_ the usage was correct, this code simply doesn't need the "circular" next_thread(), NULL at the end simplifies the code. > Also, please add 'bpf' in the subject tag ([PATCH bpf 0/3]) to > make it clear the patch should be applied to bpf tree. OK, will do next time. Or should I resend this series with 'bpf' in the subject tag? Thanks, Oleg.