Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2706332imn; Tue, 2 Aug 2022 12:55:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR5huXxhLzxxsO4sAgWGVb5/Z+ElH435YrDPlwmkTeZEAbmxI6IW4E/MkU6N9Q3mfxo3YIgz X-Received: by 2002:a17:907:a064:b0:730:726f:c62c with SMTP id ia4-20020a170907a06400b00730726fc62cmr9927691ejc.86.1659470143349; Tue, 02 Aug 2022 12:55:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659470143; cv=none; d=google.com; s=arc-20160816; b=wmfNvEjVpESx6tIn9LBlqOh+/wM5RK2F0wOGtZPjUoCssuOAlZudHZVvBk+2lcnh/l eivcINKnoatOm7g89oPyqxMvgb+gz5l0p82ihrP0x+5z1WfVtZTkkhRoyjicdCbfvIg0 uldr0opGctYrOhhO26DX3aNlTVP9n/sQQBJvYnYJbHPlp4m1v48HohnidA10vcMnbxlh bYUaahaBQ351Uyz2dSAYm9CC0liqcckeRhmfx35kW/nFVLbV25XA4p4XtHBzPF/sOhlA bskAx9aGre140kBvYG2tHDrV5liuvsQP9aanad/vfHQ3Dec2Sk6bfEFT7CxDbIR6S13U hVwQ== 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=gZujhYrVvvAmnwjraE3ShnaLiZzxSjfKysRrz6y6PpA=; b=NYDdZIrWbZNimUz7xPbqQyg3mO7nAGtGnUyG0g9h8f3j7FPPbYs8+SCv2aA879w8wW EULqNXw6qdWMCMnarrtrbtJHs7lyAb5IGsHg/kT/VoTFWIqHHfyFfiwMqwpKA+zGOCOo 7dMNFNQ9Ligx0IcDPZ9HkPcviF56bmqaGK0AiA1juuLsm0KAbTsSNNA+RdjhmfbSKcJj jsDLldsCFfOR+Kq+bT7wusfmCUoRA23RJQWjaRdvm9y6TnY6TfERSxX/OnwDySGfxWO1 PgdYxTXZB6bB4HfW072h3EPfyyxaZEnVdlVVZa+H2rkH1OIZg0bip8UuGSKXD/l9I4Wj +XMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ZSPJfxkV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e24-20020a056402331800b0043d85ca3c96si7118290eda.440.2022.08.02.12.54.57; Tue, 02 Aug 2022 12:55:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ZSPJfxkV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230439AbiHBTn1 (ORCPT + 99 others); Tue, 2 Aug 2022 15:43:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229804AbiHBTn0 (ORCPT ); Tue, 2 Aug 2022 15:43:26 -0400 Received: from mail-oa1-x32.google.com (mail-oa1-x32.google.com [IPv6:2001:4860:4864:20::32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A15650712 for ; Tue, 2 Aug 2022 12:43:25 -0700 (PDT) Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-1013ecaf7e0so18329268fac.13 for ; Tue, 02 Aug 2022 12:43:25 -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=JHoj0xw3shkCkp88tH4k4hEAX2vvA/zT8cN/NONT3ODUNFVrEHOdMtId2rFyMrIMft I2pD+34IgHYLKCERHOLsTylVMriy5K56hJ3GKCoEQAGNv1othDguMyyH0cfMpabhJTy9 K4dZWAFAQKaUsXGXzeyx1FOhTlabLyk+fqyfmabrELOm+z+dppXK2ej4G11Mj8H+GAvC IUdU4RTNarVcOpBB/oMdg/n6kOchtdCj75pzJVd9EXkHcnCheNznjmtZhA6fhdKth/tV fA2mv8wISRs2uDHDNn0pqPjPvannGDMi9IlmQAQElzD8CRBY+1h/HtsuxwoSWaQra/fI AjcQ== X-Gm-Message-State: ACgBeo37H0m8KyfXL/oh9QbMNOPOK1UsF2VP9tb58hDS9off/MEpGiZS CLLTsihwiyOVoeDlmw6SLROECwQ2v9FaLsf8eJ8gPA== 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" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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