Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2956478pxb; Tue, 12 Jan 2021 02:50:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzSFI4imflH+bb12Icw9BKmXCkNKaZqEst6H19CSJR5cu41MZVLAyb0kGjJQTKiDXdACeJQ X-Received: by 2002:aa7:c2d8:: with SMTP id m24mr2881435edp.300.1610448608579; Tue, 12 Jan 2021 02:50:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610448608; cv=none; d=google.com; s=arc-20160816; b=rpGA3nH0xafU4JK9chg9jzsPfoqiYdXcwOu+Gne78MhVRCGgHjMjMy5yZQnsqYl0Px 0Et25p1ptgsxRYkNfC++6KPu465TbKd7cfrEkH1oqItZhqgJ7QtfCvnrwbrMkRJX0gEr Eq0w43bDDyjFOi7zQLhZ0b4sh1ER334vkhxRy923u6cBo5rKCfvo4KTiWBCfgBUzrFmO a23B390PkwawLRJdp+dRYL7ox1ufBYIrAGam33pCXXOkd/K0NjoZYAFlkcATaUsekDrM +PFenybbR7783xYr9RUJXGsWHybj8t9WnagtjGxwwazTB5p1uGTvG09DuEu+pQ6doUsA R+ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=fLNQgllo3ZCC89DtTE5b6OoK2bTVUyylbTOPyId0eV4=; b=y+7uMCm8u+Ck+TwBTp4Co4ZJZaMlnQAx4HFPM91I8VSPk+BmIuWAjLdyX9uJPIe+lp j3nZ0KxwITgIxo6id064m3IixiecWBxxeoD/Pe4AYxJ0LBMVKv7DPzF0Hh92T/IR3E7v QV9PRTVZW+bE2j/D9vCfAtszgjBK5/q6XUqZYiO3T8H4Q2AR1CIgTts6wmrixkWlXKiq krdoyFk8u9EFdfgGF+5upw8ynb1juGXTnUbRByWSFVPSPjhlaBTYu1udlC6BZWL9Dz3B N5UCmOLsel0GuZO2b/iGLJSdjK8aSm9Yik94Ah9tSweitxF9k+WmN/lZ603TRuvF2t2U M4eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=obUs4N4o; 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 a1si1125942ede.520.2021.01.12.02.49.45; Tue, 12 Jan 2021 02:50:08 -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=@linux-foundation.org header.s=korg header.b=obUs4N4o; 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 S1729343AbhALBWz (ORCPT + 99 others); Mon, 11 Jan 2021 20:22:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:52842 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729129AbhALBWy (ORCPT ); Mon, 11 Jan 2021 20:22:54 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D4FD122E02; Tue, 12 Jan 2021 01:22:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1610414534; bh=fLNQgllo3ZCC89DtTE5b6OoK2bTVUyylbTOPyId0eV4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=obUs4N4o5mwnHVY9rYZZwXnXS8Rn/+2bqeLExSBNmLFsy9ruDGHnQziwu81t3OtpB PCgTuMFGUgwQ4wliyDaARt6hTTmnxw/q/pER+IErGNWBm56XeOCFS8usUIIULFFbFS agjczPAoQHs0WnCYRFSNbfsIqDiUY4VZ6Mq3u99c= Date: Mon, 11 Jan 2021 17:22:13 -0800 From: Andrew Morton To: Suren Baghdasaryan Cc: jannh@google.com, keescook@chromium.org, jeffv@google.com, minchan@kernel.org, mhocko@suse.com, shakeelb@google.com, rientjes@google.com, edgararriaga@google.com, timmurray@google.com, linux-mm@kvack.org, selinux@vger.kernel.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH v2 1/1] mm/madvise: replace ptrace attach requirement for process_madvise Message-Id: <20210111172213.ab4185a1de916c35f3245021@linux-foundation.org> In-Reply-To: <20210111170622.2613577-1-surenb@google.com> References: <20210111170622.2613577-1-surenb@google.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 11 Jan 2021 09:06:22 -0800 Suren Baghdasaryan wrote: > process_madvise currently requires ptrace attach capability. > PTRACE_MODE_ATTACH gives one process complete control over another > process. It effectively removes the security boundary between the > two processes (in one direction). Granting ptrace attach capability > even to a system process is considered dangerous since it creates an > attack surface. This severely limits the usage of this API. > The operations process_madvise can perform do not affect the correctness > of the operation of the target process; they only affect where the data > is physically located (and therefore, how fast it can be accessed). > What we want is the ability for one process to influence another process > in order to optimize performance across the entire system while leaving > the security boundary intact. > Replace PTRACE_MODE_ATTACH with a combination of PTRACE_MODE_READ > and CAP_SYS_NICE. PTRACE_MODE_READ to prevent leaking ASLR metadata > and CAP_SYS_NICE for influencing process performance. It would be useful to see the proposed manpage update. process_madvise() was released in 5.10, so this is a non-backward-compatible change to a released kernel. I think it would be OK at this stage to feed this into 5.10.x with a cc:stable and suitable words in the changelog explaining why we're doing this. Alternatively we could retain PTRACE_MODE_ATTACH's behaviour and add PTRACE_MODE_READ&CAP_SYS_NICE alongside that.