lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 17 Aug 2020 17:08:27 -0700
From:   Linus Torvalds <>
To:     "Eric W. Biederman" <>
Cc:     Linux Kernel Mailing List <>,
        linux-fsdevel <>,,
        bpf <>,
        Alexander Viro <>,
        Christian Brauner <>,
        Oleg Nesterov <>,
        Cyrill Gorcunov <>,
        Jann Horn <>, Kees Cook <>,
        Daniel P. Berrangé <>,
        Jeff Layton <>,
        Miklos Szeredi <>,
        Matthew Wilcox <>,
        "J. Bruce Fields" <>,
        Matthew Wilcox <>,
        Trond Myklebust <>,
        Chris Wright <>,
        Alexei Starovoitov <>,
        Daniel Borkmann <>,
        Martin KaFai Lau <>,
        Song Liu <>, Yonghong Song <>,
        Andrii Nakryiko <>,
        John Fastabend <>,
        KP Singh <>
Subject: Re: [PATCH 12/17] proc/fd: In fdinfo seq_show don't use get_files_struct

On Mon, Aug 17, 2020 at 3:11 PM Eric W. Biederman <> wrote:
> Instead hold task_lock for the duration that task->files needs to be
> stable in seq_show.  The task_lock was already taken in
> get_files_struct, and so skipping get_files_struct performs less work
> overall, and avoids the problems with the files_struct reference
> count.

Hmm. Do we even need that task_lock() at all? Couldn't we do this all
with just the RCU lock held for reading?

As far as I can tell, we don't really need the task lock. We don't
even need the get/pid_task_struct().

Can't we just do

        task = pid_task(proc_pid(inode), PIDTYPE_PID);
        if (task) {
                unsigned int fd = proc_fd(m->private);
                struct file *file = fcheck_task(task, fd);
                if (file)
                        .. do the seq_printf ..

and do it all with no refcount games or task locking at all?

Anyway, I don't dislike your patch per se, I just get the feeling that
you could go a bit further in that cleanup..

And it's quite possible that I'm wrong, and you can't just use the RCU
lock, but as far as I can tell, both the task lookup and the file
lookup *already* really both depend on the RCU lock anyway, so the
other locking and reference counting games really do seem superfluous.

Please just send me a belittling email telling me what a nincompoop I
am if I have missed something.


Powered by blists - more mailing lists