Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp999130pxb; Wed, 29 Sep 2021 14:31:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz05abvwF7zOgCKaZjIr5VCuQaUhBzK9dfklM+0KJgNt+lzRoqZKCotNhYSXQnBDlGQuMnL X-Received: by 2002:a17:906:6403:: with SMTP id d3mr2411224ejm.37.1632951118068; Wed, 29 Sep 2021 14:31:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632951118; cv=none; d=google.com; s=arc-20160816; b=cf6ymilnif610uq51d1W/OjVkti85wv8l4P7m3D+3SmLHkgZZbr5ITqoBtYFiB8SZU UK1ADIpYKJ+BcWW4AE/FWtf+8xF/T3HUYrUmD3csEIgKRjkBR2CF4rhRZam7wMqzH2Rn emaTEsdCup4NdREUzlOyxl85ySw7NMZXFMbqiFyB09Y3J/gG3+wn7qFQOWTd30OGzSqD a2STd3/nB5uG9x4TXFvvmLcBlpioCNK9TR+VQ51ZuckVBX971OoKrZuM1Ken08OvNkiO WmkoymzwZz20T+6j8MUrsOa/kBBrmiRZSOaMaNYn06Bi35AS0ZDQWHM/ONT3sjMvuHpq O/gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:date:subject :cc:to:from:dkim-signature; bh=l9h1XTy2+9znaKOPv2jvvVkbR7Fsg4CSbp1LYA7ZS1o=; b=jjh7DhccTpVozo/xxT4jbjdF1KEv6dE6ssBvl4xMK3z7QvrC4TmgWwE3KX11ZVjIro 3VFTZneZJ9XEIp0Q22hcdY2Z/jWbMeT6qOu2MBysC6W+Y7tvCWFoffEtimsZcDNM8vMh 2BAlBlj1RuHKK8JOZdTfbbSY0CAIcKW62C4OFbyu+D/fY4pTwUudy3xhvFZO3eugpraE KmqsnDw78cO97z/rc68zRyMi0zOeMvPxrUh9x3OwhexqG7kStBDEtqK/qO0Cbv6Enh2j 8W/ySsiNimYyNHz30I2PAdYWOAgki3dR2wKQYMmtv50dR5IYo9nK0edALN/qm7qhu3B8 9xDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bjU5qdai; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r6si1314133edd.233.2021.09.29.14.31.34; Wed, 29 Sep 2021 14:31:58 -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=@redhat.com header.s=mimecast20190719 header.b=bjU5qdai; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346369AbhI2UZV (ORCPT + 99 others); Wed, 29 Sep 2021 16:25:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59630 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346361AbhI2UZV (ORCPT ); Wed, 29 Sep 2021 16:25:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632947019; 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; bh=l9h1XTy2+9znaKOPv2jvvVkbR7Fsg4CSbp1LYA7ZS1o=; b=bjU5qdai10MsH7ssHdiI/fNWAqTHm1IFotF6wdC3aZ20T64BYtnDBjTE3HyZwaz9y7CGsL wCcPOQTicE/lcgmfm3cWbVL2QYJO48fe3YtQs22oDM1goS3/C4z/XUDl+LdNN9c0EwOAa1 p1a2jXoe1WFx/OPnHbgnrteV71q/JGY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-274-1l0GWO55N1e1UR2lZCemeQ-1; Wed, 29 Sep 2021 16:23:38 -0400 X-MC-Unique: 1l0GWO55N1e1UR2lZCemeQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 78A30101AFA7; Wed, 29 Sep 2021 20:23:36 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.176]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B201419729; Wed, 29 Sep 2021 20:23:34 +0000 (UTC) From: Florian Weimer To: linux-fsdevel@vger.kernel.org Cc: Andrew Morton , Christian Brauner , Kees Cook , "Eric W. Biederman" , linux-kernel@vger.kernel.org Subject: [PATCH] procfs: Do not list TID 0 in /proc//task Date: Wed, 29 Sep 2021 22:23:32 +0200 Message-ID: <8735pn5dx7.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If a task exits concurrently, task_pid_nr_ns may return 0. Signed-off-by: Florian Weimer --- fs/proc/base.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/proc/base.c b/fs/proc/base.c index 533d5836eb9a..54f29399088f 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -3800,6 +3800,9 @@ static int proc_task_readdir(struct file *file, struct dir_context *ctx) char name[10 + 1]; unsigned int len; tid = task_pid_nr_ns(task, ns); + if (!tid) + /* The task has just exited. */ + continue; len = snprintf(name, sizeof(name), "%u", tid); if (!proc_fill_cache(file, ctx, name, len, proc_task_instantiate, task, NULL)) { -- 2.31.1