Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3218892rdb; Thu, 16 Nov 2023 03:52:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IG2ApiYIP4L31Bbsn2V5ZSlrhtYIqcF1M751gY+0HIeIRjXRcsKRiNymXDgUNokWuo0BcmH X-Received: by 2002:a05:6870:9e42:b0:1ef:b109:b8ca with SMTP id pt2-20020a0568709e4200b001efb109b8camr18471015oab.34.1700135553689; Thu, 16 Nov 2023 03:52:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700135553; cv=none; d=google.com; s=arc-20160816; b=GnDNV5IYN6xcLFThfN/dN7i3/l8+iYRxAQKyPYoYEKK+BruFCmFi3Qxcyhc0QrJHH/ cj6jnnmgqZGdATy/FHNWSSiOVVQjwITfvLGa7tLsJ4L4sr6nhUKjth+FlxE9est+e9T8 vF/VTcXqGogQmhjTW3f6s1FUdIxLPbRrphqvgah11zJEW0jolQV5fzsLOmMXEYC4ORs5 5neZsHwNzJrf+0o2gbEo4YlquRoJLHRszamtfcAAZSbKzoJFdo7f56zQVTcbC6WU1FAF b2DC28pea7I85N549wrS5Hs/G+7w93n3HejmTZWIzpSmCKdn6Pp4c01qHPCJK0RFh7IP ZZbw== 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=1ZggfuDdZcTsvVVdCo0UNHxFw+MGuU1EhAQ583oVLKw=; fh=EUA1TULZRuyn7Gp4Ul9WH7rjigYz9whpA+h2Fm6SoBQ=; b=Khw0ZZvIRGLMsb0b3e+G2snWtcGLpmBU9znWZzCwS4s/zGrj2j1ZUrtNF/C20RyGoQ n/fxYBH9u8oz0y5QK2b4q9iw5/dOMY+n5mU5vpHlDIb1U2o3KYHhrAfyyTz9tmxK9Mg8 ijtQUom2ZL1ib1pFM7+ZJcsHKxxLqWnoKwTOjcrgMM6UCicIvsoBD5FN829lg1vyeLEx 7swetzrDUyu+0/lBl9uYBAypUEQQVXOSLf9oUbCmqR5L5v3J1MUh2vJ8A0CFEd/JFWy2 OeJasVnoD383S2njiLRxYm4nEaLBYilp/yL81N3a92gHWjkkow/XitNj6LfCvg2FIlQz 7EMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="Mf57//HV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id fh31-20020a056a00391f00b006902507d409si12647276pfb.174.2023.11.16.03.52.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 03:52:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="Mf57//HV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id CFE5881A334C; Thu, 16 Nov 2023 03:52:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345083AbjKPLwb (ORCPT + 99 others); Thu, 16 Nov 2023 06:52:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230160AbjKPLwa (ORCPT ); Thu, 16 Nov 2023 06:52:30 -0500 Received: from out-181.mta1.migadu.com (out-181.mta1.migadu.com [95.215.58.181]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83012182 for ; Thu, 16 Nov 2023 03:52:26 -0800 (PST) Message-ID: <41039b2a-6122-4392-96e2-4a833f41496d@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1700135543; 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=1ZggfuDdZcTsvVVdCo0UNHxFw+MGuU1EhAQ583oVLKw=; b=Mf57//HVeZx+M0RD2orju+Np3OdAXmRqxlMOLPhOkaEIkGSW9KdbDD14G/UwKfli82VHL3 bdkC7phTzYlLjD3TLvjiJCHPXHrU+ksdfomvXG+7RNzmTY+xKIdK56TgCOHi0gk991Sp2n FDZLiiv//A4HcThs5/UJRci0sQSohXc= Date: Thu, 16 Nov 2023 06:52:16 -0500 MIME-Version: 1.0 Subject: Re: [PATCH 0/3] bpf: kernel/bpf/task_iter.c: don't abuse next_thread() Content-Language: en-GB To: Oleg Nesterov Cc: Alexei Starovoitov , Chuyi Zhou , Daniel Borkmann , Kui-Feng Lee , linux-kernel@vger.kernel.org, bpf@vger.kernel.org References: <20231114163211.GA874@redhat.com> <20231116095439.GC18748@redhat.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yonghong Song In-Reply-To: <20231116095439.GC18748@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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 16 Nov 2023 03:52:32 -0800 (PST) On 11/16/23 4:54 AM, Oleg Nesterov wrote: > 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? There is no need then. We can wait for maintainers who may or may not have additional requests. > > Thanks, > > Oleg. >