From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E0E418643 for ; Thu, 18 Jul 2024 01:51:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721267513; cv=none; b=IqPF2S/QqPdV6nnjX+rsO6cHeqx5c73PIzEQ8D5BxS98AMy0xMj1lGlFf3t+3CbSrFsaUrabf2kmRqb8mJBVbrWNX3a+EqxtFziLJeu/bJst8xBR09tdIDLjvpwT+XMxlj4uugOeDUNF3iISj6gjk1TxNnSn1PwCTkfWbGQKdy0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721267513; c=relaxed/simple; bh=ncicT0K3UO60xiU/mIKg6ElpM+86+19R0KeSAIhcXsg=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=oKmMjo26nbOnB93PY1l1HT7PiO87gp7f0ZrD9r1jJA8P7S3rweMxz0Gko6vmH5m7pfTgBsggozKm7pCLqcozt0w/n2EblbNmu81gCI7edbi2umwxDyetvLU1sPHIbHw6xCGLZlZgQlS0kXfpGndbHiPCn9DhZIjwjgeqqc6JRLw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=kbHQFiwc; arc=none smtp.client-ip=209.85.208.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kbHQFiwc" Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-58ce966a1d3so4440a12.1 for ; Wed, 17 Jul 2024 18:51:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721267510; x=1721872310; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=FJZ63+KcodZOUJ9CCw+HbTDjxj9KTImYwSLlP4nPFDI=; b=kbHQFiwcwFZRRkAFfthpG6oS423MPU9p30ghgAk9MlSynHXK9+FxL8iYTGeeSjrghB LL1QKczu9z0LBXj/WZnx43oseAt+qBxVoziav/P2QzurgJBiE9YL0O3Vfx6yKW2mlleM vzKd7p3I3NV3a1zLyfpA43qZMnTShb2g34Fsmw4MPJGO89lUSjqsf2GnTFXkaWgOQE6B +nmoBcUMs5ZhLTx4eOvomQAg1a6ULSPES/vApXAWpse5/bgPYlnzSWdRQY4r9kUjgjiv ObS99NLKk14K63xKBZSEoZMlC3MRWUhstsO02owfX4z+ly8hUmsTKt4glJ93qltjWOIE 4Vxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721267510; x=1721872310; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FJZ63+KcodZOUJ9CCw+HbTDjxj9KTImYwSLlP4nPFDI=; b=vMqsq/7lIL2lgx6pB/mxNVEGkh6FyKRqRKHIs6+JcULbFukXnOinWdXCZB1r5U/6WW 6dSU/volhONtxiY4DnYzIX6Q7SVomJXcD9kT+2YmrdSfqbThRsHg36Hq7hwh0XozOKRe 2Hc11np+G+qBri380lz3yk+iqMMYjV7iuzvazm/rJJEz36jTQ2b0c+zCSICdzv+eJW3e 7ZUunBit//acDF04fCSjmPFUsba/J+sdCowP/3yCzORmI8cFtEShZHKl+XD2M0BoG9ZY eNcZ2xibx2MHzOJW4Xw+HlFncXssv7aaBhGmBQ7aBLy2eQmgAA9MwU04SJRngxVuzVA5 DigQ== X-Forwarded-Encrypted: i=1; AJvYcCW4Um1lZMGk9RkM814JVMau+wvGvc3JDQe3p79iyahXlFWd1gppuu4z+Vta2Ws4TSiyxOMENYmIiDYOARr8HkFcn5SbEvbQyJ3H X-Gm-Message-State: AOJu0YzKc501hfoTCfbx0YCmP62tPeNTz9hVJagJcdy8PRj8MKsfX+Bp QoWMO8sAJuBUt/2PM0Kw70cBUzkioH9fDPYSZ3fKkyVbCQOzPfE99iEahnSj3ssZgQ8igUrfR/t bHKwaHkwMsl4CdFFHFFY9jyj7rZFnVYqzJY14 X-Google-Smtp-Source: AGHT+IH9jcKAI8n2GbWdrtyqQO31S0/aF0VaU5hERSsdL1d154MSEshBIghoJbVRDz92Y4QOgC4k+74aIDfa+EXvDTY= X-Received: by 2002:a05:6402:254f:b0:58b:93:b623 with SMTP id 4fb4d7f45d1cf-5a1afc473bdmr44730a12.5.1721267509612; Wed, 17 Jul 2024 18:51:49 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-api@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240704190137.696169-1-mic@digikod.net> <20240704190137.696169-2-mic@digikod.net> <20240717.AGh2shahc9ee@digikod.net> In-Reply-To: <20240717.AGh2shahc9ee@digikod.net> From: Jeff Xu Date: Wed, 17 Jul 2024 18:51:11 -0700 Message-ID: Subject: Re: [RFC PATCH v19 1/5] exec: Add a new AT_CHECK flag to execveat(2) To: =?UTF-8?B?TWlja2HDq2wgU2FsYcO8bg==?= Cc: Steve Dower , Al Viro , Christian Brauner , Kees Cook , Linus Torvalds , Paul Moore , "Theodore Ts'o" , Alejandro Colomar , Aleksa Sarai , Andrew Morton , Andy Lutomirski , Arnd Bergmann , Casey Schaufler , Christian Heimes , Dmitry Vyukov , Eric Biggers , Eric Chiang , Fan Wu , Florian Weimer , Geert Uytterhoeven , James Morris , Jan Kara , Jann Horn , Jonathan Corbet , Jordan R Abrahams , Lakshmi Ramasubramanian , Luca Boccassi , Luis Chamberlain , "Madhavan T . Venkataraman" , Matt Bobrowski , Matthew Garrett , Matthew Wilcox , Miklos Szeredi , Mimi Zohar , Nicolas Bouchinet , Scott Shell , Shuah Khan , Stephen Rothwell , Steve Grubb , Thibaut Sautereau , Vincent Strubel , Xiaoming Ni , Yin Fengwei , kernel-hardening@lists.openwall.com, linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Elliott Hughes Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jul 17, 2024 at 3:00=E2=80=AFAM Micka=C3=ABl Sala=C3=BCn wrote: > > On Wed, Jul 17, 2024 at 09:26:22AM +0100, Steve Dower wrote: > > On 17/07/2024 07:33, Jeff Xu wrote: > > > Consider those cases: I think: > > > a> relying purely on userspace for enforcement does't seem to be > > > effective, e.g. it is trivial to call open(), then mmap() it into > > > executable memory. > > > > If there's a way to do this without running executable code that had to= pass > > a previous execveat() check, then yeah, it's not effective (e.g. a Pyth= on > > interpreter that *doesn't* enforce execveat() is a trivial way to do it= ). > > > > Once arbitrary code is running, all bets are off. So long as all arbitr= ary > > code is being checked itself, it's allowed to do things that would bypa= ss > > later checks (and it's up to whoever audited it in the first place to > > prevent this by not giving it the special mark that allows it to pass t= he > > check). > We will want to define what is considered as "arbitrary code is running" Using an example of ROP, attackers change the return address in stack, e.g. direct the execution flow to a gauge to call "ld.so /tmp/a.out", do you consider "arbitrary code is running" when stack is overwritten ? or after execve() is called. If it is later, this patch can prevent "ld.so /tmp/a.out". > Exactly. As explained in the patches, one crucial prerequisite is that > the executable code is trusted, and the system must provide integrity > guarantees. We cannot do anything without that. This patches series is > a building block to fix a blind spot on Linux systems to be able to > fully control executability. Even trusted executable can have a bug. I'm thinking in the context of ChromeOS, where all its system services are from trusted partitions, and legit code won't load .so from a non-exec mount. But we want to sandbox those services, so even under some kind of ROP attack, the service still won't be able to load .so from /tmp. Of course, if an attacker can already write arbitrary length of data into the stack, it is probably already a game over.