From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by sourceware.org (Postfix) with ESMTPS id A5E553857C49 for ; Sat, 24 Oct 2020 14:12:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A5E553857C49 Received: by mail-il1-x142.google.com with SMTP id p10so4165967ile.3 for ; Sat, 24 Oct 2020 07:12:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MgJfeca/4s0satLk61+xOaVoEfLF7ds/Hi2JJEDziWU=; b=WdDO5iaY39UXjZ/CwvCc7/Xj6bojCsVeZcGrTmc/45p76CWuGrzdMH53LEuNWu5esV O9GrBSWa/BAkakPhK2/mWcursl6w9s94gy5y7eCXaWUr6GQnic4AjpmGCcwf6iWKyZMI mLay/OheYtWd8U09/EYBvffeuNwG0kcYXlH+L76NFL+TBRA0P3KOQ7JAbFeMry1nNxh9 CFM3c3M+Luyv3KO9AEp/wkjBlmkgIp2scYxyoe6646wPMWE+XeYzTOTyr/9y+VbpoXQO ZdP86W52ggFYEA+YSi7r1EXVb82T1aJZr4QwKKRgwcDsQ09DxKJuyzl1xEbw2OzMCWwb JHOw== X-Gm-Message-State: AOAM530wbREATcsjKH/gye64vuCeMgAh/v9RWoAtCvC0zLzMIhYw5KTA gr5SgHVuX7LczHWUNLnFxdh9euQQ9AsPpD9zI8Y= X-Google-Smtp-Source: ABdhPJxALtvx3WMpnAnGGl1WqPBhdzP0ukYGoUEMsX7+QBgav0+412nekJGtwDyIlYZt5kvFXudvUAnQw7PTyzqFPh4= X-Received: by 2002:a05:6e02:d01:: with SMTP id g1mr4895628ilj.246.1603548767191; Sat, 24 Oct 2020 07:12:47 -0700 (PDT) MIME-Version: 1.0 References: <8584c14f-5c28-9d70-c054-7c78127d84ea@arm.com> <20201022075447.GO3819@arm.com> <78464155-f459-773f-d0ee-c5bdbeb39e5d@gmail.com> <202010221256.A4F95FD11@keescook> <180cd894-d42d-2bdb-093c-b5360b0ecb1e@gmail.com> <3cb894d4-049f-aa25-4450-d1df36a1b92e@gmail.com> In-Reply-To: <3cb894d4-049f-aa25-4450-d1df36a1b92e@gmail.com> From: Salvatore Mesoraca Date: Sat, 24 Oct 2020 15:12:36 +0100 Message-ID: Subject: Re: BTI interaction between seccomp filters in systemd and glibc mprotect calls, causing service failures To: Topi Miettinen Cc: Kees Cook , Szabolcs Nagy , Jeremy Linton , "linux-arm-kernel@lists.infradead.org" , libc-alpha@sourceware.org, systemd-devel@lists.freedesktop.org, "linux-kernel@vger.kernel.org" , Mark Rutland , Mark Brown , Dave Martin , Catalin Marinas , Will Deacon , Kernel Hardening , linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, 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: Sat, 24 Oct 2020 14:12:49 -0000 On Sat, 24 Oct 2020 at 12:34, Topi Miettinen wrote: > > On 23.10.2020 20.52, Salvatore Mesoraca wrote: > > Hi, > > > > On Thu, 22 Oct 2020 at 23:24, Topi Miettinen wrote: > >> SARA looks interesting. What is missing is a prctl() to enable all W^X > >> protections irrevocably for the current process, then systemd could > >> enable it for services with MemoryDenyWriteExecute=yes. > > > > SARA actually has a procattr[0] interface to do just that. > > There is also a library[1] to help using it. > > That means that /proc has to be available and writable at that point, so > setting up procattrs has to be done before mount namespaces are set up. > In general, it would be nice for sandboxing facilities in kernel if > there would be a way to start enforcing restrictions only at next > execve(), like setexeccon() for SELinux and aa_change_onexec() for > AppArmor. Otherwise the exact order of setting up various sandboxing > options can be very tricky to arrange correctly, since each option may > have a subtle effect to the sandboxing features enabled later. In case > of SARA, the operations done between shuffling the mount namespace and > before execve() shouldn't be affected so it isn't important. Even if it > did (a new sandboxing feature in the future would need trampolines or > JIT code generation), maybe the procattr file could be opened early but > it could be written closer to execve(). A new "apply on exec" procattr file seems reasonable and relatively easy to add. As Kees pointed out, the main obstacle here is the fact that SARA is not upstream :( Salvatore