Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5543380pxb; Wed, 26 Jan 2022 14:37:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxyypHqi2RkTELeb8S1WCTmF1EVpawMGgBhDJV3VgjNDfDUQ7dOI4oR3B82ICzORAF3BP2g X-Received: by 2002:a05:6402:37a:: with SMTP id s26mr1064265edw.400.1643236636223; Wed, 26 Jan 2022 14:37:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643236636; cv=none; d=google.com; s=arc-20160816; b=ClTrqd/PgJKU3Sx9DBGF6/U0lNVFEvpakPCnE+v/Y5a46p03iB7pupi/qiY0nk13rh CaNnIzI0mwQ6VOCfjCoJU647KcjljWHQ/ZQu/ckeSXz1f18sYcseqrgYaM87bJYwI7tW ZRJNNJyBgVBR0dWqMlCE13ylJph2xXG+kwnS6nq2y9NDsrEtk0mwsGp0l+xt32FPLBhR AGGr9wb469F4bvaEPt7rjuws0u5/yHma964df5kymIJj5/Onr8W4nwqDj7NNCYoela9B HTIiuhYf8EBFXOqpYwSi8WXinMFt3lL9jtAJT5hnMMWexP/dcM4GTMy6eUSt+pKYuLAx XCfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Wj7KZuqwaOnmEdiVWVR69LpJrxWukw8SVQkUC4MLo7s=; b=sAL3/UQ57e1lMLaw82ispRioG5JELZ1Pi0LGN2GaqkhkN/csvdiRUTcAujaZ9ztXiu oXL/ouVgpvBW/NZyh7X1OxpcI8Bo8dXcybSHATXZYrL1B1Enr/ikqBmGBvAOPFGwlXki I7vnIFNfGcAp7ookxXsGzuk0tVKsJXjwWu03xa20QNxEAfZdr1kw7j1c74m9WYoJLuae LzuuWAPjkhCSEFpLx+LxyWb+DH5I4l5Oth9HWkEFr+MNs8fT5SKpZv/hNLNcgs82O+R6 uAhbQOMwHX4wxjCDjsUhbTwKkPw1sXpKxu0GdVjKckTGWgYPzlAYrN8zxMk5CfRaRC45 7/7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JIYMQZEu; 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 b18si308999edd.407.2022.01.26.14.36.50; Wed, 26 Jan 2022 14:37:16 -0800 (PST) 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=JIYMQZEu; 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 S230099AbiAZUNS (ORCPT + 99 others); Wed, 26 Jan 2022 15:13:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230082AbiAZUNS (ORCPT ); Wed, 26 Jan 2022 15:13:18 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 032FDC061748 for ; Wed, 26 Jan 2022 12:13:18 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id d1so561328plh.10 for ; Wed, 26 Jan 2022 12:13:17 -0800 (PST) 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=Wj7KZuqwaOnmEdiVWVR69LpJrxWukw8SVQkUC4MLo7s=; b=JIYMQZEueLmr/Bcu+0hn3GJkYnsMrkdWIxCMlEUBwg4HvJdd/pwwuuoFtclMne7x5f mBVWpQjR6YOrZexhCa/idsq6RSWlTK3VUS8Gft1RQQprU/wPVUmHmVKlGriHabfjGlyZ RSlRONtD2MuECMp9iPdBrJw00YjCmXqbC1UPc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Wj7KZuqwaOnmEdiVWVR69LpJrxWukw8SVQkUC4MLo7s=; b=6ZEOV77ZhZJOfFOiq35EGUosM0oiY3rbdMs1GTekLvXY9CMQ+N1axgglxzSWxFr5kk Qqo9+4WGaHcs6S1aytZIaAVSIkCKeibwKHjjtOKqi2W1DrUGwUCJVNq5k2WfzoCbvdnB 03+W/319nBiobpotkLAHjuvF0Oww0i8xMGtVS67FGGKlKPV9DQ89Dvbb4255vJtJTv8x H4dHh095cPoeTJ4ZS1kSViE1rdfqyIZzdi4TgxSIY+RgCjeA4YCSPmrPlrLBdDTWU5qA VKRc7+cEbwaorgcPUbSQJjGkoHyqN+vqgdd3Vq/suJM/Fhheg6f7fi9HtCetOPpX5pA7 uUUw== X-Gm-Message-State: AOAM533WeNCU5yOyqTj1QOPnfoCdI3bGrGRhhPJfTBISqWBKR0MKYlrg 2mRKAF938taceGM6u9nyuQlJvP5FxqzF6Q== X-Received: by 2002:a17:902:8f8a:: with SMTP id z10mr618939plo.59.1643227997497; Wed, 26 Jan 2022 12:13:17 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id d8sm3195141pfv.64.2022.01.26.12.13.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jan 2022 12:13:17 -0800 (PST) Date: Wed, 26 Jan 2022 12:13:16 -0800 From: Kees Cook To: Matthew Wilcox Cc: Jann Horn , Ariadne Conill , Michael Kerrisk , Christian Brauner , Rich Felker , Eric Biederman , Alexander Viro , linux-fsdevel@vger.kernel.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] fs/binfmt_elf: Add padding NULL when argc == 0 Message-ID: <202201261210.E0E7EB83@keescook> References: <20220126175747.3270945-1-keescook@chromium.org> <202201261157.9C3D3C36@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 26, 2022 at 08:08:14PM +0000, Matthew Wilcox wrote: > On Wed, Jan 26, 2022 at 11:58:39AM -0800, Kees Cook wrote: > > We can't mutate argc; it'll turn at least some userspace into an > > infinite loop: > > https://sources.debian.org/src/valgrind/1:3.18.1-1/none/tests/execve.c/?hl=22#L22 > > How does that become an infinite loop? We obviously wouldn't mutate > argc in the caller, just the callee. Oh, sorry, I misread. It's using /bin/true, not argv[0] (another bit of code I found was using argv[0]). Yeah, {"", NULL} could work. > Also, there's a version of this where we only mutate argc if we're > executing a setuid program, which would remove the privilege > escalation part of things. True; though I'd like to keep the logic as non-specialized as possible. I don't like making stuff conditional on privilege boundaries if we can make it always happen. -- Kees Cook