Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1448545ybm; Sat, 30 May 2020 09:09:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQq5NPdT9tyy/BSmsMvTLE3KajkJxtiRwzbAc6iJeU1ZVxD60pN6mI5Rs9r3kkfobrOLFd X-Received: by 2002:a05:6402:1855:: with SMTP id v21mr13730309edy.189.1590854971714; Sat, 30 May 2020 09:09:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590854971; cv=none; d=google.com; s=arc-20160816; b=c2QZeoEO1HXCIw1sA6yBTXjd4ftP6Yc1boX9B+CXL8ZSv/mp3xlThHz+ozXIosI8W7 Wn0C5kB+cEvTgtn+cZeZ/AbmXWBhU//KFL1LhXR37wbG/bls4zDUIHCkXMJTS9J5jWOR /OJeiGLnC7APRhTXADttFEBX9X5cezd9Yr4KKClvoDfM5Zf343sCWlA1IqKXvCqoknDq tnBZr0pLxxySwhaG3sPHaYDTIrdu6g6OVo6q0qqYFPJ3wR1KnSEiYAvSkedXlwaQhVWV SNzWIyoJV0DR17GWlRWvO+PW1aqiQoXbS6pyMXQobIqCGTa2yzx7rOnrCVCfmORQ97a0 OIHQ== 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 :dkim-signature; bh=DdoV3WWy/h0472QJ9/SAoLZAkGaClwMXT5quJJmxsPY=; b=U4xdrvQE3I2nTU0g9gKnCNaGRcD7KbFDjoSHPg1HEzlRHIjtBXmMSzWLBl+aSATK0r OCfSmAKlKzUC5uTVqISaf9DuH853yqO6J0wvdj3SImr6sjP0JupaFaQ+Y/kaemVSFEir YGHtNFlybaP/FufgB5YwQf6KPfjri11tWaZ3oz22raxBP65uoJNf7afDKCXgKtei64cD 6TCuvqg0PqrW8e6aN4/id3AQQamyU19OrQCY3A0HOn54k+YnMPTpFwkgoSL1lGdv9riP rsqIhAm+d0Gx3Rxr0XtA3qFQbxZEczNNYtykyNdoyST6ALQgQDFOwVtwNQKUkM9xGAZE xKcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Yv2vqOFO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i4si660044edq.200.2020.05.30.09.09.07; Sat, 30 May 2020 09:09:31 -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; dkim=pass header.i=@chromium.org header.s=google header.b=Yv2vqOFO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728927AbgE3QHU (ORCPT + 99 others); Sat, 30 May 2020 12:07:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729026AbgE3QHU (ORCPT ); Sat, 30 May 2020 12:07:20 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9BC8C08C5C9 for ; Sat, 30 May 2020 09:07:18 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id p30so1380707pgl.11 for ; Sat, 30 May 2020 09:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=DdoV3WWy/h0472QJ9/SAoLZAkGaClwMXT5quJJmxsPY=; b=Yv2vqOFOVVvE9Dma0cQRiNb4ghy2CvppzAooljl0Qg4QtEFe3avE17HBccN2PVZQTn X+nHYpD/wObrqKv3gOADULmXKqv+MOPSKhp82sbc6Qq2SUpIMdi4mSn5+n0TO/7TZV6f 729i0RnuUIPSfOZTU+1NCeifM3JfyWzBk93xY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=DdoV3WWy/h0472QJ9/SAoLZAkGaClwMXT5quJJmxsPY=; b=LFXg4pD6VvLS2ZgdghbSgG1SkjnPgpul9yzEMuIBdOQ9g0cSZJRfPHDX/1YLWbCEIs z9JnvpfWRKhnOM7buDDtYu+7tSasvWDGIl8RtYCCW/S9333ZclGLwKXsIdNa2cs2hmIJ p8G9Z4NIXKPvyFA+Mv1yseFsk5JVOpZ1RM750xC2rhFLbePQaRlVJmpR4YvDXnWHOAJW xnXZ1rsh7Cr2Xi1vFmDl6f/QMz4bkzWITpN9vEWGCm6P4yK8iJiKa1yW42/5BMN1vjul /0RXErLbq4nmSZIfr4TtX9kzV7GBzSfgRRHtddc4UmKLcpf3cYYPZeM3WVjG0Z9GXJmn LubA== X-Gm-Message-State: AOAM532gvbooioT2pmx2dsHx0Oz0NoKtLoC9Ttdky8fjr89/dnMeU/qO gbG0oGSTR/J+7k2APxGUpKH1ow== X-Received: by 2002:a63:368c:: with SMTP id d134mr12833657pga.393.1590854838327; Sat, 30 May 2020 09:07:18 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id k14sm8919617pgn.94.2020.05.30.09.07.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 May 2020 09:07:17 -0700 (PDT) Date: Sat, 30 May 2020 09:07:16 -0700 From: Kees Cook To: Al Viro Cc: Sargun Dhillon , christian.brauner@ubuntu.com, containers@lists.linux-foundation.org, cyphar@cyphar.com, jannh@google.com, jeffv@google.com, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, palmer@google.com, rsesek@google.com, tycho@tycho.ws, Matt Denton Subject: Re: [PATCH v2 2/3] seccomp: Introduce addfd ioctl to seccomp user notifier Message-ID: <202005300834.6419E818A7@keescook> References: <20200528110858.3265-1-sargun@sargun.me> <20200528110858.3265-3-sargun@sargun.me> <202005282345.573B917@keescook> <20200530011054.GA14852@ircssh-2.c.rugged-nimbus-611.internal> <202005291926.E9004B4@keescook> <20200530140837.GM23230@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200530140837.GM23230@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 30, 2020 at 03:08:37PM +0100, Al Viro wrote: > On Fri, May 29, 2020 at 07:43:10PM -0700, Kees Cook wrote: > > > Can anyone clarify the expected failure mode from SCM_RIGHTS? Can we > > move the put_user() after instead? I think cleanup would just be: > > replace_fd(fd, NULL, 0) > > Bollocks. > > Repeat after me: descriptor tables can be shared. There is no > "cleanup" after you've put something there. Right -- this is what I was trying to ask about, and why I didn't like the idea of just leaving the fd in the table on failure. But yeah, there is a race if the process is about to fork or something. So the choice here is how to handle the put_user() failure: - add the put_user() address to the new helper, as I suggest in [1]. (exactly duplicates current behavior) - just leave the fd in place (not current behavior: dumps a fd into the process without "agreed" notification). - do a double put_user (once before and once after), also in [1]. (sort of a best-effort combo of the above two. and SCM_RIGHTS is hardly fast-pth). -Kees [1] https://lore.kernel.org/linux-api/202005282345.573B917@keescook/ -- Kees Cook