Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp608085pxb; Mon, 16 Aug 2021 12:55:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGWoKDv2nHmVtuz1UikUGTEtUh1jbyA/hPegX6h5nnxBWHFbA7eUmP3EUZNiR1F3GwSvtd X-Received: by 2002:aa7:c810:: with SMTP id a16mr269553edt.195.1629143743885; Mon, 16 Aug 2021 12:55:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629143743; cv=none; d=google.com; s=arc-20160816; b=LoJqbLrGvDAnBAyhFla8UBF7lnSANZDZeab8wU6c0TTYkxkB2YSo+P/WrM0uqpA5JM 8r5PY7L4ysFa/xW5i82SwZxvWrloNXdd8zu9M7UDyFApmDJTo6/ABredwsVImrUUWbuI dFHMk439G+RjXkJ373saPC6MlEoCpKx61zA+iXc90diyHeAr6esmgri7aLAb27WfW1jF r1dbs6g4dabCCfiiXp9SCT0Y0OZFqt93qggcNwFWZnQBFPbai7yxRvDxIB/u37Z6Q84M RwKlHb46qvNn1lpfQlHJ+SihcOY9MwOSnzJyqDMny0b7xypgguOf8lPsbaqF4TH5PmnW 55PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SpO66406P+aAOH9nMaFQuRCCfyFRAgAvhM8DGsbyqP0=; b=b1mXjviQd07bc7UIuiYrSbyjsCm2lWNvgxzxgw1kNGnEdy0vFPKqnJWmo0+9b4UAMr oyK/OFTt4h8uXKO4aB6hOuA1ZMhR3eCVcf2U57Gdpd/qtZeVscUKapKbzPcXe4IcdSdB DnIZSgkqnkgFhmrUumDoGEKHS2jBLg+5wtk1sz4QB9rpKKHmzCXXFt6PzypyDzjjNavx 5wtn/3ApjWcWNqUnpaw1BoRH4T1JHCSBMzOuhyaJ1mbGKpquDOmrl4hSb9uXPEUyR+R1 upvSeHuId5IQ7aw9HoQLa85qBfcIS+6Wtz5ex96FKt20G6HhEeulKIMJ1S5WZ9gf6QBC XhKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VsIC5EK2; 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 f17si196789ejz.260.2021.08.16.12.55.20; Mon, 16 Aug 2021 12:55:43 -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=VsIC5EK2; 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 S231653AbhHPTwD (ORCPT + 99 others); Mon, 16 Aug 2021 15:52:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32787 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231587AbhHPTwA (ORCPT ); Mon, 16 Aug 2021 15:52:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629143488; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SpO66406P+aAOH9nMaFQuRCCfyFRAgAvhM8DGsbyqP0=; b=VsIC5EK2TQDcair/dw8Ry23YrazfHNsxMrRp70Sb2P7w/tn+dT+qrWpg84CNmOfqkVLwgI W9KhL3exZnxNLSFDR5J+ns1/aaW7tBRgPaBPPztTsk1amt/xPUiWsYJfgA/jaJtCrSybyT IDd4s9OohERRgusGwodouJ6uBuPtNqs= 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-558-4goGKXNePI-qhMOzOLNJiA-1; Mon, 16 Aug 2021 15:51:27 -0400 X-MC-Unique: 4goGKXNePI-qhMOzOLNJiA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 12296802922; Mon, 16 Aug 2021 19:51:26 +0000 (UTC) Received: from t480s.redhat.com (unknown [10.39.192.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id C242D5C1D5; Mon, 16 Aug 2021 19:51:06 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: David Hildenbrand , 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 , 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 , Michal Hocko , Miklos Szeredi , Chengguang Xu , =?UTF-8?q?Christian=20K=C3=B6nig?= , Florian Weimer , David Laight , linux-unionfs@vger.kernel.org, linux-api@vger.kernel.org, x86@kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 6/7] mm: ignore MAP_DENYWRITE in ksys_mmap_pgoff() Date: Mon, 16 Aug 2021 21:48:39 +0200 Message-Id: <20210816194840.42769-7-david@redhat.com> In-Reply-To: <20210816194840.42769-1-david@redhat.com> References: <20210816194840.42769-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Let's also remove masking off MAP_DENYWRITE from ksys_mmap_pgoff(): the last in-tree occurrence of MAP_DENYWRITE is now in LEGACY_MAP_MASK, which accepts the flag e.g., for MAP_SHARED_VALIDATE; however, the flag is ignored throughout the kernel now. Add a comment to LEGACY_MAP_MASK stating that MAP_DENYWRITE is ignored. Acked-by: "Eric W. Biederman" Signed-off-by: David Hildenbrand --- include/linux/mman.h | 3 ++- mm/mmap.c | 2 -- mm/nommu.c | 2 -- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/include/linux/mman.h b/include/linux/mman.h index bd9aadda047b..b66e91b8176c 100644 --- a/include/linux/mman.h +++ b/include/linux/mman.h @@ -32,7 +32,8 @@ * The historical set of flags that all mmap implementations implicitly * support when a ->mmap_validate() op is not provided in file_operations. * - * MAP_EXECUTABLE is completely ignored throughout the kernel. + * MAP_EXECUTABLE and MAP_DENYWRITE are completely ignored throughout the + * kernel. */ #define LEGACY_MAP_MASK (MAP_SHARED \ | MAP_PRIVATE \ diff --git a/mm/mmap.c b/mm/mmap.c index 589dc1dc13db..bf11fc6e8311 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1626,8 +1626,6 @@ unsigned long ksys_mmap_pgoff(unsigned long addr, unsigned long len, return PTR_ERR(file); } - flags &= ~MAP_DENYWRITE; - retval = vm_mmap_pgoff(file, addr, len, prot, flags, pgoff); out_fput: if (file) diff --git a/mm/nommu.c b/mm/nommu.c index 3a93d4054810..0987d131bdfc 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -1296,8 +1296,6 @@ unsigned long ksys_mmap_pgoff(unsigned long addr, unsigned long len, goto out; } - flags &= ~MAP_DENYWRITE; - retval = vm_mmap_pgoff(file, addr, len, prot, flags, pgoff); if (file) -- 2.31.1