From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f67.google.com ([209.85.215.67]:34231 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934122AbdBQRLl (ORCPT ); Fri, 17 Feb 2017 12:11:41 -0500 Date: Fri, 17 Feb 2017 20:11:36 +0300 From: Cyrill Gorcunov To: Andy Lutomirski Cc: Linux FS Devel , "linux-kernel@vger.kernel.org" , Linux API , Al Viro , Andrew Morton , Andrew Vagin , Pavel Emelyanov , Michael Kerrisk , Kirill Kolyshkin , Andrey Vagin Subject: Re: [RFC 1/2] fs,eventpoll: Add ability to install target file by its number Message-ID: <20170217171136.GA23766@uranus> References: <20170217083324.627615532@openvz.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri, Feb 17, 2017 at 08:52:59AM -0800, Andy Lutomirski wrote: > > > > To resolve this tie lets add EPOLL_CTL_DUP operation which simply takes > > target file descriptor number and installs it into a caller's file table, > > thus we can use kcmp() syscall and figure out which exactly file to be > > added into eventpoll on restore procedure. > > This is a scary thing to let an unprivileged process do. > > I'm wondering if there might be a nicer way to address this using a > better interface in /proc. Well, I tend to agree. Need to add security checking if the target file is accessable by a caller. As to better interface to procfs nothing comes to mind immediately. Another potential problem is that since it is never guaranteed that target file number listed in fdinfo matching existing /proc/pid/fd/N, so that I think we will have to use this dup functionality for every target file, which of course not that fast. Probably need to think more if I manage to invent some better and faster interface to find where exactly target file belong in the whole process tree of a container. Thanks for pointing about this security problem, Andy!