Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp562935pxb; Wed, 13 Jan 2021 10:10:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQ/YLdvRZteE5ZV3yRoyNwmSkBd3GBZdLsv1aW5HSydFDH0hc8kjFi1toI+LqP+zsAQ3wU X-Received: by 2002:a17:906:7156:: with SMTP id z22mr2421859ejj.441.1610561432462; Wed, 13 Jan 2021 10:10:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610561432; cv=none; d=google.com; s=arc-20160816; b=K0CfrXx75W78mZKgrwLGPD+coe9OieL4EFt4rRDsUX/0x0tBHASWpH4CKfvUo6QZRt cj4jfn9e/84XrrK+HMVDbU7g8wx56A+TfMHDJB1mbmT79xdObYGalKZ40ir4QJjGlh8L Dfa4LFVCcwl0G0ucLq23jz8Z1kOtQLrmZhxve5SPGFD8r/P6i2PwaIXF6HuBpHKsKvyv FxOZfYJSmT1ZIZe4jndkWp/fezaUYcl8cU5rQABsqESuQfbXEr0hbjPpBA1bPTgRxXWA u9FAlYlSfFlWeEnWPK51Ve+Fb6L3owCB0lxkPSIS8iBcsNUyxD6Kvl9+EK3GstUBPBGl 4tww== 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=yH5u9y2wy1keEH/7cm+6LpeR3BpSRhAV0Ow7SdVvy58=; b=yxWAwcS2H7LLF+lE6znLTmos3koYELena5IT63NXTafeIBlBAh1ZJqRuD+cCLa74RM L9AO/x4Raj5Z2yAgedq7yYkW3HbLPRFs8+AEPmGZuAIHloWILlSJ9vHkIW/IppzzTeK8 cMrsqCHMBwocrD86XAZfZnyj+8NdHRbb8V9qJkXBLgo5AsS6sM4FrvCoz9lXWhEKijiO d3mhJnRveayNlGcbllPYne9RpHAVcsI8sMdazUuYRY80kxnZFK5x1g7Xd24yTd7e4cUp Xh8YIahuCmv6rAdNJIYivmtXOl4DIth/Bxkx0vxqAfakZFs9LOoaLML3AodidYvMXmMY 5ULg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Bdwk6nUF; 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 v23si1253218ejy.208.2021.01.13.10.10.07; Wed, 13 Jan 2021 10:10:32 -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=Bdwk6nUF; 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 S1727984AbhAMSJB (ORCPT + 99 others); Wed, 13 Jan 2021 13:09:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727827AbhAMSJB (ORCPT ); Wed, 13 Jan 2021 13:09:01 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A04ABC061794 for ; Wed, 13 Jan 2021 10:08:20 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id d26so3093875wrb.12 for ; Wed, 13 Jan 2021 10:08:20 -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=yH5u9y2wy1keEH/7cm+6LpeR3BpSRhAV0Ow7SdVvy58=; b=Bdwk6nUFlCU+LPWRFAuXQj2yM2oD/qD5nc1ASW24XvBCfyLvhbRO7i0GT9uj20AayT 4B+343KPnyqctxOjxfYPws509SjQuI5J8b/pPdcgSc+uDXEV6LyPX+J9ayTX+9A2OCCZ h+nDYj7pStlw/LGEB/Bb2bXgqu1XoeRv1PKo8d5i/nE0KuKXr0kVsdZENuXc4+boAk8x fYxlXgqy4kH8FIaLjvInn0JaKu2+v9aqajNCZ87OH3iY/0siM7zeqtK00jRVHa7r6oOv MoTOEk69/OTdcIZa2OWgDqZDRLKXQNyg0L4+hSEcDw3lwZWMWXI4xYb7hZ6bVxYPZvuG mxUA== 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=yH5u9y2wy1keEH/7cm+6LpeR3BpSRhAV0Ow7SdVvy58=; b=Wkk3qPyJ5LrcE2iebSQNeMWFduDg1/1s6abzDMz2DxLD1oinc8m/XZBTSPHuKDZRBn AHktLho/klyheV7NvjTIOI6qOd9NfHbVjtmuzPYwYRaiHDxdlbBCiFxkIABXUu5Zxntu xEnF9wSafLNH4o1BPkEt3JvD+036JN+K6jSVkL7tVE37kSRX7Ru9omQzMAB5E2cvdaHG NrqR/5RWja6p/ntnSnLJKxqpkXOLF6M/D2It0d90VYZMHNUVOeA9xh7AlvbB6euuMaVi 5FZ6kHtAT7uNkZOliy+cG8CccZoRmVNNhgqq+GHEDa00OXv6UoIniU9+4hmYsUt4CJzX vj4A== X-Gm-Message-State: AOAM530+4Dsms43ROQ4tAUHRb/DRK1GFvwN9g87LQgN41X6YFQqc0tg/ FMWz5ueuenfMCnt4CleXC4P510W5bgtxoB+RnubH/A== X-Received: by 2002:a5d:4a44:: with SMTP id v4mr4006181wrs.106.1610561299128; Wed, 13 Jan 2021 10:08:19 -0800 (PST) MIME-Version: 1.0 References: <20210111170622.2613577-1-surenb@google.com> <20210112074629.GG22493@dhcp22.suse.cz> <20210112174507.GA23780@redhat.com> <20210113142202.GC22493@dhcp22.suse.cz> In-Reply-To: <20210113142202.GC22493@dhcp22.suse.cz> From: Suren Baghdasaryan Date: Wed, 13 Jan 2021 10:08:08 -0800 Message-ID: Subject: Re: [PATCH v2 1/1] mm/madvise: replace ptrace attach requirement for process_madvise To: Michal Hocko Cc: Oleg Nesterov , Andrew Morton , Jann Horn , Kees Cook , Jeffrey Vander Stoep , Minchan Kim , 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 Wed, Jan 13, 2021 at 6:22 AM Michal Hocko wrote: > > On Tue 12-01-21 09:51:24, Suren Baghdasaryan wrote: > > On Tue, Jan 12, 2021 at 9:45 AM Oleg Nesterov wrote: > > > > > > On 01/12, Michal Hocko wrote: > > > > > > > > On Mon 11-01-21 09:06:22, Suren Baghdasaryan wrote: > > > > > > > > > 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. > > > > > > > > I have to say that ptrace modes are rather obscure to me. So I cannot > > > > really judge whether MODE_READ is sufficient. My understanding has > > > > always been that this is requred to RO access to the address space. But > > > > this operation clearly has a visible side effect. Do we have any actual > > > > documentation for the existing modes? > > > > > > > > I would be really curious to hear from Jann and Oleg (now Cced). > > > > > > Can't comment, sorry. I never understood these security checks and never tried. > > > IIUC only selinux/etc can treat ATTACH/READ differently and I have no idea what > > > is the difference. > > > > I haven't seen a written explanation on ptrace modes but when I > > consulted Jann his explanation was: > > > > PTRACE_MODE_READ means you can inspect metadata about processes with > > the specified domain, across UID boundaries. > > PTRACE_MODE_ATTACH means you can fully impersonate processes with the > > specified domain, across UID boundaries. > > Maybe this would be a good start to document expectations. Some more > practical examples where the difference is visible would be great as > well. I'll do my best but I'm also not a security expert. Will post the next version with a draft for the man page (this syscall does not have a man page yet AFAIKT) and we can iterate on the wording there. > > He did agree that in this case PTRACE_MODE_ATTACH seems too > > restrictive (we do not try to gain full control or impersonate a > > process) and PTRACE_MODE_READ is a better choice. > > All that being said, I am not against the changed behavior but I do not > feel competent to give an ack. Great. SOunds like the only missing piece is the man page with more details. I'll work on it but since it's the first time I will be contributing to man pages it might take me a couple days. Thanks everyone for the reviews! > -- > Michal Hocko > SUSE Labs