Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2776991pxb; Tue, 9 Mar 2021 10:32:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJybUcoS0X1mZh0KfraorHxkSNkAwn7cLVv5sqvNejtdDZFe7lxTuot9vzJYMZfQ1gR+DRhw X-Received: by 2002:aa7:db53:: with SMTP id n19mr5931597edt.330.1615314746104; Tue, 09 Mar 2021 10:32:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615314746; cv=none; d=google.com; s=arc-20160816; b=HY98cziPkoOcGI18nWO7boRQwScyLOV7DYaZBv3XW6iNr3F09M5mItzzOXCLwAimCT f5pRsd6VCzPwffJmYRp4zkpeSBpkr2h96CLrzeBbYyZV1TCdU4LaK//iDryH98EmYKe6 Uc380eJ+hGjCaIhvLdyyPXzHkw0OVohaMRl2TkXv+UYeHcU1p+O8giyvaWEoRgSMtKNj GLlk8jE63iw52YZJ+lWbT7JTQuyawK+7AH7HRNijko+C3sDGeSmkpzxVM1rKfJs9phi8 Fq38/l+GNzXASs+5GCRN/xWA/41FNhfoDAjQvQ5NWHEbMMa3fuPXPIGEfgQSuVJDbI43 kwuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=S8doZ1v17h0DQUZr7Z0rbMh+ReaDfhfdaNDPk8GmNYY=; b=QOfMU4NyPVIHf8MlnbXzQUXGTFLhzLAIPKzfhwly0YjZLcjg5FoTT+m8xO3XZlONaQ 2wvGATMWm4Ftqgzv9CWZEUpemlxAiMeSZm+xhADBC8k3GA+dowI5BaG1LZM16OmTAWOc 4InS2kenL8Mo4wQZb6ckv3l7LBPG9LXnYzhTIGcalP0zbSpexVn8lBsc6TuQuQhkoj4A iDPCkUNU9MU3mHvgRiX/5r7GbJhMhXdZez1usuLRSBliRyeQnnUfe89gvl378JnNdK3y guyLbP21I1AYVfxLPckvkENLveBvf5dZEkEqKj4zMUb/bO2jR+/++SnACUYreQ+m3X8r xXkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FH2kFKrt; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x21si9493171edv.185.2021.03.09.10.32.03; Tue, 09 Mar 2021 10:32:26 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=FH2kFKrt; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230522AbhCISaa (ORCPT + 99 others); Tue, 9 Mar 2021 13:30:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:38216 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230372AbhCISaZ (ORCPT ); Tue, 9 Mar 2021 13:30:25 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9AABB65062; Tue, 9 Mar 2021 18:30:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615314624; bh=tRYGs1afC4aUKzNs4pVIOuMVj2QEYFFqBfyuqhUD1RU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FH2kFKrtY54pC3u2e3ROhnxiM6wDk5CC8+3QpDa1m6zTVYvNrCA3JfrOc6a/oTKho Z05NIAyL1NswHpueCktCWaYmUnnHx5QSE84qm8YBT+Itk/R852AWnoxkIyNbsShsEK hmzql3KVqiDNL+3adotrJt+k8YEQZYeoTsMo4h+yoYN/g64WyTD3KdWrm8wWjERfYu sOIZZEf8dn4tnX5nWA6aXXgI+YAA/yqD0feKqbvRzEm8RUUWam2WSSSAMJ0+qMmABq Neaei65ZrbW9BaoG578eNI4BOU886cUnzlkmkLU5SDPByA3m5BD7Veh/nzwNrhk1rk 7thDaMl0h4DvQ== Date: Tue, 9 Mar 2021 10:30:23 -0800 From: Eric Biggers To: Jia-Ju Bai Cc: adobriyan@gmail.com, christian@brauner.io, ebiederm@xmission.com, akpm@linux-foundation.org, keescook@chromium.org, gladkov.alexey@gmail.com, walken@google.com, bernd.edlinger@hotmail.de, avagin@gmail.com, deller@gmx.de, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH] fs: proc: fix error return code of proc_map_files_readdir() Message-ID: References: <20210309095527.27969-1-baijiaju1990@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210309095527.27969-1-baijiaju1990@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 09, 2021 at 01:55:27AM -0800, Jia-Ju Bai wrote: > When get_task_mm() returns NULL to mm, no error return code of > proc_map_files_readdir() is assigned. > To fix this bug, ret is assigned with -ENOENT in this case. > > Fixes: f0c3b5093add ("[readdir] convert procfs") > Reported-by: TOTE Robot > Signed-off-by: Jia-Ju Bai > --- > fs/proc/base.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/fs/proc/base.c b/fs/proc/base.c > index 3851bfcdba56..254cc6ac65fb 100644 > --- a/fs/proc/base.c > +++ b/fs/proc/base.c > @@ -2332,8 +2332,10 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx) > goto out_put_task; > > mm = get_task_mm(task); > - if (!mm) > + if (!mm) { > + ret = -ENOENT; > goto out_put_task; > + } > > ret = mmap_read_lock_killable(mm); Is there something in particular that makes you think that returning ENOENT is the correct behavior in this case? Try 'ls /proc/$pid/map_files' where pid is a kernel thread; it's an empty directory, which is probably intentional. Your patch would change reading the directory to fail with ENOENT. - Eric