From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87347C433E1 for ; Mon, 25 May 2020 00:39:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71779207D8 for ; Mon, 25 May 2020 00:39:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388591AbgEYAj0 (ORCPT ); Sun, 24 May 2020 20:39:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388014AbgEYAjZ (ORCPT ); Sun, 24 May 2020 20:39:25 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B748C061A0E; Sun, 24 May 2020 17:39:25 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.93 #3 (Red Hat Linux)) id 1jd19D-00EviN-Co; Mon, 25 May 2020 00:39:19 +0000 Date: Mon, 25 May 2020 01:39:19 +0100 From: Al Viro To: Sargun Dhillon Cc: LKML , Linux Containers , Linux API , Christian Brauner , Tycho Andersen , Kees Cook , Aleksa Sarai , Jeffrey Vander Stoep , Jann Horn , Robert Sesek , Chris Palmer , Matt Denton , Kees Cook Subject: Re: [PATCH 2/5] seccomp: Introduce addfd ioctl to seccomp user notifier Message-ID: <20200525003919.GC23230@ZenIV.linux.org.uk> References: <20200524233942.8702-1-sargun@sargun.me> <20200524233942.8702-3-sargun@sargun.me> <20200525000537.GB23230@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 24, 2020 at 05:27:58PM -0700, Sargun Dhillon wrote: > > if (addfd->fd >= 0) { > > ret = replace_fd(addfd->fd, addfd->file, addfd->flags); > > } else { > > ret = get_unused_fd_flags(addfd->flags); > > if (ret >= 0) > > fd_install(ret, get_file(addfd->file)); ^^^^^^^^ > Wouldn't this result in consumption of reference in one case (fd_install), > and the fd still having a reference in the replace_fd case?