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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 6BBE9C433E1 for ; Wed, 8 Jul 2020 23:50:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44E9F206DF for ; Wed, 8 Jul 2020 23:50:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="EAcptXzM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726261AbgGHXuA (ORCPT ); Wed, 8 Jul 2020 19:50:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725972AbgGHXt7 (ORCPT ); Wed, 8 Jul 2020 19:49:59 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AE89C08C5DD for ; Wed, 8 Jul 2020 16:49:59 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id t11so168034pfq.11 for ; Wed, 08 Jul 2020 16:49:59 -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=cdJJ5r+BqrO/qlRhUW7k9YoabQA26UHQQU/lmrdCNU4=; b=EAcptXzMsr1BjEYa7HxVxUcyj7xGkNKAxC/wx6vNj8tkfFUUxRBx3kh2osiH2ygzSu 24N0CWKIE2/80wUBSTofZfsEQZmaI/UlZbqNRTvSJsi7sxB+rDv+7Xq9NWvYcl3aVPj1 6CB4n/ImV3QbEW7DMQrcK0PGK2lqSaxgZEuPc= 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=cdJJ5r+BqrO/qlRhUW7k9YoabQA26UHQQU/lmrdCNU4=; b=F6WsD0DjV0wb3U/rLv3HpuB4+Dzn1A+YgDxZbP4TGWz+mT9myPKaxj4pwD1DXnAuxW ChEhbkBPVezatrbSVbL0cOlf/tG3VMWGBgaDa7vmMp7DDjwMoVl4kuLW5A2At2hWkeLY Rkz5vFiadIWoUuFqyFgS3pb+zq2lqUb+XhHyB9LaJIHM1K6/1NSQhdsk8cUpcTaCNkGo 7LXopCUjrWYx/raNA9J+c0qUQDUT8z2dMuFdX0Rxhi7fcjs5qbPz4hrbNuVtVVlggNdp 2LNg6QUw0fZXZ0l0/3kO/YuVLRDbH7j5qTKVnP2TJh2NeGSUwboVkVTVo3XqLyTOUOea IH2Q== X-Gm-Message-State: AOAM531c2TY7hsMTLWw884PsSCcfic9M/AdDuOPMILeOdn4zEM5JBlyB XfEbnBIFoEa0e0GDaCkcOWk7Iw== X-Google-Smtp-Source: ABdhPJysfVsNKGkbpEgU6PL7cKFI4ZUeAqpmCKgcJfT0/XsmRTdUaHLhXN8y1mNfMbIwEs/yIdK84Q== X-Received: by 2002:aa7:98c6:: with SMTP id e6mr56705310pfm.17.1594252198968; Wed, 08 Jul 2020 16:49:58 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id t29sm781588pfq.50.2020.07.08.16.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2020 16:49:58 -0700 (PDT) Date: Wed, 8 Jul 2020 16:49:57 -0700 From: Kees Cook To: Christian Brauner Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, Sargun Dhillon , Christian Brauner , Tycho Andersen , David Laight , "David S. Miller" , Jakub Kicinski , Alexander Viro , Aleksa Sarai , Matt Denton , Jann Horn , Chris Palmer , Robert Sesek , Giuseppe Scrivano , Greg Kroah-Hartman , Andy Lutomirski , Will Drewry , Shuah Khan , netdev@vger.kernel.org, containers@lists.linux-foundation.org, linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH v6 4/7] pidfd: Replace open-coded partial receive_fd() Message-ID: <202007081649.622969AAFB@keescook> References: <20200706201720.3482959-1-keescook@chromium.org> <20200706201720.3482959-5-keescook@chromium.org> <20200707122220.cazzek4655gj4tj7@wittgenstein> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200707122220.cazzek4655gj4tj7@wittgenstein> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 07, 2020 at 02:22:20PM +0200, Christian Brauner wrote: > On Mon, Jul 06, 2020 at 01:17:17PM -0700, Kees Cook wrote: > > The sock counting (sock_update_netprioidx() and sock_update_classid()) was > > missing from pidfd's implementation of received fd installation. Replace > > the open-coded version with a call to the new receive_fd() > > helper. > > > > Thanks to Vamshi K Sthambamkadi for > > catching a missed fput() in an earlier version of this patch. > > > > Fixes: 8649c322f75c ("pid: Implement pidfd_getfd syscall") > > Reviewed-by: Sargun Dhillon > > Signed-off-by: Kees Cook > > --- > > Thanks! > Acked-by: Christian Brauner > > Christoph, Kees, > > So while the patch is correct it leaves 5.6 and 5.7 with a bug in the > pidfd_getfd() implementation and that just doesn't seem right. I'm > wondering whether we should introduce: > > void sock_update(struct file *file) > { > struct socket *sock; > int error; > > sock = sock_from_file(file, &error); > if (sock) { > sock_update_netprioidx(&sock->sk->sk_cgrp_data); > sock_update_classid(&sock->sk->sk_cgrp_data); > } > } > > and switch pidfd_getfd() over to: > > diff --git a/kernel/pid.c b/kernel/pid.c > index f1496b757162..c26bba822be3 100644 > --- a/kernel/pid.c > +++ b/kernel/pid.c > @@ -642,10 +642,12 @@ static int pidfd_getfd(struct pid *pid, int fd) > } > > ret = get_unused_fd_flags(O_CLOEXEC); > - if (ret < 0) > + if (ret < 0) { > fput(file); > - else > + } else { > + sock_update(file); > fd_install(ret, file); > + } > > return ret; > } > > first thing in the series and then all of the other patches on top of it > so that we can Cc stable for this and that can get it backported to 5.6, > 5.7, and 5.8. > > Alternatively, I can make this a separate bugfix patch series which I'll > send upstream soonish. Or we have specific patches just for 5.6, 5.7, > and 5.8. Thoughts? I was thinking of just tossing the entire series (hch's and mine) at -stable since it's relatively narrow. I'll look at what's needed for backports... > > Thanks! > Christian -- Kees Cook