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 0A86DEB64D9 for ; Thu, 29 Jun 2023 10:30:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 88E1A8D0006; Thu, 29 Jun 2023 06:30:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 816D68D0005; Thu, 29 Jun 2023 06:30:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 693978D0006; Thu, 29 Jun 2023 06:30:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 56E3C8D0005 for ; Thu, 29 Jun 2023 06:30:15 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 2CCF9B08DE for ; Thu, 29 Jun 2023 10:30:15 +0000 (UTC) X-FDA: 80955415590.24.BD55F82 Received: from nautica.notk.org (nautica.notk.org [91.121.71.147]) by imf04.hostedemail.com (Postfix) with ESMTP id 95A6D4000D for ; Thu, 29 Jun 2023 10:30:12 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=codewreck.org header.s=2 header.b=KEfVaX0t; dkim=pass header.d=codewreck.org header.s=2 header.b=tCJfaWg5; spf=pass (imf04.hostedemail.com: domain of asmadeus@codewreck.org designates 91.121.71.147 as permitted sender) smtp.mailfrom=asmadeus@codewreck.org; dmarc=pass (policy=none) header.from=codewreck.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688034613; 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=if9qbAJfyLZr3BzQNxYrgUhfEv4hP+9JnW2xBmEgwCY=; b=wF/AY/YblWs2GwWrkhkFtSR13bYLrx6K9qexO5UDJoIBkCgyvfxwsRnx8Hl5Udq2XV3Dud guIsvDnTwlBNc5qaCSihll/iXeBYCyrfQyOd3Abv90nk9i2rpWk5KLqZMaChjGzExJT996 9Gw7Y2x4yXcCT8KbDXTqunZPgayHtDY= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=codewreck.org header.s=2 header.b=KEfVaX0t; dkim=pass header.d=codewreck.org header.s=2 header.b=tCJfaWg5; spf=pass (imf04.hostedemail.com: domain of asmadeus@codewreck.org designates 91.121.71.147 as permitted sender) smtp.mailfrom=asmadeus@codewreck.org; dmarc=pass (policy=none) header.from=codewreck.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688034613; a=rsa-sha256; cv=none; b=lKHfSANxT63dyVkAYQcOokTJU1aen/W4zoDXz227dsFBg+izv/GcaSIfTuzfcwAulofQ1W 53QFqO8j1oJb8HV8+QfqZKEewyMQXpdnPtPTdC7cwhkyhVLZgNA3xOy2QLCfqSOCUmDg0H sIATMn64U93Q/Xj3Rh9vUx/WTC2hEYs= Received: by nautica.notk.org (Postfix, from userid 108) id 8DCC7C01E; Thu, 29 Jun 2023 12:30:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1688034610; bh=if9qbAJfyLZr3BzQNxYrgUhfEv4hP+9JnW2xBmEgwCY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KEfVaX0t2OTlde6Nd3qey+ECr1O+nYrxhyKKZOCmXh/2Kgcop7vRZZGfXcxSCkW9O vWBrQHO6EdSwboCUulup2O1xup6vfcwAA2DqiKe4OyYvd6TS6wbKjx41Lx5ZQxmYFv zxl6hIZ+F/OljOeiV/hZ0rKO9KXNX19gdAieVTBhnlRlqRIKPe4znCamk91RyWjpgd Zo4wwqIiqmylUaGksQz3sONpgxlJcMR0v+5kLVORcCl+zKCict7j3FOqPvvQYM5ZGL SeG9xnU8RQs8NhqFGuZ8Ohh+FQRrWzJa8NGmufRUwA7LHNGGXMMOSq8i7/cS3aUDfk 62Jh4ql10yc5A== Received: from odin.codewreck.org (localhost [127.0.0.1]) by nautica.notk.org (Postfix) with ESMTPS id 3F9D1C009; Thu, 29 Jun 2023 12:30:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1688034609; bh=if9qbAJfyLZr3BzQNxYrgUhfEv4hP+9JnW2xBmEgwCY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tCJfaWg5ag2BGOgbHK7s89C2ekhrviQD8tcS4Twse5JOBeKNyoTJCAq6SGCTf3SSf X1jwKdSvMnpNmpynUzepZLjmFnIxPK19pPmpvR+qjvvhZ2fvVcq/pmCh2GawrhqyeQ b3QDV4VSIrSfZZ9w4doi9uyaaNanBZZZr+x/38T/xBOZaW9oDALteGq0rBLMZse75m 9Y++q6QRmQUnN8ijUoIV+bhbSd2BmwuIs4tjSf6bVKI0ogoVMNhVoYuu2VuWHmpuba xjGs0VygsedMgSD2vLPool/GcdCoTQXjq0M3iwsj7gCkkDAMpgfqC87vJrtjrgn7mn s5NXJ8uUYen7A== Received: from localhost (odin.codewreck.org [local]) by odin.codewreck.org (OpenSMTPD) with ESMTPA id 9e8fd47c; Thu, 29 Jun 2023 10:30:01 +0000 (UTC) Date: Thu, 29 Jun 2023 19:29:46 +0900 From: Dominique Martinet To: Jeff Xu Cc: skhan@linuxfoundation.org, keescook@chromium.org, akpm@linux-foundation.org, dmitry.torokhov@gmail.com, dverkamp@chromium.org, hughd@google.com, jeffxu@google.com, jorgelo@chromium.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, jannh@google.com, linux-hardening@vger.kernel.org, linux-security-module@vger.kernel.org, kernel test robot Subject: Re: [PATCH v8 3/5] mm/memfd: add MFD_NOEXEC_SEAL and MFD_EXEC Message-ID: References: <20221215001205.51969-1-jeffxu@google.com> <20221215001205.51969-4-jeffxu@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 95A6D4000D X-Rspam-User: X-Stat-Signature: tgukuwke5q71gjueoz8rubonz9d8unwp X-Rspamd-Server: rspam01 X-HE-Tag: 1688034612-191226 X-HE-Meta: U2FsdGVkX18RfgEwNkAFrKerjLXXpp5558uOaFuEmtDRBXcjG7XhB3pEF0q2UmGsof0vwXyjvRidEmVE8GKRjVLP05QYOYY9IGIiXMIFNxcj/HgR/FmoYek+UKSEqVrV9xb4mKdm+6TVi7TV3QQMRzyOQ3x3lTyitOKAvgHUL4flO3pnnwRZajvwPiH/SDbmW41Mej0v587m9+HRD5lhc4llv8cOB1hVH40FdoHmMxdDsIAhbM+/ZsGuLhGUe8ajVEIReZQtBaNJvRsAdoyCxUDuQPt9T1YugGf1EDU0qx5a5UreQunGmc03NP0mIJ5AGVylyFhitdaqEofGM/jX5pyMsZaCltfPiquvBo97Kd4amvRcgCYhOlwgblxjmR9nr3GVq6W1bMpDs3Tr4Ku5MpCvaX1alpuV3cy7SUNERLLfB7FTYTDDAwv1oSDU7Lp/+frqYRS6mqdyLgASCfFpMZYymlbp4TaEszBgX2LtsJxeeyH/ummkp6mPwZlhZXjsXQqlHcKclfaEvjgnQ6JPCrh9wjmzsvtSLNNSBKE/86QVmt6yltonaEHeZdjkI5TIwU4MXWIVX3OZjZLlk5V0bSNkkZ5EVP8NoiuAY4T6xxEccNZNgXKcmogzGBUJVCV9UU83CRA3hqgLyWy5lfHbf6zlphBZO7sT+et0tvqPKfkbiWUPtuN6AfWvp0awvtJ0Wo6APyj4Jqnwd0UvZ9kUMybydHx6qgeaxA/fcv+IOd5UYagiqdU+9SNP/r0r3zi1wTbgXKvIR0SBNjiAnkPcHXBx4GcLAuJot97pcoeatBg0v9tb18xmkN0JvtD4MGVO+07m9Zv59Y62rTErS1+9Es6XKsXuDDnOhpfl/Z9NT+p8MgdeWpNV/JJ/KAdGx3W1YRvXJ1FzXoquIpl8FqhuBePsdv061CAgmeMJdN+gsBRtNjEdVlkdPBaE/7CWbXZkPNRF2ZAz96fSKVR5NwO Y/K7POB2 yLbCBBS7p2lCqr0y9TNOs4BwJWU4uCnerf1YVAcFAq3eQrAreFfEGIGFQjnSsuRG5lVizWPW5VIECfIVvsUbw3WA0lfyrPuWqEoPcFbwikhef2Ij+p691BVBVZzz4s/ebDKwbEe2xoRSr8hdMZ9hudCUiTB9VoKPTkDV/bLlQNe8JJkD/7hgqEhlwK1I18HdOmbU3HbE/xq8JqYCcg4dNYgTnmZmC2dz2oYdVF088U2BRKDaH2JHedQTXt3CAgjnwc+cQP8uDn+2WBMOV5fXa39jg/2FStLQNWHUt 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: Jeff Xu wrote on Wed, Jun 28, 2023 at 09:33:27PM -0700: > > > BTW I find the current behaviour rather hard to use: setting this to 2 > > > should still set NOEXEC by default in my opinion, just refuse anything > > > that explicitly requested EXEC. > > > > And I just noticed it's not possible to lower the value despite having > > CAP_SYS_ADMIN: what the heck?! I have never seen such a sysctl and it > > just forced me to reboot because I willy-nilly tested in the init pid > > namespace, and quite a few applications that don't require exec broke > > exactly as I described below. > > > > If the user has CAP_SYS_ADMIN there are more container escape methods > > than I can count, this is basically free pass to root on main namespace > > anyway, you're not protecting anything. Please let people set the sysctl > > to what they want. > > Yama has a similar setting, for example, 3 (YAMA_SCOPE_NO_ATTACH) > will not allow downgrading at runtime. > > Since this is a security feature, not allowing downgrading at run time > is part of the security consideration. I hope you understand. I didn't remember yama had this stuck bit; that still strikes me as unusual, and if you require a custom LSM rule for memfd anyway I don't see why it couldn't enforce that the sysctl is unchanged, but sure. Please, though: - I have a hard time thinking of 1 as a security flag in general (even if I do agree a sloppy LSM rule could require it); I would only lock 2 - please make it clear, I don't see any entry in the sysctl documentation[1] about memfd_noexec, there should be one and you can copy the wording from yama's doc[2]: "Once set, this sysctl value cannot be changed" [1] Documentation/admin-guide/sysctl/vm.rst [2] Documentation/admin-guide/LSM/Yama.rst Either way as it stands I still don't think one can expect most userspace applications to be converted until some libc wrapper takes care of the retry logic and a couple of years, so I'll go look for another way of filtering this (and eventually setting this to 1) as you suggested. I'll leave the follow-up up to you and won't bother you more. Thanks, -- Dominique Martinet | Asmadeus