Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3027266rdb; Wed, 15 Nov 2023 19:34:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IEZmdMQqq+3nar8MKOnrlqG32cr+pbK/oov/tmAsb/AhCYS3rYtfIfy9YS8qcSA7UKkifS/ X-Received: by 2002:a81:9103:0:b0:583:307d:41bc with SMTP id i3-20020a819103000000b00583307d41bcmr15618300ywg.27.1700105673336; Wed, 15 Nov 2023 19:34:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700105673; cv=none; d=google.com; s=arc-20160816; b=x+s+doiWkfAit1ly2RNWsJ7jzTM1tJMJpVPnFZ1cTavtC+4FqfE08BiL2Zvd9/ZoTy b27CG5J/h5jf9U5NmjpiOArvBwbt2I/nSa20ywa/CrBjnkaM1DX6jFr9OnOvQbh3R8IK USJWm2oSpRwjTAgs5y9U+vIBqOC8YNOt/qmRiyDiKLlzdkbYtKj0KudivB+VfB+1aDUb kaqXsCpPY5hY2FlUtgqW+BtZ+oxey7ngPNMh5iBHBvyZTS1I59OAWwmJJobHo5qF75ej VvU0AghqUmxL5oGIY3ceaQ2HKiyDwQB40Wd5M4gQrrNegr//qosJDmgLI4r0g4xP72os gPIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:mime-version:date :dkim-signature:message-id; bh=7hfj98r1RUf05ReDEmwIF2LjiRP9glPD+KMKS9nDF6Y=; fh=jyhFGwMdrQYdQ1gnNERUBwoVWoMaUKowoEMziUleRjs=; b=gXewA4jKpenwVwrw80CgIuRoqsiTWb5/2dR8mQGIzoSX+1hSxhZzhfPteyZnGMFkfR NayQ6hCp2T9zUyxotCdFc4mZKt2d/v91p8+7lkI/EqJJaloZ97y1FoK/hmJZGxaKpRme 857gzdgVAi0W6q4EOLgJQiGSbegytSZyFpekF6jWj1/dkKIBd0Bamp2ZlphJeMmpMLEn JVk5g3fKAlogmyDoUfwlwL8dh5Cw/YZqxir7BFLscZJId6YoRCOdvuKvngNT3kCyppmL 7kwGIa4ALQVD0/4jq6tz9Q0i+lcjFfSEVu5Mhw6I2En42KUToK/RKoDnqlX4C1+9VyrW 5PqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=DzCdVATe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id ca10-20020a056a00418a00b006be1fc3ee73si9620227pfb.358.2023.11.15.19.34.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 19:34:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=DzCdVATe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 7CA3180212FD; Wed, 15 Nov 2023 19:34:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344454AbjKPDeY (ORCPT + 99 others); Wed, 15 Nov 2023 22:34:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbjKPDeX (ORCPT ); Wed, 15 Nov 2023 22:34:23 -0500 Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3AEC8F for ; Wed, 15 Nov 2023 19:34:17 -0800 (PST) Message-ID: <95c2b494-ce8a-422b-918e-8ae4853ab9f0@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1700105656; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7hfj98r1RUf05ReDEmwIF2LjiRP9glPD+KMKS9nDF6Y=; b=DzCdVATezfQ6/FLY6Xis/fjn0jTfNE3hQu4QmbGPYsqE7r/+w2L5JDZOKfJFx5EwtKa2Ts 1f7IUl/yzPCu8arnh7SYex5MWFoaDV3o/2ea9hkaE6dAD4uly8WEx9p1CK+1fyn1v3LicS 2UdxZz0IBb3sX0fJRuXCy4t/fY15fu8= Date: Wed, 15 Nov 2023 22:34:10 -0500 MIME-Version: 1.0 Subject: Re: [PATCH 2/3] bpf: bpf_iter_task_next: use __next_thread() rather than next_thread() Content-Language: en-GB To: Oleg Nesterov , Alexei Starovoitov Cc: Chuyi Zhou , Daniel Borkmann , Kui-Feng Lee , linux-kernel@vger.kernel.org, bpf@vger.kernel.org References: <20231114163237.GA897@redhat.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yonghong Song In-Reply-To: <20231114163237.GA897@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 15 Nov 2023 19:34:30 -0800 (PST) On 11/14/23 11:32 AM, Oleg Nesterov wrote: > Lockless use of next_thread() should be avoided, kernel/bpf/task_iter.c > is the last user and the usage is wrong. > > bpf_iter_task_next() can loop forever, "kit->pos == kit->task" can never > happen if kit->pos execs. Change this code to use __next_thread(). > > With or without this change the usage of kit->pos/task and next_task() > doesn't look nice, see the next patch. > > Signed-off-by: Oleg Nesterov Acked-by: Yonghong Song