Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp3242269pxb; Tue, 12 Jan 2021 09:39:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRYCOl5vbVw3cejYUPyIEprwyb+4CIR+vkTGR1GYfQaJBhL5vBju/9RfXZr62WlWv2DFqH X-Received: by 2002:a17:906:9452:: with SMTP id z18mr4020116ejx.389.1610473183556; Tue, 12 Jan 2021 09:39:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610473183; cv=none; d=google.com; s=arc-20160816; b=mxk+V9V+kaqlMIelpdAbUzBDNdjFe0IKfg8vT066u+/DMpzLy+pGkkBWxG28JTqWfC CnntspX5OryETDoFggVjpULG875zwfOA/prHdnrex8PJCQrSY9BTE1QvuZn/4jA086cs jnBna/CqDxEB2bFQd44wgF2uTBCS4TqLiOR3AlaLGkIzi0g8cQx+Okdj1p09Uc+EBKvh 3aSzYDOuMS8YVukRrzOltXcYJnecdy/LHyCc+hZ6frHTkBRgucssBtj5S0j8Y1Ws2SmX OX7YUKD3DyGm+iJrdNUUJzFHLVBLP7Hk9Rosu+y15q77ktA+5n2gJ/Cr9k3iNHi0hyKd FymA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=wfBdHlbPhe9JJVFJ53u2WB3aTeFtdCK9M9opKH7jl0E=; b=k1frOkuNtpZUZq+RKGDcx9M5NsCQZBnRmervOQypW2ayjCx3hS7BD3nKGhOvPx5Iy3 q+Jbdo4uA+JDPcCSPzZV+ISPY+C76l8H7hvZZvkiRz3oFZlZId65blC88bzwsH5cR94i t/QcdfCPdjVXpkZNXHHEpaLJ8CF/Xma1ECK3AWc0ek/94uAg8WEx1pARSrxc9XLcf1BF of4FbVSMiAKiVAinedSJcGIOTCVShT2sDdXw0pn7Zk96OuNSg3+rd2qiMidSVCJi7jqW RCtfZ+IdLuXyJdqoZMFzY7Ekf4NJ+d3/59LFwmFB904SffcXzDgtDHxRsRFM9ciPKifU fGnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=r+hFbctf; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b7si1647493edy.561.2021.01.12.09.39.19; Tue, 12 Jan 2021 09:39:43 -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=@google.com header.s=20161025 header.b=r+hFbctf; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391097AbhALRhR (ORCPT + 99 others); Tue, 12 Jan 2021 12:37:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390844AbhALRhM (ORCPT ); Tue, 12 Jan 2021 12:37:12 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88E27C06179F for ; Tue, 12 Jan 2021 09:36:31 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id w5so3356685wrm.11 for ; Tue, 12 Jan 2021 09:36:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wfBdHlbPhe9JJVFJ53u2WB3aTeFtdCK9M9opKH7jl0E=; b=r+hFbctf7X7hHlEJB3cUCjzH8j2xrYepKGUGArG/haPmHg3VEsQqEoP+bjyfE+JUV4 7fNlBjtiSaVAjnlZ8OaToJ9zft6m1wHPMAvTu/fKvVnerheKqOs0WRIVdNMN12Jw7COZ FVQMfPoZ0h5x0cFG0Z9WY0uT5Hp0zqIxpVoCNdwBTExy689NFmyPnNG3yNlT+FuggQJY PcUzwOPS1IslA3+lNcHct75qRyTW9ivKIgWwcPwxQoEltGGD4o6tV3kE9jPcvQfhuuXA O6Owucb4wqQ+RuictebWz50p1Hg4HXq7M3petBX90hlXHPZpAra0SIB2ZVih0uotmjgi REWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wfBdHlbPhe9JJVFJ53u2WB3aTeFtdCK9M9opKH7jl0E=; b=olj8w+abni1hokyS6ZoZTzYZ5Vi0Oxv4KQ0DFVgLS7z5HzCA19J+csuhi8X65DbkqQ pg+AhSapLQET/gE6ogRj9MQOHz3Q+T+h0veZuPr5FKnkDUc3fDQIFpUz4oZLTkqxD6du Z5SmxTUwFT6b2UnBZoWxMPHmC+R+nHG5vfnTPAw2gVSdbX8cck+5Ty3CXM7yZyZtiVrp g+RQiL2SEAUhrylDyyQ01hRenBswbOaeqH9bnHTruZNI35ox9ib7obVooYw8PPh3bDcb ume6amq0VupnKGvmJe1wdv5FEBREYJG9p3r4eBjVgcfvaqEtqJUxDGW4/sJvlc0dIGhA Uv0Q== X-Gm-Message-State: AOAM530rSD1ryJ2w1sqwRFEtS+MBCeFvVD3n3C/T3evWs5dL+7sDYQEb JqFKykC/uIDjPQakLaZBDbSM8U7K88D9DRnwLwd6yw== X-Received: by 2002:adf:f0d0:: with SMTP id x16mr5603702wro.162.1610472990153; Tue, 12 Jan 2021 09:36:30 -0800 (PST) MIME-Version: 1.0 References: <20210111170622.2613577-1-surenb@google.com> <20210111172213.ab4185a1de916c35f3245021@linux-foundation.org> In-Reply-To: <20210111172213.ab4185a1de916c35f3245021@linux-foundation.org> From: Suren Baghdasaryan Date: Tue, 12 Jan 2021 09:36:18 -0800 Message-ID: Subject: Re: [PATCH v2 1/1] mm/madvise: replace ptrace attach requirement for process_madvise To: Andrew Morton Cc: Jann Horn , Kees Cook , Jeffrey Vander Stoep , Minchan Kim , Michal Hocko , Shakeel Butt , David Rientjes , =?UTF-8?Q?Edgar_Arriaga_Garc=C3=ADa?= , Tim Murray , linux-mm , selinux@vger.kernel.org, Linux API , LKML , kernel-team Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 11, 2021 at 5:22 PM Andrew Morton wrote: > > 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. Sure, I will post another patchset that will include manpage update and will CC:stable. That's of course after Michal's concerns are addressed. Thanks! > > Alternatively we could retain PTRACE_MODE_ATTACH's behaviour and add > PTRACE_MODE_READ&CAP_SYS_NICE alongside that.