Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp562584ybt; Wed, 8 Jul 2020 06:34:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydTFEiBR5FfocgjuZq7NZtT/ek0evKoB6Dij4B9LGh+Auc1qTk7/CDOQoec8GKqJpvrrbq X-Received: by 2002:a50:f0c6:: with SMTP id a6mr14161660edm.374.1594215250962; Wed, 08 Jul 2020 06:34:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594215250; cv=none; d=google.com; s=arc-20160816; b=nZGzbUN3JFS2Gux1IjyZ7Ksf+DBVnN8y/IWPwtGGEJyGGd5aw9UDB+QxkbvfLqdS1d Gu0YcU5JlWg6lgpjaekSzEUbc09MOhmb52pqIgTJB1IJPZN1wXkGv8W2YHxvvBxcCrRT liAzBKaeUmnHV/NHpVptUP3Ol84DdlYcCgzkmk+RkDIUwcSi/e9XS/e4DmMc6sCtFbw0 n67mR5tNOFfETVTlBDtXfgMuJNoxZu3ndUzE7aEDifT42twPSIz8/E/Wx3wrr+FUWJgp VotSzV5a8o0DPigAxkGuSAD9c13T5qo1w+98wSmdgRNgrfgDd0AAKSsxavUYfmkdhq83 lK4g== 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=G3W3NkSnYhvVkNWYcmyRPWMbSJt95CSFGEsN8GxSyEw=; b=c6IPS4axG98Xj85K8jSwz1BCjj6Wxnl+rovzM07OCfObEbErffJm9TlGhYvFHNYwra lqzY9Fxf0ptzcaexvMW86OqNP6CZXpIscRiQ5cY6z2AGZE3zSj2F8q9wqC7N+pEvjAbc iUHs74YQNcnfuddzke4ZEPYNSyCFDF0SBDiyqRg6VDgqxGoB2sqypqeGXApECy0n4jxQ qruhFHJvXuRXym9dOCJ6lWjW2qRzGrKaIS/cE3RidmY4fZ1UEYRcLMaqcV2hzfl7cuL2 atcT8paWKdl8W7xki4ERzEe6ln/Q7jiMCGc0fF6ZfjjUUbIKu+AXcHu4/5MidMvgo21F TEaA== 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h17si1047228ejl.514.2020.07.08.06.33.47; Wed, 08 Jul 2020 06:34:10 -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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729588AbgGHNcy (ORCPT + 99 others); Wed, 8 Jul 2020 09:32:54 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:33707 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729323AbgGHNcx (ORCPT ); Wed, 8 Jul 2020 09:32:53 -0400 Received: by mail-pf1-f194.google.com with SMTP id m9so9717909pfh.0; Wed, 08 Jul 2020 06:32:52 -0700 (PDT) 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=G3W3NkSnYhvVkNWYcmyRPWMbSJt95CSFGEsN8GxSyEw=; b=mVanR3Whkf4arRJg+Thx4buqfyznr1htPmIEtMovYg8JU2x4Y0fUITkChQIPudh8fs IaFhf8DzAIITNTmXFtWk70Da3vB6SYOCXMOUwZ3XrGf04jz8aqKmtHQxZ9vXgXV/HV3A Y8FIcCnZLjSJM2XZQHLYxOaElpwgJHyDPqbSbthyXWUjBlnKVdTwY0KdIuyh0eh7YsjJ uXrHbeIS6GlGmGjEOH6m8O6RXXLIFsb0+EcyT+OWuftQv+J369LEHLIyzuHX1SY3Xanw 3h5k17dvLZilYwqfMN5Qvxqh6dzRc9I59PRmRNkuzAlkRUutb9ZeQBXoshmUkxAXtDer ew2g== X-Gm-Message-State: AOAM533d3i/ukNuyU4lsK1I//23MxoKIm+kvoMK9TRA1+JoEvoleeajw yb+OTEw3xRrL1HqERj9ZlNE= X-Received: by 2002:a62:7505:: with SMTP id q5mr50170680pfc.262.1594215171970; Wed, 08 Jul 2020 06:32:51 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id n25sm12846pff.51.2020.07.08.06.32.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2020 06:32:51 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 801FF401AE; Wed, 8 Jul 2020 13:32:50 +0000 (UTC) Date: Wed, 8 Jul 2020 13:32:50 +0000 From: Luis Chamberlain To: "Eric W. Biederman" Cc: Alexei Starovoitov , linux-kernel@vger.kernel.org, David Miller , Greg Kroah-Hartman , Tetsuo Handa , Kees Cook , Andrew Morton , Alexei Starovoitov , Al Viro , bpf , linux-fsdevel , Daniel Borkmann , Jakub Kicinski , Masahiro Yamada , Gary Lin , Bruno Meneguele , LSM List , Casey Schaufler , Linus Torvalds , Christian Brauner , Greg Kroah-Hartman Subject: Re: [PATCH v3 10/16] exec: Remove do_execve_file Message-ID: <20200708133250.GH4332@42.do-not-panic.com> References: <87y2o1swee.fsf_-_@x220.int.ebiederm.org> <20200702164140.4468-10-ebiederm@xmission.com> <20200708063525.GC4332@42.do-not-panic.com> <20200708124148.GP13911@42.do-not-panic.com> <87y2nugnnq.fsf@x220.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87y2nugnnq.fsf@x220.int.ebiederm.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 08, 2020 at 08:08:09AM -0500, Eric W. Biederman wrote: > Luis Chamberlain writes: > > > On Wed, Jul 08, 2020 at 06:35:25AM +0000, Luis Chamberlain wrote: > >> On Thu, Jul 02, 2020 at 11:41:34AM -0500, Eric W. Biederman wrote: > >> > Now that the last callser has been removed remove this code from exec. > >> > > >> > For anyone thinking of resurrecing do_execve_file please note that > >> > the code was buggy in several fundamental ways. > >> > > >> > - It did not ensure the file it was passed was read-only and that > >> > deny_write_access had been called on it. Which subtlely breaks > >> > invaniants in exec. > >> > > >> > - The caller of do_execve_file was expected to hold and put a > >> > reference to the file, but an extra reference for use by exec was > >> > not taken so that when exec put it's reference to the file an > >> > underflow occured on the file reference count. > >> > >> Maybe its my growing love with testing, but I'm going to have to partly > >> blame here that we added a new API without any respective testing. > >> Granted, I recall this this patch set could have used more wider review > >> and a bit more patience... but just mentioning this so we try to avoid > >> new api-without-testing with more reason in the future. > >> > >> But more importantly, *how* could we have caught this? Or how can we > >> catch this sort of stuff better in the future? > > > > Of all the issues you pointed out with do_execve_file(), since upon > > review the assumption *by design* was that LSMs/etc would pick up issues > > with the file *prior* to processing, I think that this file reference > > count issue comes to my attention as the more serious issue which I > > wish we could address *first* before this crusade. > > > > So I have to ask, has anyone *really tried* to give a crack at fixing > > this refcount issue in a smaller way first? Alexei? > > > > I'm not opposed to the removal of do_execve_file(), however if there > > is a reproducible crash / issue with the existing user, this sledge > > hammer seems a bit overkill for older kernels. > > It does not matter for older kernels because there is exactly one user. > That one user is just a place holder keeping the code alive until a real > user comes along. > > For older kernels the solution is to just mark the bpfilter code broken > in Kconfig and refuse to compile it. That is the trivial backportable > fix if anyone wants one. This seals the deal for me, thanks! Carry on, but hey, please add yourself to MAINTAINERS too :) Luis