Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp617020pxt; Thu, 12 Aug 2021 06:06:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTbFsUM2+Cke+7uHh5DitFNb0Jtrqp64rRbdzsnciuLrT/pnTbZ+NqKEPRPYtY36MNVEBH X-Received: by 2002:a05:6512:118a:: with SMTP id g10mr2453587lfr.491.1628773567643; Thu, 12 Aug 2021 06:06:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628773567; cv=none; d=google.com; s=arc-20160816; b=njy+I9i17P6iBa//1dFtlwlbYi3SPovjUFpV9LcME7LpqMptgBwOcd2P470SyDLsTC IVwidKUtkuvlL0Vx4/uemU/RZrTlioXKIce3P14JYGvsR6Kd/hTmlFPix3ASdY3LuG24 Nh7dA03+UKk1SnHmxUEja85OCPAFNDksZgZnwQzYdu2vMFZe/WKYDdQulfh4l9LyBkQn GUNJyBvtrJUCTIUOlIeAdR4K3pj7yarHzczaXY33mUSVfK/w6RBd4wYKUKzeujqbnfiq C0iWCNnErjNSBMgMk8K+xUr9J5QYrBCNEWmDH/1JECZgbhyn+dMdRTnDlqK+Gi7cPqnh s+Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=67VxuLoInCrL14SlTIDdgh0fWkak+9n8Xf3485B2J+A=; b=Elqfe26+2M9Y7wJ9CS3i//ve8j4Tmk8KgeMiFLTocyH+inCIIlBVjxGHeq0x2wTK+6 Cb0GqBvs3vivFICJYx9eSzMuGJ1CbquVSzIL0w0UQ9+EU7XulgOlR3t/OzX44HIQNdFB wdDbQVZqz5Wg2+bmNdC11PpkeFEJzJjSqY59hcukM3q6aiZ/JrlwJl/WiRYmKOXuVfau nd7ks+Tz20XYOCqC4IKGOj30vSHtJLpS5MrMDPSg5KA1QMGSWWAZ5F0F+dqw1ZF+NAEh ikdj8Y9kJ3RGo/WvYNGsusjC/kb74TPJ6NF18RNQ5Dp7BSFUhrwd1i1zUIynRfgqJZw7 ESCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MaHl4Svf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m11si2366868edc.207.2021.08.12.06.05.37; Thu, 12 Aug 2021 06:06:07 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MaHl4Svf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236211AbhHLMV3 (ORCPT + 99 others); Thu, 12 Aug 2021 08:21:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49437 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236398AbhHLMV1 (ORCPT ); Thu, 12 Aug 2021 08:21:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628770861; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=67VxuLoInCrL14SlTIDdgh0fWkak+9n8Xf3485B2J+A=; b=MaHl4SvfwLF3u+hb3q+7MPy3TeuAxdl+U4eVWEjdqMlbKRRNZhRqA8i7JTngHNdp/L7nxE dVovuXcd6vt9FKe85FMAZGiiIpYGdHAmxf08sOd2qagrM9WBcInnDJuXkz8lfhWPc4HYNW +8mEBlZ5r+WwHJT+sfRoB7UlDPGHbLY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-447-gxDVc6M-Ox-S_Gxm2GGHxw-1; Thu, 12 Aug 2021 08:21:00 -0400 X-MC-Unique: gxDVc6M-Ox-S_Gxm2GGHxw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 073861853025; Thu, 12 Aug 2021 12:20:59 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.194.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E1D6A5D9C6; Thu, 12 Aug 2021 12:20:38 +0000 (UTC) From: Florian Weimer To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, Linus Torvalds , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Alexander Viro , Alexey Dobriyan , Steven Rostedt , Peter Zijlstra , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Petr Mladek , Sergey Senozhatsky , Andy Shevchenko , Rasmus Villemoes , Kees Cook , "Eric W. Biederman" , Greg Ungerer , Geert Uytterhoeven , Mike Rapoport , Vlastimil Babka , Vincenzo Frascino , Chinwen Chang , Michel Lespinasse , Catalin Marinas , "Matthew Wilcox (Oracle)" , Huang Ying , Jann Horn , Feng Tang , Kevin Brodsky , Michael Ellerman , Shawn Anastasio , Steven Price , Nicholas Piggin , Christian Brauner , Jens Axboe , Gabriel Krisman Bertazi , Peter Xu , Suren Baghdasaryan , Shakeel Butt , Marco Elver , Daniel Jordan , Nicolas Viennot , Thomas Cedeno , Collin Fijalkovich , Michal Hocko , Miklos Szeredi , Chengguang Xu , Christian =?utf-8?Q?K=C3=B6nig?= , linux-unionfs@vger.kernel.org, linux-api@vger.kernel.org, x86@kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v1 0/7] Remove in-tree usage of MAP_DENYWRITE References: <20210812084348.6521-1-david@redhat.com> Date: Thu, 12 Aug 2021 14:20:37 +0200 In-Reply-To: <20210812084348.6521-1-david@redhat.com> (David Hildenbrand's message of "Thu, 12 Aug 2021 10:43:41 +0200") Message-ID: <87r1eyg8h6.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * David Hildenbrand: > There are some (minor) user-visible changes with this series: > 1. We no longer deny write access to shared libaries loaded via legacy > uselib(); this behavior matches modern user space e.g., via dlopen(). > 2. We no longer deny write access to the elf interpreter after exec > completed, treating it just like shared libraries (which it often is). We have a persistent issue with people using cp (or similar tools) to replace system libraries. Since the file is truncated first, all relocations and global data are replaced by file contents, result in difficult-to-diagnose crashes. It would be nice if we had a way to prevent this mistake. It doesn't have to be MAP_DENYWRITE or MAP_COPY. It could be something completely new, like an option that turns every future access beyond the truncation point into a signal (rather than getting bad data or bad code and crashing much later). I don't know how many invalid copy operations are currently thwarted by the current program interpreter restriction. I doubt that lifting the restriction matters. > 3. We always deny write access to the file linked via /proc/pid/exe: > sys_prctl(PR_SET_MM_EXE_FILE) will fail if write access to the file > cannot be denied, and write access to the file will remain denied > until the link is effectivel gone (exec, termination, > PR_SET_MM_EXE_FILE) -- just as if exec'ing the file. > > I was wondering if we really care about permanently disabling write access > to the executable, or if it would be good enough to just disable write > access while loading the new executable during exec; but I don't know > the history of that -- and it somewhat makes sense to deny write access > at least to the main executable. With modern user space -- dlopen() -- we > can effectively modify the content of shared libraries while being used. Is there a difference between ET_DYN and ET_EXEC executables? Thanks, Florian