Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp674955ybs; Sun, 24 May 2020 17:56:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfGMIDNnnBwwrvv6NwCAGnPfUZt470UwM7MeElUSpnSxU3kWMppvrUdsocpSTIAAtSfBqk X-Received: by 2002:a05:6402:180e:: with SMTP id g14mr12461276edy.75.1590368175722; Sun, 24 May 2020 17:56:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590368175; cv=none; d=google.com; s=arc-20160816; b=jm9p2TBTCUzSIEHTx5kD15H/dVY5qFC8M/KMAOmg8Th3jGhJM5cYypadxhU3gU2ye2 cXP/gfO5jh2X6pUQWkNGLjAFX8XYCbtxG2aP4M+AWbXEJRst3kZh0qKQf5HagDsfpSvi J/C/F2aKFWllERkpdERkMnCQJ0WAGtrVhT1EvvyCEnj2WWkzio7v7MR7hX68VLJ9jU+H 6sW+8ybrEoDq+R+a4TX2rorZ8usv8ew7HONrqcUx0GdtEqQX/yq/HGe5l8KzUvupypsI 2Rq2CbJrVZS2JRGpfkZ+AQQLmbpdaAZX0vnXWVdpYIllT0BQ9DAAKzVVM62Yf9j/Z7Dv T4Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=p32BMRyPZRuORFKfcuH1WvkIg3DIL1gBwfCCLqNbaxU=; b=J3i9yfXq8mr4K9rtcH1CYMn2D3S2xu9wvmHzfviLBATqm9FVwZMZfyblh9XBH0yMYL z9NX4isrqk+WDldX3WsC8Ek6SfSFapRB6UDQohO8Sm/DGnuLre6svxsCus/7d7p+bhYd 5Ac970uVks0z1wIH5b1MZCHqM5gnYT1ONhyHqsK8L9pN65hjEZcIm+oOOKNNo1Urb0B2 fcHB3q0wdBbmJWyt3L9HeNIZYKnbcF46l9kt4qJiLaiLbxQvH0EBPvt9wFPD9sSdbDLF p7ypp7dJwbv8HHhA+q6N4cjzGEWOY+zzAKM4fE/TtJ2VtcmFv+xdjBOWwMfZ+JQCeClS ygyA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f24si9011830eja.255.2020.05.24.17.55.52; Sun, 24 May 2020 17:56:15 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388531AbgEYAj0 (ORCPT + 99 others); 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?