Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2479599pxb; Mon, 11 Jan 2021 10:37:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJwMuSBGFwGUeeQb/TmcjziSXv6qN1d1hjTzHolnixz2CwsiVrMBJasKjkf3q+KC/KVoaQY2 X-Received: by 2002:a17:906:1a01:: with SMTP id i1mr548397ejf.315.1610390226759; Mon, 11 Jan 2021 10:37:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610390226; cv=none; d=google.com; s=arc-20160816; b=K43IRkAgMbdmb1wcRPr1RM5LyUs9YKXSmQprSvFIvmrnFqnSdhOJwca/xHzX/rm5Uk vD/u3I3WB2NnwFrFAfnc8nBHWu96R/57qtAvCSqTavlsPF0eyf+JUPOY5q5lR2ExnDW8 MiipZprXhKoQvM9P3hqF6+OmSVpIE2Npwj9NIQhsdpC4RRRMP+5EYyI/ZcCe9geA0rLS PNVbg8Ulo8evOzeNwuHSJUkUBlhEuyqx1UiA9tbOEv+z3KnL8Jh/CojUBCed0R9Zf0uq Dqg7Pwj/w7n1KbO4WXeJY1PVuCgs6WzyCDGfaEM85Vjg8MbU+j5GmESytSRf0KGM14WP 5RAA== 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=4GdBSUrpm58ToHKTls9IOMw+i4c1oYKehuTuyvH6rXI=; b=xqO9YpyoJ5hBtbLfAvuco8bG1JM+uRRkYB2V6gHJGFt55qrnxCeE2CddpPSle9SWRT MiA7z5geGxFIqjA6yuspVD+q8klqM+h1Nxxm2yrDzYGAaGVUZszbsLqWCSnAhVQCNKBG bmmJwvBl7BXJa++U3lXxGxtBuiM1LGgMWCtc1Wi87CGxpf1D03np4drG5Ko42N6yTqq4 +1QvFRnBUzoTaoPs6mklv7N8Ke5FCFd7IYja1dPPq5Hm91yyYOjmnBHpvA3eMLcVaxNo PCTVed5hBT7X+ARsf37RwlPNM0uToZJxOBHL+2x27nh5dINR0FA8KLz8hzjkkvDVLyPo SgVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bpYEjWwA; 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 h4si223188edf.490.2021.01.11.10.36.43; Mon, 11 Jan 2021 10:37:06 -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=bpYEjWwA; 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 S1730937AbhAKSeU (ORCPT + 99 others); Mon, 11 Jan 2021 13:34:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726986AbhAKSeU (ORCPT ); Mon, 11 Jan 2021 13:34:20 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 504BBC061786 for ; Mon, 11 Jan 2021 10:33:40 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id m6so466404pfk.1 for ; Mon, 11 Jan 2021 10:33:40 -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=4GdBSUrpm58ToHKTls9IOMw+i4c1oYKehuTuyvH6rXI=; b=bpYEjWwAhYDf6NfLaHwrtedqGAyLGuBu3WdELiQ1qCHr74NrZzUqZLmSkttMy+B3+n M/QpiKzcciLYrNQsryiRWzORjy+5YkIaF1CGoSzWqv3VlZXeTbXJg4ayVyuOj43VhfnY W2Iw2hu4K6DrZwgLEcDWCmh5b34LnhLNP5kaQ= 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=4GdBSUrpm58ToHKTls9IOMw+i4c1oYKehuTuyvH6rXI=; b=XdWV/wEuUmuzl1sCjZoImVWAynuRsEn85bTKv3QwJjPI2WTsijsoV1k2h8dVhy+IIY 2XINhUPQnfDApikR/Pu7dgmiRRbjdsLKkhQVTL6HUm+aXjB/l1FjOXCf2t/UrmNMpVq7 ERi9uuTz+z0LVmmIDwCsdnSuYY9YEbbUJZFwZhblI3NpJazvJld8n1KH19WlvY364Xtg Bs7CSL1S1WLtFecwevhV96VH0/oUITk+ZmdOWSzVJmoTKHgvWt9CP2poXdKGYg/uYuWB 5onhNECIq7tsp+ukWbxkz9J1KdWQ5R2FT/5QAx7xJTaj/03hMclpZXkwKJNFrRVqkjaQ bi2w== X-Gm-Message-State: AOAM530JVZRYLeeDmSx+A9wscDbbrrGEmkyVNup+LP+EED2RtdxnFbcQ CAPpMxz281zJG1VoTlMKresroA== X-Received: by 2002:a63:5942:: with SMTP id j2mr810948pgm.33.1610390019873; Mon, 11 Jan 2021 10:33:39 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id fs12sm77488pjb.49.2021.01.11.10.33.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jan 2021 10:33:39 -0800 (PST) Date: Mon, 11 Jan 2021 10:33:38 -0800 From: Kees Cook To: Suren Baghdasaryan Cc: akpm@linux-foundation.org, jannh@google.com, 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: <202101111033.2D03EA97@keescook> References: <20210111170622.2613577-1-surenb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210111170622.2613577-1-surenb@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 11, 2021 at 09:06:22AM -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. > > Signed-off-by: Suren Baghdasaryan Reviewed-by: Kees Cook -- Kees Cook