Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp602881pxk; Wed, 23 Sep 2020 11:01:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZpDFU5sRZXdHR4ohNWO61mxrSR8vapXrRcb+KHKi9wSAmMbg2R6o55pYpwwvADHS9KRLw X-Received: by 2002:a17:906:4101:: with SMTP id j1mr793025ejk.473.1600884096896; Wed, 23 Sep 2020 11:01:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600884096; cv=none; d=google.com; s=arc-20160816; b=TNowFpy+FXCG0e/YZyItjVDo3sMWGoEA8Kh1BseYkDVJMBkHgu/2YsFXKEQeqJvIuo 6O38+s9dOwtpadIVNraHvjxmdxIVysdK81Cg74tB6gUwxPllE8QDzTTw5oH+iksBT7/s z5HnUvlI4XHAdufMfeBoJOgPq0HN45er1qpIGLBwbuFiA6mf9egYITzUTlxf7CjZp7hO udmcFptENX5NlQfaWDfjm3A0lhXLdu2ibRYGkW2PYwre6waSoaCi1A4AYUFe/Z+dQsNS xzuWiIr2BHWXxcQ1yQnNsOBT18VfxOA4MpMPBVoPKBfxZEkdyAWrxjIYRzzcEcvVCaZT HnnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=PgNZ7CBLlSdnuSEiotSZelWaxyVjVLJ6zhBvPKt2Z4o=; b=0cofg1jhk66RSFcaTTCShTt6TYV4k/5KLj1557hu6TcdL4a+T0zWRiQP9oI0YrZpQl ssB28uzgS763vZ7H6g68XAyWNuYKqN+BOzcdYk7+SiHGwOdq02IuvWR8s0U+qFX5+z0p agkX9zdoVqBg2HBNu4tR3BdqLPccVebTVe/O0gTDLx7Ojg+OxlQf3axrZiVBOEMrpNl9 oUiT2OIys0anNCRUc71es6pPTwYiP81nAgiOZiYnHeJ+RB1wJrEcXsICEyZkfsoFGATU 5kQGi/QAdOlg6ayXY9z3tPr4xd0fBSWLXu6mAfJphaWBHcC0XypXOb3r4GaVHf3Hu4Hu mDyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b19si395008edw.155.2020.09.23.11.01.11; Wed, 23 Sep 2020 11:01:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726424AbgIWSAP (ORCPT + 99 others); Wed, 23 Sep 2020 14:00:15 -0400 Received: from mother.openwall.net ([195.42.179.200]:53992 "HELO mother.openwall.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726460AbgIWSAP (ORCPT ); Wed, 23 Sep 2020 14:00:15 -0400 Received: (qmail 18029 invoked from network); 23 Sep 2020 18:00:12 -0000 Received: from localhost (HELO pvt.openwall.com) (127.0.0.1) by localhost with SMTP; 23 Sep 2020 18:00:12 -0000 Received: by pvt.openwall.com (Postfix, from userid 503) id 59151AB844; Wed, 23 Sep 2020 20:00:07 +0200 (CEST) Date: Wed, 23 Sep 2020 20:00:07 +0200 From: Solar Designer To: Pavel Machek Cc: madvenka@linux.microsoft.com, kernel-hardening@lists.openwall.com, linux-api@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, oleg@redhat.com, x86@kernel.org, luto@kernel.org, David.Laight@ACULAB.COM, fweimer@redhat.com, mark.rutland@arm.com, mic@digikod.net, Rich Felker Subject: Re: [PATCH v2 0/4] [RFC] Implement Trampoline File Descriptor Message-ID: <20200923180007.GA8646@openwall.com> References: <20200922215326.4603-1-madvenka@linux.microsoft.com> <20200923081426.GA30279@amd> <20200923091456.GA6177@openwall.com> <20200923141102.GA7142@openwall.com> <20200923151835.GA32555@duo.ucw.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200923151835.GA32555@duo.ucw.cz> User-Agent: Mutt/1.4.2.3i Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 23, 2020 at 05:18:35PM +0200, Pavel Machek wrote: > > It sure does make sense to combine ret2libc/ROP to mprotect() with one's > > own injected shellcode. Compared to doing everything from ROP, this is > > easier and more reliable across versions/builds if the desired > > payload > > Ok, so this starts to be a bit confusing. > > I thought W^X is to protect from attackers that have overflowed buffer > somewhere, but can not to do arbitrary syscalls, yet. > > You are saying that there's important class of attackers that can do > some syscalls but not arbitrary ones. They might be able to do many, most, or all arbitrary syscalls via ret2libc or such. The crucial detail is that each time they do that, they risk incompatibility with the given target system (version, build, maybe ASLR if gadgets from multiple libraries are involved). By using mprotect(), they only take this risk once (need to get the address of an mprotect() gadget and of what to change protections on right), and then they can invoke multiple syscalls from their shellcode more reliably. So for doing a lot of work, mprotect() combined with injected code can be easier and more reliable. It is also an extra option an attacker can use, in addition to doing everything via borrowed code. More flexibility for the attacker means the attacker may choose whichever approach works better in a given case (or try several). I am embarrassed for not thinking/recalling this when I first posted earlier today. It's actually obvious. I'm just getting old and rusty. > I'd like to see definition of that attacker (and perhaps description > of the system the protection is expected to be useful on -- if it is > not close to common Linux distros). There's nothing unusual about that attacker and the system. A couple of other things Brad kindly pointed out: SELinux already has similar protections (execmem, execmod): http://lkml.iu.edu/hypermail/linux/kernel/0508.2/0194.html https://danwalsh.livejournal.com/6117.html PaX MPROTECT is implemented in a way or at a layer that covers ptrace() abuse that I mentioned. (At least that's how I understood Brad.) Alexander P.S. Meanwhile, Twitter locked my account "for security purposes". Fun. I'll just let it be for now.