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=-5.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 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 3CBE6C2D0A3 for ; Sun, 1 Nov 2020 11:41:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 938CE20870 for ; Sun, 1 Nov 2020 11:41:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="csv/7BOj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 938CE20870 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A5E776B0036; Sun, 1 Nov 2020 06:41:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E9B16B005D; Sun, 1 Nov 2020 06:41:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 885DA6B0072; Sun, 1 Nov 2020 06:41:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0197.hostedemail.com [216.40.44.197]) by kanga.kvack.org (Postfix) with ESMTP id 5439B6B0036 for ; Sun, 1 Nov 2020 06:41:36 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D38801EE6 for ; Sun, 1 Nov 2020 11:41:35 +0000 (UTC) X-FDA: 77435659350.03.tank93_1810cff272a7 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id B71C228A4E8 for ; Sun, 1 Nov 2020 11:41:35 +0000 (UTC) X-HE-Tag: tank93_1810cff272a7 X-Filterd-Recvd-Size: 7630 Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Sun, 1 Nov 2020 11:41:35 +0000 (UTC) Received: by mail-lf1-f68.google.com with SMTP id b1so13659230lfp.11 for ; Sun, 01 Nov 2020 03:41:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=vE+kC+A2VtoW9DT/RZQzhv7ZNYaInonkNcxpMpbSM+g=; b=csv/7BOjVnNPb13k2e9k7oAz/KX07fOskCrtW+1AFv2EE6rzrbVa1J44nAzt/MDSAd GwKewslY+k0vYVsVCD3Tl1TnLTJxqfdl/xDvO/+zavX2IP4yPz1MyRkjn28eFzuV0MmA Sol0v0ZjKU5b7rBDlgosZH2GGyX1Bm6yf5mDGCnNUvpdqnRLY7sCrdwfFJ9iQc44EmSq g4r9BaEMTKNSD4MpCLmMWJPSdybG2yQJcr3mNfHy1TWYqcJEKY5308kpd4HrAyQGNjk3 HNs8pvkym6Z62dn7+VsZ8VDnYEdEkGVbSZj5rumVEYOnTnON3imfllHddl/7pDo4f8DH x4tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=vE+kC+A2VtoW9DT/RZQzhv7ZNYaInonkNcxpMpbSM+g=; b=Eo1SD1/BMgQQcgXBIOcV95alf3c/rD5fN0BDdtZvkW534gFy5avGyTuOXcGo8kbhxD ssj3fblC6Co/8v+ii0zGkwrS9WVijP2xalg/4z4IdimpUrrXJ20mvcVVX5CnZrHev8qt txg/nSGsO90IrG54YT5sSzxcylk+iXYslY5bTUbA0Tj8qtIHbBiownwz1hUU6fpjggH0 rzHyaSXua0t5/WSmIGBACYs1cf8liPHk4hVaL2SqXuq8wMOgGuX1ktyEoUj8R3N/7/Ed T99LwfQ1xLCarw/8+ifgSRGSRXGyswAh9LuQO7QKFmTufhNgxPmv3WgMWDDiKqCh9iDB s1aA== X-Gm-Message-State: AOAM532h6wilRPgBCF5L2tSX6k7kSH04ukg9HbjoMk4/dxk/yuRB4swt mrHgWS8FXugr8n6GbkEe8Hg= X-Google-Smtp-Source: ABdhPJzTyJaOgR6sLbJ8Q3gm5CTxoJ7vmnJTMZiTqr6ItplKz8DMRI/avr3NT7zSc+HQNhvLQXOH0w== X-Received: by 2002:a19:f119:: with SMTP id p25mr3799303lfh.151.1604230893778; Sun, 01 Nov 2020 03:41:33 -0800 (PST) Received: from [192.168.1.112] (88-114-211-119.elisa-laajakaista.fi. [88.114.211.119]) by smtp.gmail.com with ESMTPSA id x69sm1453725lff.54.2020.11.01.03.41.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 01 Nov 2020 03:41:33 -0800 (PST) Subject: Re: [PATCH] mm: optionally disable brk() To: David Hildenbrand , David Laight , Michal Hocko , Kees Cook Cc: "akpm@linux-foundation.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" References: <20201002171921.3053-1-toiwoton@gmail.com> <653873ef-2a57-37e0-1ac3-fba763652b35@redhat.com> <2a0f5ade-d770-c36e-50bc-ff0c8e9dacbf@gmail.com> <20201005061248.GN4555@dhcp22.suse.cz> <888e62e0-3979-207b-c516-ddfc6b9f3345@redhat.com> <4d325e3e-3139-eded-6781-435fb04fb915@gmail.com> <9dc586f4-38f0-7956-0ab6-bd7921491606@redhat.com> <5fb32353b1964299809fce0c7579a092@AcuMS.aculab.com> From: Topi Miettinen Message-ID: Date: Sun, 1 Nov 2020 13:41:30 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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 5.10.2020 15.18, David Hildenbrand wrote: > On 05.10.20 13:21, David Laight wrote: >> From: David Hildenbrand >>> Sent: 05 October 2020 10:55 >> ... >>>> If hardening and compatibility are seen as tradeoffs, perhaps there >>>> could be a top level config choice (CONFIG_HARDENING_TRADEOFF) for this. >>>> It would have options >>>> - "compatibility" (default) to gear questions for maximum compatibility, >>>> deselecting any hardening options which reduce compatibility >>>> - "hardening" to gear questions for maximum hardening, deselecting any >>>> compatibility options which reduce hardening >>>> - "none/manual": ask all questions like before >>> >>> I think the general direction is to avoid an exploding set of config >>> options. So if there isn't a *real* demand, I guess gluing this to a >>> single option ("CONFIG_SECURITY_HARDENING") might be good enough. >> >> Wouldn't that be better achieved by run-time clobbering >> of the syscall vectors? > > You mean via something like a boot parameter? Possibly yes. > This may be obvious, but a global seccomp filter which doesn't affect NNP can be installed in initrd with a simple program with no changes to kernel: #include #include #include #include #include int main(int argc, char **argv) { if (argc < 3) { fprintf(stderr, "Usage: %s syscall [syscall]... program\n", argv[0]); return EXIT_FAILURE; } scmp_filter_ctx ctx = seccomp_init(SCMP_ACT_ALLOW); if (ctx == NULL) { fprintf(stderr, "failed to init filter\n"); return EXIT_FAILURE; } int r; r = seccomp_attr_set(ctx, SCMP_FLTATR_CTL_NNP, 0); if (r != 0) { fprintf(stderr, "failed to disable NNP\n"); return EXIT_FAILURE; } fprintf(stderr, "filtering"); for (int i = 1; i < argc - 1; i++) { const char *syscall = argv[i]; int syscall_nr = seccomp_syscall_resolve_name(syscall); if (syscall_nr == __NR_SCMP_ERROR) { //fprintf(stderr, "unknown syscall %s, ignoring\n", syscall); continue; } r = seccomp_rule_add_exact(ctx, SCMP_ACT_ERRNO(ENOSYS), syscall_nr, 0); if (r != 0) { //fprintf(stderr, "failed to filter syscall %s, ignoring\n", syscall); continue; } fprintf(stderr, " %s", syscall); } fprintf(stderr, "\n"); r = seccomp_load(ctx); if (r != 0) { fprintf(stderr, "failed to apply filter\n"); return EXIT_FAILURE; } seccomp_release(ctx); char *program = argv[argc - 1]; char *new_argv[] = { program, NULL }; execv(program, new_argv); fprintf(stderr, "failed to exec %s\n", program); return EXIT_FAILURE; } This can be inserted in initrd to disable some obsolete and old system calls like this: #!/bin/sh exec /usr/local/sbin/seccomp-exec _sysctl afs_syscall bdflush break create_module ftime get_kernel_syms getpmsg gtty idle lock mpx prof profil putpmsg query_module security sgetmask ssetmask stty sysfs tuxcall ulimit uselib ustat vserver epoll_ctl_old epoll_wait_old old_adjtimex old_getpagesize oldfstat oldlstat oldolduname oldstat oldumount olduname osf_old_creat osf_old_fstat osf_old_getpgrp osf_old_killpg osf_old_lstat osf_old_open osf_old_sigaction osf_old_sigblock osf_old_sigreturn osf_old_sigsetmask osf_old_sigvec osf_old_stat osf_old_vadvise osf_old_vtrace osf_old_wait osf_oldquota vm86old brk /init -Topi