Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp643452pxb; Fri, 8 Jan 2021 14:21:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJz8IPL3da2QWf152PaUNlhaD7fk01aGbuvAkgFDrZbuItpTVf4cb2n3OnDNu7hSkzGmGJ6u X-Received: by 2002:a05:6402:1714:: with SMTP id y20mr6613890edu.2.1610144514889; Fri, 08 Jan 2021 14:21:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610144514; cv=none; d=google.com; s=arc-20160816; b=UzcML0myXeiAQMwqancx7r3KC9qxTkIWbAco7ev3yP5FwHqvtVET4gB5oAZ0WT4+8a ooDb58bq16Av0BEAlGSWouMUT+7x8O2ktw9WpEpxeArkIqGkovWC4VBs/2jCsyEV+3II KPptbJBPLEU6lzajAQaWtRZwnd+2ehg4TcyHA0frsi6DOQAv2ANClU+4mAKI6UzRha38 RCgTNDfVf3b7LFhfaOmGi2wIz0zJaBfDUrcEqO2NxnwUHZT5yAfEycGKNnpltM36aevj bQf0dq5QcMt4ICJlfUBPupbO82xl0WIjN+fYDQGh4Rzv+vnc0oMCruplGONsjuFYsNOU JjDA== 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=dfNPOuXbiYYuQXptBPkm0/8Iz5DAMcXqOk0WAcfNZT0=; b=O4MgrlXwgQAmY6GlYs3bxboVRSasMlAbzsnA16Z+pCPTuMAMiU5iYRm+02DYKmqE3N ngll5N9HIgTe8XnUD3nBYfSiRU1TedvjxGwBMI0lwuVQmdAf4y2CVgdlIYi5h5WewWhU qwCmtCvzuZN1GneSFhdeN2AqUQCqB2piVSdxzBV/lR0P2m/x5IlMeUd5sfvAXJlr5/3Y pTuq1xZNqDo94iUI0FnELfnqIwTDFu11CnNsnHCSq+s9644Vv96BSqbnU9YCOOQOwnyE QUNfXc9Vuy78O08faKB6N2aUlxftcBq552lxMWSc/U4nc0qALRK7OT6qaQHzmdPKKCtH BNig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=OwKIICBG; 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 i3si3743311eja.676.2021.01.08.14.21.31; Fri, 08 Jan 2021 14:21:54 -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=OwKIICBG; 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 S1725877AbhAHWS3 (ORCPT + 99 others); Fri, 8 Jan 2021 17:18:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725813AbhAHWS3 (ORCPT ); Fri, 8 Jan 2021 17:18:29 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55D0AC061799 for ; Fri, 8 Jan 2021 14:17:30 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id r3so10387158wrt.2 for ; Fri, 08 Jan 2021 14:17:30 -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=dfNPOuXbiYYuQXptBPkm0/8Iz5DAMcXqOk0WAcfNZT0=; b=OwKIICBG4ziBL858fu/p6nkk7+7rYxyWE1veyLMYcq8xsyhXf7/F9O0gvB13SSnZD3 XO+8qjLHVM4kuZx7TPjG+iaE+jBXURk072L+H23O+fM7S4PaxitqMc78dVhZmghwZ0Fi ZbbroueXQAT996JB4CzRaHNHdWgCRtYyjRgm56Ow9PHs7io9FmlxzldrOgn0CXiD1nRo NJfhRVkWJipHsA7aZVyDBY0agTh1ZkeyInVUPjSyHbkVJWdyTFgz5oMRSwV3370kckHI aPSupM1d8kj6aJchlRpMWL6ETpmSfbqJLzVR5gS+Gi9oYJxaRVgGjiRFMo42lBIYn6Sk QKvg== 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=dfNPOuXbiYYuQXptBPkm0/8Iz5DAMcXqOk0WAcfNZT0=; b=towNE/tJ4cw5ExuABi3OLF6YQEdkl1NbTQkyZKLtosC2Cq8LlnxzSxN0ihd8vYTWzq DsUGhcxiZoPlxAO51JdUaxRFTMY442lnesRot0Cq0mymxlFuklDuurRkoto40cxXpmZV sVMypLUcq/Uy/BMy9yo40G4yHw/sLeOS7fsCD38VPiH/SSbyXEYwXRuzPkCtw+y77gZ0 Ff50pZei8VgM0Ny5h+/mStf9lkVnKIV6EjW1ajWR/rNyMDB12bTHW61DzADmKI38oTsJ 5j00V52TWmWFW1e0vZI16XB9MZp1mMYGZNZcGCdqlKW6zB9Q+OyeQbpvRFg17V4WsG8l 0FQw== X-Gm-Message-State: AOAM5330y9W/AsA8uNB7xH5Id69SaPlNrPQnMe077QrGHRaPFITvH4n7 UA18S4GwIU8uggguubYXGYUIgkkHzmTfAmsNZcrDLQ== X-Received: by 2002:a5d:4a44:: with SMTP id v4mr5731046wrs.106.1610144248889; Fri, 08 Jan 2021 14:17:28 -0800 (PST) MIME-Version: 1.0 References: <20210108205857.1471269-1-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Fri, 8 Jan 2021 14:17:17 -0800 Message-ID: Subject: Re: [PATCH 1/1] mm/madvise: replace ptrace attach requirement for process_madvise To: Minchan Kim Cc: Andrew Morton , Jann Horn , Kees Cook , Jeffrey Vander Stoep , 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 Fri, Jan 8, 2021 at 2:15 PM Minchan Kim wrote: > > On Fri, Jan 08, 2021 at 12:58:57PM -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 > > It sounds logical to me. > If security folks don't see any concern and fix below, > > Acked-by: Minchan Kim > > > @@ -1197,12 +1197,22 @@ SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec, > > goto release_task; > > } > > > > - mm = mm_access(task, PTRACE_MODE_ATTACH_FSCREDS); > > + /* Require PTRACE_MODE_READ to avoid leaking ASLR metadata. */ > > + mm = mm_access(task, PTRACE_MODE_READ_FSCREDS); > > if (IS_ERR_OR_NULL(mm)) { > > ret = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH; > > goto release_task; > > } > > > > + /* > > + * Require CAP_SYS_NICE for influencing process performance. Note that > > + * only non-destructive hints are currently supported. > > + */ > > + if (!capable(CAP_SYS_NICE)) { > > + ret = -EPERM; > > + goto release_task; > > mmput? Ouch! Thanks for pointing it out! Will include in the next respin. > > > + } > > + > > total_len = iov_iter_count(&iter); > > > > while (iov_iter_count(&iter)) { > > -- > > 2.30.0.284.gd98b1dd5eaa7-goog > > > > -- > To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@android.com. >