From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CECEDC433E0 for ; Wed, 13 Jan 2021 18:08:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 38AFB23435 for ; Wed, 13 Jan 2021 18:08:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38AFB23435 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 91D9D8D0084; Wed, 13 Jan 2021 13:08:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A7098D006A; Wed, 13 Jan 2021 13:08:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 76EF88D0084; Wed, 13 Jan 2021 13:08:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0220.hostedemail.com [216.40.44.220]) by kanga.kvack.org (Postfix) with ESMTP id 58D8E8D006A for ; Wed, 13 Jan 2021 13:08:21 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 1CB34181AF5C3 for ; Wed, 13 Jan 2021 18:08:21 +0000 (UTC) X-FDA: 77701536402.11.metal23_19170ac27520 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id ED6B4180F8B86 for ; Wed, 13 Jan 2021 18:08:20 +0000 (UTC) X-HE-Tag: metal23_19170ac27520 X-Filterd-Recvd-Size: 5997 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Wed, 13 Jan 2021 18:08:20 +0000 (UTC) Received: by mail-wr1-f53.google.com with SMTP id m4so3099703wrx.9 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=Ce+CHYx7DW7faKGmvaM28OPHwHEzltzFeVPvhshXbkMjGlu/oma3iwN0pLLVLXJKQZ XCfE3AMraelalyV5YoENCbkQOqhRSSWK4dCArR7Fx9Qdz+mCAkYCRwXVWqOCsTaT3qEE mV6YOUo7/yxpIy1DDxSuAc9S2mAhniJGV9J4DAEnAOkPLicvQ0IhjZ25OzcEtGP8RKco 5nOvzCNTadqkmawrNH5d7ejjuAOB29gy9n5plG9+gGUENju5oliNe3BYnSF5Nw2VnuGz sj7BPvZOLjQ+1GvmtivE3m0IsqfUk0mwxR/ilikDwmxIQmGyAATYm2bSkl7vfXHsOSbE Smpw== X-Gm-Message-State: AOAM531TAmFNWj3PkM2ke0ZO7hdYpLIC8UfSM9EqMDzeixynp+L9k9Ih 7+5Ays6JlfEwPs9cY0/fOKZMzILy4K4drkaR2xFmeQ== X-Google-Smtp-Source: ABdhPJzvfLlFhauGSP5N6MGXJl9v13+O6cX+vTvVC9ye8FhSO5okdudU++QgL2t0g5Ek15bT4blDIQNiAZWIwiPjFRE= 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" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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