Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp667611ybs; Sun, 24 May 2020 17:38:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8TBsHGVRALGe0Sjg9+2ldDtPvSwKM9FUbawT2mDvMUncchgD+NfS8UM5r3Hkt2wswBZnk X-Received: by 2002:a17:906:4995:: with SMTP id p21mr17058199eju.19.1590367125651; Sun, 24 May 2020 17:38:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590367125; cv=none; d=google.com; s=arc-20160816; b=VgiH/pPHV3mw4d3bhOIKNGamIURojK09G0YUUHw94/Z46t/NeiK0EyPhID/WRyh+/x 3T1tTa3hUi4neLGG1joU2iuK36QWFx2SyHJrdYnoF38biKLAbNODufDJOo4M/3fqcUkS 9i5xlGfmAPVfO/pZime3sWTZnvUv34OZp2rpuBcx1WSA+euMmP+NGoZS8HohQsl+eJbP 2SuSScoHqwpIStPFQzkNs7q+3dpPj89tmU4XY1pcNKAkXnVWv2sUKE1bKItCxr3FY+79 /2W8bH+1J7pILrgYMQMxdkEVJjhOu+X59iJgmVFFHUT9tImMRV+w7NVXhTcvLrL51VtZ q8mQ== 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=Ujgmu6qsF8KjwF0asTJwlN/jtHorDxcj3S3k6D7sfR4=; b=yDO0KAgjceXE86c/k9Q5Cp4uNYvRAl/b5o7bQvCMD1W9zqmA+OG1x9rw946JdrURWt VZJ3H2+NPX9yIvuZfJpuwjjpnJG4pqLXy9g3A07feS7mTTZgI+/dF+5lrT3GsprG0W0E hbJVHqV6N7cpFDbAHE/OC6ThAb5psZFKirsfDOeY05HnVhQFIZlrv47EY0biEVDvdlhs IN9fWg4hs5akbcEd+CRXi2yrVBSwUp8gPS9+Y2tjU67EfR29/XJ8+oUrJ0wg4dTIyZYw oQSDOKHTtBS0jL4Gz3/3FTdkZSZZAWXl9rt1O47wIgF863E5dX1wXIp3LIEgwUwQt/Q5 Oxvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b=jV5abBUX; 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 l13si8386457edw.21.2020.05.24.17.38.22; Sun, 24 May 2020 17:38:45 -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=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b=jV5abBUX; 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 S2388600AbgEXX6f (ORCPT + 99 others); Sun, 24 May 2020 19:58:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388559AbgEXX6f (ORCPT ); Sun, 24 May 2020 19:58:35 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7992C05BD43 for ; Sun, 24 May 2020 16:58:33 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id b18so12661222oti.1 for ; Sun, 24 May 2020 16:58:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tycho-ws.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Ujgmu6qsF8KjwF0asTJwlN/jtHorDxcj3S3k6D7sfR4=; b=jV5abBUXtxyNey4FdgLuz5aknabD6HeVYSYsWWwVfhdAice2CVc4CA1W3B8auInwQE gnOuh9u7VPvwRnOLAx237unvR/r7zl/5Kg7025KjFSFCaS8HVAh71QRYqSlZX7UXNjQw 77qmB+EB6hxMeAUPgbtrBZUHtGeWEAn+tQdTkU8cbUc71pT8kG8Gd2pCSXYvqOy1tXMh 5MUMduFTA7+8GH/fZdRiZe5vl8bQKE+8p1ppqmDfc1llEvjph0KccZ6dx9AQPJN7GUco itgSd4SND67rD4CZXVhq5tZeI3YHToadTvsEjq+7QezEaPQ4yYBLEZzGe6jIlDOz1pbJ bQWw== 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=Ujgmu6qsF8KjwF0asTJwlN/jtHorDxcj3S3k6D7sfR4=; b=m2Nsot6rYydnrsaAeCsTQBMeNxOnKEEyVz5HNoWVRFu+y8z8LLS7bWrK6O2R0uJkJo jwXWLVg54EzdTR/ocsEdcZCAOjm09O21XKIBFH1wgvAIcYIii1TJnVK8FG/vpOz9el6I Rlt+liWZFeF8dnbcb5/qjq8Mzp4LyJDWGFLQyuDQS+ZPzSoFSRpG6RDyyCdIqPR5woHQ SHyHfx05yk98/y7UCNYO5eYWBKx+0TZAXdhtd59z5a25fp+E858yjpIQYaBxm7QFUzO8 eBmujIvJkSzrxY4xT3qI02LOSWbXsCI6kn6/aW49BtWKhr9+ii6W3xDzeBYfCny58iIN 7MMA== X-Gm-Message-State: AOAM530GkJn8X1uOj4NiSyFitD1IhwBst+4h00A+iUqKj5F25tVrq3Az GVLU34loZpTuoVpJnJJEyyp65g== X-Received: by 2002:a9d:785a:: with SMTP id c26mr18109817otm.39.1590364713095; Sun, 24 May 2020 16:58:33 -0700 (PDT) Received: from cisco ([2601:282:b02:8120:e9d7:5ec6:88ea:b4a1]) by smtp.gmail.com with ESMTPSA id c184sm4808180oif.3.2020.05.24.16.58.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2020 16:58:32 -0700 (PDT) Date: Sun, 24 May 2020 17:58:34 -0600 From: Tycho Andersen To: Sargun Dhillon Cc: linux-kernel@vger.kernel.org, containers@lists.linux-foundation.org, linux-api@vger.kernel.org, christian.brauner@ubuntu.com, keescook@chromium.org, cyphar@cyphar.com, Jeffrey Vander Stoep , jannh@google.com, rsesek@google.com, palmer@google.com, Matt Denton , Kees Cook Subject: Re: [PATCH 2/5] seccomp: Introduce addfd ioctl to seccomp user notifier Message-ID: <20200524235834.GJ2605652@cisco> References: <20200524233942.8702-1-sargun@sargun.me> <20200524233942.8702-3-sargun@sargun.me> <20200524235732.GI2605652@cisco> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200524235732.GI2605652@cisco> 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:57:32PM -0600, Tycho Andersen wrote: > On Sun, May 24, 2020 at 04:39:39PM -0700, Sargun Dhillon wrote: > > +static void seccomp_handle_addfd(struct seccomp_kaddfd *addfd) > > +{ > > + int ret; > > + > > + /* > > + * Remove the notification, and reset the list pointers, indicating > > + * that it has been handled. > > + */ > > + list_del_init(&addfd->list); > > + > > + ret = security_file_receive(addfd->file); > > + if (ret) > > + goto out; > > + > > + if (addfd->fd >= 0) { > > + ret = replace_fd(addfd->fd, addfd->file, addfd->flags); > > + if (ret >= 0) > > + fput(addfd->file); > > + } else { > > + ret = get_unused_fd_flags(addfd->flags); > > + if (ret >= 0) > > + fd_install(ret, addfd->file); > > + } > > + > > +out: > > + addfd->ret = ret; > > + complete(&addfd->completion); > > +} > > My previous comment about SCM_RIGHTS still applies, right? That is, we > should do, > > sock = sock_from_file(fp[i], &err); > if (sock) { > sock_update_netprioidx(&sock->sk->sk_cgrp_data); > sock_update_classid(&sock->sk->sk_cgrp_data); > } > > and perhaps lift that into a helper. Oh, and now I see the later patch. But is there a reason to separate these? I can't think of one. Tycho