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.0 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 C7E4AC4320E for ; Sat, 14 Aug 2021 09:06:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 635D660F4B for ; Sat, 14 Aug 2021 09:06:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 635D660F4B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id C7BC36B0072; Sat, 14 Aug 2021 05:06:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C04CE6B0073; Sat, 14 Aug 2021 05:06:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A7F296B0074; Sat, 14 Aug 2021 05:06:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0210.hostedemail.com [216.40.44.210]) by kanga.kvack.org (Postfix) with ESMTP id 8A0B06B0072 for ; Sat, 14 Aug 2021 05:06:55 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 2DE181F226 for ; Sat, 14 Aug 2021 09:06:55 +0000 (UTC) X-FDA: 78473106390.16.572776C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 9B7D610003DE for ; Sat, 14 Aug 2021 09:06:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628932013; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sWOfJKXDv3Msrm1oZtxU2+iL1w42iciVMe2lnnbOuSA=; b=IZudabC6+PPKpDqUUOvvZ8dNb0ZZBvTXwtNN1eK/zdOLkV7WwFpgEehA1U9kQXE/KMxvRK Pa0/2FXyk6+l3bfTbadv7MmXUvepD3Oj16xecsMatS/gcuhPDvaZBuX0NTZrp14Ac/qqRm LBe+MbT7T4FJVXp5e0CyArPy4R8hLNE= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-507-QrW84baxMIKFvs42EQQ16A-1; Sat, 14 Aug 2021 05:06:52 -0400 X-MC-Unique: QrW84baxMIKFvs42EQQ16A-1 Received: by mail-wr1-f69.google.com with SMTP id z2-20020adff1c20000b0290154f60e3d2aso3559355wro.23 for ; Sat, 14 Aug 2021 02:06:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:organization:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=sWOfJKXDv3Msrm1oZtxU2+iL1w42iciVMe2lnnbOuSA=; b=XYw28sIlzmUcEKRxyVhF4dj2Q+lOg8G3iv7srUkKq2lVNKaZqf6jNbESMsUGGCP5k+ wqJHFvQ7mLyNEmaC4FLlCziQu4PyA0qRW352hm2JWNkpBDnqk+4Vt6B+2v9spEmt0mSB kekPYkzDx18y6SzqJY9+uAoMVBh+7pUXLz4XJSd8wdaGVB3M0XSndAQXfyCktRYL3xy8 eNZmCHwG+4vl/qD/kMrtH0EMIHZMjvsIKNzrHQItxA5OzBiyXaaLak0O9a8cTXP3GBwx x5W6/UWKgPdqxUr4muvhO1tKb8CHmhol5sVpSoYij9IfqPAR/Ir+kGkWJeSwT8RDk1ly X3ag== X-Gm-Message-State: AOAM532/5IUaD5wcze9ehvkXiJfVhhgE4KGRdee28HwaVmF4/OU8Zzyy K49TddsTw9fjkM/tASFZQ3T25SlqiAqMpt6IQjc3OCqOuJqjHqpdWvOL5mL+FO5+0xB2Oam7eqE KxP8GY/E4J2k= X-Received: by 2002:a1c:3b09:: with SMTP id i9mr6361379wma.62.1628932011309; Sat, 14 Aug 2021 02:06:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmRQCvf+Z+ORlo8pa+7ajUFCHPEEEB/g8t9ifOo/hJh3Qa3/emogzOCEyiSbKRsyYXp+6DPg== X-Received: by 2002:a1c:3b09:: with SMTP id i9mr6361322wma.62.1628932011053; Sat, 14 Aug 2021 02:06:51 -0700 (PDT) Received: from [192.168.3.132] (p4ff2325a.dip0.t-ipconnect.de. [79.242.50.90]) by smtp.gmail.com with ESMTPSA id l9sm3846322wrt.95.2021.08.14.02.06.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 14 Aug 2021 02:06:50 -0700 (PDT) To: Al Viro , Linus Torvalds Cc: Andy Lutomirski , "Eric W. Biederman" , David Laight , Linux Kernel Mailing List , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Alexey Dobriyan , Steven Rostedt , "Peter Zijlstra (Intel)" , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Petr Mladek , Sergey Senozhatsky , Andy Shevchenko , Rasmus Villemoes , Kees Cook , 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 , =?UTF-8?Q?Christian_K=c3=b6nig?= , "linux-unionfs@vger.kernel.org" , Linux API , the arch/x86 maintainers , linux-fsdevel@vger.kernel.org, Linux-MM , Florian Weimer , Michael Kerrisk References: <87lf56bllc.fsf@disp2133> <87eeay8pqx.fsf@disp2133> <5b0d7c1e73ca43ef9ce6665fec6c4d7e@AcuMS.aculab.com> <87h7ft2j68.fsf@disp2133> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v1 0/7] Remove in-tree usage of MAP_DENYWRITE Message-ID: Date: Sat, 14 Aug 2021 11:06:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IZudabC6; spf=none (imf12.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 9B7D610003DE X-Stat-Signature: cisj1xtyfqqungsuxak615gtzz6fsbgs X-HE-Tag: 1628932014-464585 Content-Transfer-Encoding: quoted-printable 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 14.08.21 04:02, Al Viro wrote: > On Sat, Aug 14, 2021 at 01:57:31AM +0000, Al Viro wrote: >> On Fri, Aug 13, 2021 at 02:58:57PM -1000, Linus Torvalds wrote: >>> On Fri, Aug 13, 2021 at 2:54 PM Linus Torvalds >>> wrote: >>>> >>>> And nobody really complained when we weakened it, so maybe removing = it >>>> entirely might be acceptable. >>> >>> I guess we could just try it and see... Worst comes to worst, we'll >>> have to put it back, but at least we'd know what crazy thing still >>> wants it.. >> >> Umm... I'll need to go back and look through the thread, but I'm >> fairly sure that there used to be suckers that did replacement of >> binary that way (try to write, count on exclusion with execve while >> it's being written to) instead of using rename. Install scripts >> of weird crap and stuff like that... >=20 > ... and before anyone goes off - I certainly agree that using that > behaviour is not a good idea and had never been one. All I'm saying > is that there at least used to be very random (and rarely exercised) > bits of userland relying upon that behaviour. >=20 Removing it completely is certainly more controversial than limiting it=20 to the main executable. I'm mostly happy as long as we get rid of that=20 nasty per-VMA handling, because that adds real complexity at places that=20 are complicated enough. Having the remaining deny_write_access()/allow_write_access() at sane=20 places now (loading a new binary, exchanging exe_file) looks certainly=20 much cleaner and I still consider it a valuable, simple sanity feature=20 to have around. I don't think there is any sane use case for modifying=20 the main executable, and it seems to be very easy to catch. For example, besides users that rely on this behavior, in my thinking=20 (see the cover letter), especially having a binary not getting changed=20 while we're loading it sounds like a very good idea (not saying we would=20 expose a way to exploit the kernel if we would allow for modifications=20 while in the elf parser, but also not saying we wouldn't because I=20 didn't check if there would be a way; at least we already allow it in=20 the legacy library loader before mapping the segments with=20 MAP_DENYWRITE). And if we decide to keep the behavior while loading the=20 executable, keeping it while exe_file is set isn't much added=20 code/complexity IMHO. Long story short, I'd vote for keeping it in, and if we decide to rip it=20 out completely, do it a a separate, more careful step. --=20 Thanks, David / dhildenb