From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oleg Nesterov Subject: Re: [PATCH v2 3/4] seccomp: add a way to get a listener fd from ptrace Date: Thu, 17 May 2018 17:41:39 +0200 Message-ID: <20180517154139.GB8586@redhat.com> References: <20180517151218.12850-1-tycho@tycho.ws> <20180517151218.12850-4-tycho@tycho.ws> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20180517151218.12850-4-tycho-E0fblnxP3wo@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Tycho Andersen Cc: "Tobin C . Harding" , Kees Cook , containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, Akihiro Suda , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Andy Lutomirski , "Eric W . Biederman" , Christian Brauner , Tyler Hicks List-Id: containers.vger.kernel.org again, I don't understand this code yet, but On 05/17, Tycho Andersen wrote: > > +long seccomp_get_listener(struct task_struct *task, > + unsigned long filter_off) > +{ > + struct seccomp_filter *filter; > + struct file *listener; > + int fd; > + > + filter = get_nth_filter(task, filter_off); > + if (IS_ERR(filter)) > + return PTR_ERR(filter); > + > + fd = get_unused_fd_flags(O_RDWR); > + if (fd < 0) { > + __put_seccomp_filter(filter); > + return fd; > + } > + > + listener = init_listener(task, task->seccomp.filter); > + if (IS_ERR(listener)) { > + put_unused_fd(fd); > + return PTR_ERR(listener); __put_seccomp_filter() ? and since init_listener() does __get_seccomp_filter() on sucess, it is needed uncondtitionally? Oleg. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752420AbeEQPlr (ORCPT ); Thu, 17 May 2018 11:41:47 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45906 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752358AbeEQPln (ORCPT ); Thu, 17 May 2018 11:41:43 -0400 Date: Thu, 17 May 2018 17:41:39 +0200 From: Oleg Nesterov To: Tycho Andersen Cc: linux-kernel@vger.kernel.org, containers@lists.linux-foundation.org, Kees Cook , Andy Lutomirski , "Eric W . Biederman" , "Serge E . Hallyn" , Christian Brauner , Tyler Hicks , Akihiro Suda , "Tobin C . Harding" Subject: Re: [PATCH v2 3/4] seccomp: add a way to get a listener fd from ptrace Message-ID: <20180517154139.GB8586@redhat.com> References: <20180517151218.12850-1-tycho@tycho.ws> <20180517151218.12850-4-tycho@tycho.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180517151218.12850-4-tycho@tycho.ws> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org again, I don't understand this code yet, but On 05/17, Tycho Andersen wrote: > > +long seccomp_get_listener(struct task_struct *task, > + unsigned long filter_off) > +{ > + struct seccomp_filter *filter; > + struct file *listener; > + int fd; > + > + filter = get_nth_filter(task, filter_off); > + if (IS_ERR(filter)) > + return PTR_ERR(filter); > + > + fd = get_unused_fd_flags(O_RDWR); > + if (fd < 0) { > + __put_seccomp_filter(filter); > + return fd; > + } > + > + listener = init_listener(task, task->seccomp.filter); > + if (IS_ERR(listener)) { > + put_unused_fd(fd); > + return PTR_ERR(listener); __put_seccomp_filter() ? and since init_listener() does __get_seccomp_filter() on sucess, it is needed uncondtitionally? Oleg.