Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1058210ybm; Fri, 29 May 2020 20:20:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylvYOYctCGwXsMF4GKgpvZGbxw1fRL2PS3hHDuqvppxEP1/AFAABjUHwA0goJkd9O7fGJY X-Received: by 2002:a05:6402:c2:: with SMTP id i2mr11435023edu.224.1590808812707; Fri, 29 May 2020 20:20:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590808812; cv=none; d=google.com; s=arc-20160816; b=W+5YIsTsmDzrqnHCpThNg+TrXsjVvITUzNfRn3EegqwKk0aIi1siEJtYgSCr7F2V5R YX2+QDzGWUEhvHGBiLUN4ex7igVJ6DoO9LwdjtfM6ekvMb8ERwKWDnb7GLkU0qJMV6G0 WchCohXbbXZLG76YUluX6DcClhimuUhTalIYNuasR2t8oC6uVUWpXV//hAbZr3WPOp2G RhE/sdGiOeFpvdhqJH6A14aMELqzMQpni+hyqe9bq5RDxGuJnk1ICJwPL3u8KnuFmiJS 4VnzMu63qSil97e9KzuORWGH8wTGJL3rCW0jXbGqYpsydGfs73wC1sBaFsSO7Zre0HCZ /d4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=qAzzi6iT/99Kzep9I6N6vUOQSaglX3NMEqv/R35zMzg=; b=bmAgUc9M3WapFGUBhtTxhaeJidTPXci56lxhhK6cBOuItXTVGVJwMM19eBhEI8MJPR AaWosrMY0Jm3Xkq9bbPEOVRSLQAh1PhYidi194Y4oVj9djaxENWLixPuXo7i1Jy1VFlv P76qLBUsTE3zPAxjvXOX0eVERObPRlw2w/mHIXVit4Te8I8dR86+TNDsPrtjrWRVc0XU X5PZAOEUu0VFKVJG9TkXexzrEXpHjm1BefMSh4k7j//+HvuV7HsCfbBHJZGUv1hputzo oTsjCNkyqaT5FKwQqoaZvxdbFWpDkBprW0FbJU1FhxsD1I4QuL1EX+g/Zo67b/C/1M2D oXOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=kMEJZWXT; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fy14si6759282ejb.628.2020.05.29.20.19.48; Fri, 29 May 2020 20:20:12 -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=@google.com header.s=20161025 header.b=kMEJZWXT; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728714AbgE3DR5 (ORCPT + 99 others); Fri, 29 May 2020 23:17:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728297AbgE3DR4 (ORCPT ); Fri, 29 May 2020 23:17:56 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14C55C08C5C9 for ; Fri, 29 May 2020 20:17:53 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id k5so1606171lji.11 for ; Fri, 29 May 2020 20:17:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qAzzi6iT/99Kzep9I6N6vUOQSaglX3NMEqv/R35zMzg=; b=kMEJZWXTCuXXpMzPmI1oXS8B+nPKTCFTFJeWDNanOkoeAWo0NajeLc14NLFwtXu7TD T1esDDSnFxgbWr9UHpuKYsKhwIEfcbW9guLsK7BEC3IU1PHw7e8Jo8W9QMRKDPcmexGH 2pL6zks1ywxdNUYWD9luZ3HodypdOe4QbDbeH054DV9+nVJURp47JX23CbAY9mms1WZy g32iddYT4guKgxTH6aECpechaohc+xsEXkXZUyd85nhD+Vu89iXgz5aTQwnUfQ0MGMTt KAucywSTUO+PUvGYPObqYElbCE7OapYyow/1m6glLRIq0ZYLtkXvHirthic91m514SKm oT8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qAzzi6iT/99Kzep9I6N6vUOQSaglX3NMEqv/R35zMzg=; b=S+8r7P6DL12SxnBEtq/PMWJh2YheIIE5MF/Vf5p436itgrmgAl48h5adYdX7stybwP 1pyQgC63LS2o8Q+aWh13O7FgR6zOg6rSxHo7DNlIFaP5xRWzh3RZaUofbxqooX2IXEj7 xFwD9p0Oee3q2CTK8++WDQGgOVlNWK1ikOuLxcEb69U5Auy8KdfEN0g2x/dj3CBkeRG0 459cdEn7MOFDgkDwiBfbjji+uK3LFU5W+jnxs+lDikuiSnkJUeEfrR0tC+NX0ooCHr6V gqLfCMzXFuS933ZRbYt60uxMIfP1//xaxveFpqDS4hHWE/v1/VqrDHoBX9dzsPryA5qa LsKw== X-Gm-Message-State: AOAM5334JjfOv6wNdE+Z6tnGw/+RPF9k9cjz4T8Pd/ju0ewXtWhcjAw5 kdIOLJ84d7/iLNxX4YY3bvXQ2CmHYP3zT/j+p8UkNA== X-Received: by 2002:a2e:1f02:: with SMTP id f2mr5178479ljf.156.1590808671140; Fri, 29 May 2020 20:17:51 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: <202005291926.E9004B4@keescook> From: Jann Horn Date: Sat, 30 May 2020 05:17:24 +0200 Message-ID: Subject: Re: [PATCH v2 2/3] seccomp: Introduce addfd ioctl to seccomp user notifier To: Kees Cook Cc: Sargun Dhillon , Christian Brauner , Linux Containers , Aleksa Sarai , Jeffrey Vander Stoep , Linux API , kernel list , Chris Palmer , Robert Sesek , Tycho Andersen , Matt Denton , Al Viro Content-Type: text/plain; charset="UTF-8" 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 4:43 AM Kees Cook wrote: > I mean, yes, that's certainly better, but it just seems a shame that > everyone has to do the get_unused/put_unused dance just because of how > SCM_RIGHTS does this weird put_user() in the middle. > > Can anyone clarify the expected failure mode from SCM_RIGHTS? Can we > move the put_user() after instead? Honestly, I think trying to remove file descriptors and such after -EFAULT is a waste of time. If userspace runs into -EFAULT, userspace is beyond saving and can't really do much other than exit immediately. There are a bunch of places that will change state and then throw -EFAULT at the end if userspace supplied an invalid address, because trying to hold locks across userspace accesses just in case userspace supplied a bogus address is kinda silly (and often borderline impossible). You can actually see that even scm_detach_fds() currently just silently swallows errors if writing some header fields fails at the end.