From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by sourceware.org (Postfix) with ESMTPS id E62BF3857C52 for ; Thu, 22 Oct 2020 10:04:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E62BF3857C52 Received: by mail-lf1-x143.google.com with SMTP id j30so1521762lfp.4 for ; Thu, 22 Oct 2020 03:04:19 -0700 (PDT) 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=v+g60jSFAWmJk25t84LrgkacnZZF5EGyn0T0qZYVJPQ=; b=U4e/lhiJnMxyNawcvE9v5bvQBYSxlTH4G6IPPR/SURWM5iREaH7NxDxoGBkL7LA79F 1FDIRQst92hgvF8O0k3YQQ/TmjkPcV6R3r1r3HnyyMsXyqpmr5YPDJ6aK3aBRNQa2Ner jLU+E71WkwQmDzkq7+bWsFNtuLRWrOWBYD4jSYOtq9cOKQmWbUS4txw7GaVm56yDGQm2 Jkdi+nZ+4fS9Oma/LOAnQrWi0jqMNRlJN2dZ0kVrXEW/atz6RM68/+h+ACDbu6aTs8Di +kEvBkjCQNoZfLnI8WFbNZQh3wRVWIKmFCpF9Zku7DdFeHcop86BHT+nyR3Fk/uykg32 ctzg== X-Gm-Message-State: AOAM531Hkm09h9qGtWNnfTCa6NWlu/G5a4C9v/qkC6CVQjvJ9/dhzzl2 mEJKAsTB29mBR4I3K3UEKOG5i96SBPs= X-Google-Smtp-Source: ABdhPJwH9XOdDe0YlZMRGx22HEpQlzpQeIUZpjxkbSUK3SepOq2QRD5zb2keQbFEDVMtjNYwhkZhhw== X-Received: by 2002:a19:434f:: with SMTP id m15mr528494lfj.601.1603361058694; Thu, 22 Oct 2020 03:04:18 -0700 (PDT) Received: from [192.168.1.112] (88-114-211-119.elisa-laajakaista.fi. [88.114.211.119]) by smtp.gmail.com with ESMTPSA id m4sm227110ljg.137.2020.10.22.03.04.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Oct 2020 03:04:18 -0700 (PDT) Subject: Re: [systemd-devel] BTI interaction between seccomp filters in systemd and glibc mprotect calls, causing service failures To: Szabolcs Nagy Cc: Florian Weimer , Lennart Poettering , Mark Rutland , systemd-devel@lists.freedesktop.org, Kees Cook , Catalin Marinas , Will Deacon , "linux-kernel@vger.kernel.org" , Mark Brown , libc-alpha@sourceware.org, Dave Martin , "linux-arm-kernel@lists.infradead.org" References: <8584c14f-5c28-9d70-c054-7c78127d84ea@arm.com> <20201022071812.GA324655@gardel-login> <87sga6snjn.fsf@oldenburg2.str.redhat.com> <511318fd-efde-f2fc-9159-9d16ac8d33a7@gmail.com> <20201022082912.GQ3819@arm.com> From: Topi Miettinen Message-ID: <55b44a39-ab19-363e-3703-9bf4e7d75f68@gmail.com> Date: Thu, 22 Oct 2020 13:03:59 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20201022082912.GQ3819@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Oct 2020 10:04:21 -0000 On 22.10.2020 11.29, Szabolcs Nagy wrote: > The 10/22/2020 11:17, Topi Miettinen via Libc-alpha wrote: >> On 22.10.2020 10.54, Florian Weimer wrote: >>> * Lennart Poettering: >>>> Did you see Topi's comments on the systemd issue? >>>> >>>> https://github.com/systemd/systemd/issues/17368#issuecomment-710485532 >>>> >>>> I think I agree with this: it's a bit weird to alter the bits after >>>> the fact. Can't glibc set up everything right from the begining? That >>>> would keep both concepts working. >>> >>> The dynamic loader has to process the LOAD segments to get to the ELF >>> note that says to enable BTI. Maybe we could do a first pass and load >>> only the segments that cover notes. But that requires lots of changes >>> to generic code in the loader. >> >> What if the loader always enabled BTI for PROT_EXEC pages, but then when >> discovering that this was a mistake, mprotect() the pages without BTI? Then >> both BTI and MDWX would work and the penalty of not getting MDWX would fall >> to non-BTI programs. What's the expected proportion of BTI enabled code vs. >> disabled in the future, is it perhaps expected that a distro would enable >> the flag globally so eventually only a few legacy programs might be >> unprotected? > > i thought mprotect(PROT_EXEC) would get filtered > with or without bti, is that not the case? It would be filtered, but the idea is that with modern binaries this would not happen since the pages would be mapped with mmap(,, PROT_EXEC | PROT_BTI,,) which is OK for purposes MDWX. The loader would have to use mprotect(PROT_EXEC) to get rid of PROT_BTI only for the legacy binaries. -Topi