Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp393488pxb; Wed, 13 Jan 2021 06:26:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4mKtLhpjAAiz1XYfSgc7cT+SfglImEnd7uqLZ0vk+77cTe33VJNaj4Lt+Vc18mwlmlMSw X-Received: by 2002:a17:906:4a4f:: with SMTP id a15mr1792166ejv.541.1610547961044; Wed, 13 Jan 2021 06:26:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610547961; cv=none; d=google.com; s=arc-20160816; b=b3Oraenr0MCGcdLIkGlfuUdG7ChjCs+kxxoGxot4Iip2LTVi2g2sAlmLZqGZcA2uf3 3vAYyRqjKSWoahixrW547yXD8PjlqAHIQfmdUIc8jCarduhBx/8ayRJk+oKK7BxWZmkM dC1rY5MB/ysDBr75/aABviYI2i8FkEvE2i+YkymcoV7hUz8rIq8dBTivjb8ZTaf6PAYT uv8Do+VY5m8tucURrKQ6S7I4dX1MLGImDwvFpnzkjN8Nv5QV5fgt4pzIc9SCl6On67OW +BXlRzxcYzaV4kTV3/UYG27grX23wHiWN4btxED/L+MtuaqRB36gRwErfnBAX5hLywm0 7QOw== 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=YaJyrouPpgNEF+Q5LLB84J7mSoEpwJTbsWHp0jr/WhE=; b=qT7VYm7E8ydDEgzmmfu2qURcomf/+v3IQvwtmZWYklVlYDA3HCqe7yS0X4k1+AtuEc nkbWKDNCKNxKALaVRlVXLUuQS4mnuIXnB1kiZxpIOSHcPuxFMi3bSZAXLKkXlN2bFUf5 nUOmUXzhd1vU+UzwNS/0vX/1znG8sWOJ0ojPQxqoVAEl7Yp4amMrqlkxY7gtSECOqrWa Szow1Rb6PEq+edUFNrEd6azzobbhw6HF/bL0FXDObkf2kTw3jvjsEMVF/f4e5FWfV5FD qKZs1+1P4Itg9Xzk3/cdMIbAFz69RFuRH5NGwemI2YvFvMOiGjhUyjGmcaXR4hScMlRa kjWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=nYxkz9Sq; 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=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p11si963139ejb.434.2021.01.13.06.25.37; Wed, 13 Jan 2021 06:26:01 -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=@suse.com header.s=susede1 header.b=nYxkz9Sq; 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=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726900AbhAMOWt (ORCPT + 99 others); Wed, 13 Jan 2021 09:22:49 -0500 Received: from mx2.suse.de ([195.135.220.15]:57016 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725801AbhAMOWt (ORCPT ); Wed, 13 Jan 2021 09:22:49 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1610547723; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YaJyrouPpgNEF+Q5LLB84J7mSoEpwJTbsWHp0jr/WhE=; b=nYxkz9Sq6tjTWZXiRBdUWWSzCCX6BtDKVlPAHOePb5A1L1HZPs7t55Upu+WK3pf4UFzwzb hCGFVYpzluAZT3bz0KONs0OSTUQaoUkunsNqL2ljnKSgfYvpNgZ2IvFKtI2lfR4OZBVAqd BP5XaBj2yUWfuZ3R4CjoSDXcuc9kdmE= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id DC4B3B8DA; Wed, 13 Jan 2021 14:22:02 +0000 (UTC) Date: Wed, 13 Jan 2021 15:22:02 +0100 From: Michal Hocko To: Suren Baghdasaryan Cc: Oleg Nesterov , Andrew Morton , Jann Horn , Kees Cook , Jeffrey Vander Stoep , Minchan Kim , Shakeel Butt , David Rientjes , Edgar Arriaga =?iso-8859-1?Q?Garc=EDa?= , Tim Murray , linux-mm , selinux@vger.kernel.org, Linux API , LKML , kernel-team Subject: Re: [PATCH v2 1/1] mm/madvise: replace ptrace attach requirement for process_madvise Message-ID: <20210113142202.GC22493@dhcp22.suse.cz> References: <20210111170622.2613577-1-surenb@google.com> <20210112074629.GG22493@dhcp22.suse.cz> <20210112174507.GA23780@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > 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. -- Michal Hocko SUSE Labs