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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 830F7C00140 for ; Tue, 2 Aug 2022 19:43:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F356D8E0002; Tue, 2 Aug 2022 15:43:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EBE4B8E0001; Tue, 2 Aug 2022 15:43:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D869A8E0002; Tue, 2 Aug 2022 15:43:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C77918E0001 for ; Tue, 2 Aug 2022 15:43:25 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A1D4E120A8E for ; Tue, 2 Aug 2022 19:43:25 +0000 (UTC) X-FDA: 79755676770.23.A31563B Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) by imf20.hostedemail.com (Postfix) with ESMTP id 2C2241C0121 for ; Tue, 2 Aug 2022 19:43:25 +0000 (UTC) Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-10bd4812c29so18366405fac.11 for ; Tue, 02 Aug 2022 12:43:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gZujhYrVvvAmnwjraE3ShnaLiZzxSjfKysRrz6y6PpA=; b=ZSPJfxkVJtHKhnn6H5pieCDozzVCYNcABXzvLcAE9csfr57RgROVrF3BA/baeJeZZ/ oQXwTvhG/F7lfTn4I0219O547Ud2OtEn5f+sTcNPJ0ItaauVo/leAMOHy2tUIcw4WaTe rka8BSFHq09cVAj/UQPnh+BDtMko299AVBX3Wg1ZiiWF2lOXvBZZdFdFuBphXz9WrG29 v2FHor9/kYhbWK43j72XraVMG9RBiUm/zfBPBZC2tZG0PAmiwlbxo635QWX0HrXlNW9E IcxI6Dpti0lOmDOhpH8G9cZNNlwkH99gV7diguECiQNNQjWSJ+atsznDNssY9kUHn0qa fRlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gZujhYrVvvAmnwjraE3ShnaLiZzxSjfKysRrz6y6PpA=; b=H71cDlv1Ze+ROhoZFNrvROlENfzCpexOu4sK+fYyarM1gPqy1eKQwfJEm3Qt5OWTZb drEWK6P3edc7loJzuBspkdRs+Z+UUG9Y83UJq+H/Q4mTCOFwCZHufq2r6zuNSXvTx5MU 3XOfJwLe1jkY3krR0Ez53qh9TD4zX693vCoxW8+yygIJEoWRh6hPRT4bTWBIlOzHMx4X d+oLiXvl0//X5EGIQZVblPbuEIo5mn2e90L00adx0j05KJOxK54xOGio0WvTTbVJZ/rS uujCPLryok5e0mB7GbIxrOdRQKO23p3rPrtxylY2Wv4Uxhj/3lQhXLFfeVKKiUvYHyxT ufXg== X-Gm-Message-State: ACgBeo14wuwL3v5csBvjg7NF+yk8mJqxVXNsUTD9qs072k7JkPnOmDsa F5iza3IjJJ4I5z6SWoxBCJ8f7wLi2/MS0U/68k2FNQ== X-Google-Smtp-Source: AA6agR7yMFNZuea36Auv9bhp/MY6EQ4zBLvwrr6zBdwaahXs41PVfFBBbnF9DeonuwCyq/+nSdm9TBmXBeQiZbplKk4= X-Received: by 2002:a05:6870:a91d:b0:10c:55e:3f64 with SMTP id eq29-20020a056870a91d00b0010c055e3f64mr426579oab.123.1659469404221; Tue, 02 Aug 2022 12:43:24 -0700 (PDT) MIME-Version: 1.0 References: <20220801210946.3069083-1-zokeefe@google.com> In-Reply-To: From: "Zach O'Keefe" Date: Tue, 2 Aug 2022 12:42:48 -0700 Message-ID: Subject: Re: [PATCH mm-unstable] mm/madvise: remove CAP_SYS_ADMIN requirement for process_madvise(MADV_COLLAPSE) To: Michal Hocko Cc: linux-mm@kvack.org, Andrew Morton , linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, Axel Rasmussen , James Houghton , Hugh Dickins , Yang Shi , Miaohe Lin , David Hildenbrand , David Rientjes , Matthew Wilcox , Pasha Tatashin , Peter Xu , Rongwei Wang , SeongJae Park , Song Liu , Vlastimil Babka , Zi Yan , Andrea Arcangeli , Arnd Bergmann , Chris Kennelly , Chris Zankel , Helge Deller , Ivan Kokshaysky , "James E.J. Bottomley" , Jens Axboe , "Kirill A. Shutemov" , Matt Turner , Max Filippov , Minchan Kim , Patrick Xia , Pavel Begunkov , Thomas Bogendoerfer Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659469405; a=rsa-sha256; cv=none; b=yjHzPL/D1tyTXVglgQHr1ywzMvJgg/qLfoX7EHpawbwgU1uYXGp/Nj7OuOW+TZHr6alEpa nzUJ6Q8IdggK92H+b8DnEQF+NlE6ssezNM2V8T9wjNId0rtuYbTj1jNUs0Xcq8nqhangZ7 MrxqXi1Dihis0Gn85U4CJdzfl/Wg7c4= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=ZSPJfxkV; spf=pass (imf20.hostedemail.com: domain of zokeefe@google.com designates 209.85.160.50 as permitted sender) smtp.mailfrom=zokeefe@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659469405; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gZujhYrVvvAmnwjraE3ShnaLiZzxSjfKysRrz6y6PpA=; b=zq7CsP4y/pVlPOCv77D9g1+VMJa/kQ804x61Sky4DD+yvhj/2YYx8BVNKGdjFtlM5vFrtZ 3lY4Ebd+ZNjLPEQBF5TKMt1kr+PonK+40xFJLnmJwfKPMg5eD0AB7VBqGVWMA/mD8wHJ9U uASQdlUMfzq0d/woQDCZUjho4KsApgM= Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=ZSPJfxkV; spf=pass (imf20.hostedemail.com: domain of zokeefe@google.com designates 209.85.160.50 as permitted sender) smtp.mailfrom=zokeefe@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: s41tn6u8mdqi1iy7rohw461c5c9k5ht4 X-Rspamd-Queue-Id: 2C2241C0121 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1659469405-61968 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000004, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Aug 2, 2022 at 5:04 AM Michal Hocko wrote: > > On Tue 02-08-22 02:48:33, Zach O'Keefe wrote: > [...] > > "mm/madvise: add MADV_COLLAPSE to process_madvise()" in the v7 series > > ended with me mentioning a couple options, but ultimately I didn't > > present a solution, and no consensus was reached[1]. After taking a > > closer look, this is my proposal for what I believe to be the best > > path forward. It should be squashed into the original patch. What do you think? > > If it is agreed that the CAP_SYS_ADMIN is too strict of a requirement > then yes, this should be squashed into the original patch. There is no > real reason to create a potential bisection headache by changing the > permission model in a later patch. Sorry about the confusion here. Assumed (incorrectly) that Andrew would kindly squash this in mm-unstable since I added the Fixes: tag. Next time I'll add some explicit verbiage saying it should be squashed. > From my POV, I would agree that CAP_SYS_ADMIN is just too strict of a > requirement. > > I didn't really have time to follow recent discussions but I would argue > that the operation is not really destructive or seriously harmful. All > applications can already have their memory (almost) equally THP > collapsed by khupaged with the proposed process_madvise semantic. > > NOHUGEMEM and prctl opt out from THP are both honored AFAIU and the only > difference is the global THP killswitch behavior which I do not think > warrants the strongest CAP_SYS_ADMIN capability (especially because it > doesn't really control all kinds of THPs). Ya. In fact, I don't think the ignoring the THP sysfs controls warrants any additional capability (set alone CAPS_SYS_ADMIN), since a malicious program can't really inflict any more damage than they would with CAP_SYS_NICE and PTRACE_MODE_READ. > If there is a userspace agent collapsing memory and causing problems > then it can be easily fixed in the userspace. And I find that easier > to do than putting the bar so high that userspace agents would be > unfeasible because of CAP_SYS_ADMIN (which is nono in many cases as it > would allow essentially full control of other stuff). So from practical > POV, risking an extended RSS is really a negligible risk to lose a > potentially useful feature for all others. > Agreed. Thanks for taking the time, Michal! Zach > Just my 2c > > > Thanks again, > > Zach > > > > [1] https://lore.kernel.org/linux-mm/Ys4aTRqWIbjNs1mI@google.com/ > > -- > Michal Hocko > SUSE Labs