Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2027373ybd; Sun, 23 Jun 2019 22:46:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+yXR9gohl3ue/kmkQH/8rxA73LlZbDhvf5hxdzQ2EavQs3oZ68mzAGMWl/ijx39TAKw5D X-Received: by 2002:a63:60c5:: with SMTP id u188mr10161538pgb.159.1561355196565; Sun, 23 Jun 2019 22:46:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355196; cv=none; d=google.com; s=arc-20160816; b=qIgjVN2KQJ/zVGfrEkJZdUH/07txV1KdbcWel++Mp8rACAddpohLqNz2tqq4+LgxWJ CUYu8QXmynvQvHexH2E1zqNqzsmIw16cygp/0Oun6yfAtXWHiJ1Pj0qrRh3T/SrM4Inh uwWzjcPg8xlcaXYvIJ4zn0uR2+Yj9gzLYC88heHfj0O3UH8U3IttYqyJUD8C9zVTBPhU Ahs//jzGm2hCbVfRPTvxgWjhQOvUgYFILikN772DHhokKVq2BWH9H/P1lwpzpd6Zi20H F6RV7RdDWw6vT9oMqPRxccdpOJJRD45DcMGvcIMEjpvzcZVhoMwaF6FFiAZIMvGLdxHm tg0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dGgF55hFtmmmZc+ieAzS4XO99ZIShl4dVYuogqe2WpY=; b=iv9e0O74dGp69kZYef+HQH9xb0tNIaVzeu5YArRHxfAe0UMA+4VXhn6RZsuXQQgsYP jxnQjD9KP3OHPKzshZ83Af9wRGBiQD+1aOcQG6kNHQUkktERfA509BsSb+Ru96urH5fg Fqpa6Q/5s5cnEKMnaTcp19YNU225HBoF5Ziw3QCMEXZfth0BMvpwnWjg6Xa46DfZXvA0 GXC1ehXBR7LanxdkQACpvMx4/QxDmO3I79neGqMJP1/LEaCYYbiZHyERoQ1rbBqAZKlK 1e29OScrthQmb5aeJaQg+DX8nbkV5ge100nof5GMwQwYC9ql0irk7tHFIzxHPWpU8OFX gMKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=oQ+2sb4O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b17si10120797pjq.20.2019.06.23.22.46.21; Sun, 23 Jun 2019 22:46:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=oQ+2sb4O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727150AbfFXFna (ORCPT + 99 others); Mon, 24 Jun 2019 01:43:30 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35094 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726223AbfFXFn2 (ORCPT ); Mon, 24 Jun 2019 01:43:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=dGgF55hFtmmmZc+ieAzS4XO99ZIShl4dVYuogqe2WpY=; b=oQ+2sb4O0ME8d5ABjk4P58q0nw GIsnV3dmJ/XiMyp6DvmASmc4e5qGID3C66YIiTWRuy/o8Ws3yDWphOJBSiduNIzLdTKUaicf/eT5+ +J8xkvIy0OgTS9FXTCwbHDLUDO2czpVwB8TGgdLKOE/Fc+tVqHBSOvSMYLGLtsPKFswRD0EGvJ0bp AFIsQdQU3ONiJIJ4edKqFETEQtDQuKbY9oUUthtrbn2nDZik41DPsPUguFaOzAHoYKZvQzRL+t5LX BJKN5z/viz/nDZY3Ue8edIuv8pyfQgby9aJmhKEnEVq4ZKaEnbDqV0pszHiwm9V55p3Pa861BFO6P BV4LEQ5Q==; Received: from 213-225-6-159.nat.highway.a1.net ([213.225.6.159] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfHlG-00068k-3f; Mon, 24 Jun 2019 05:43:26 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Vladimir Murzin Subject: [PATCH 03/17] mm/nommu: fix the MAP_UNINITIALIZED flag Date: Mon, 24 Jun 2019 07:42:57 +0200 Message-Id: <20190624054311.30256-4-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624054311.30256-1-hch@lst.de> References: <20190624054311.30256-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We can't expose UAPI symbols differently based on CONFIG_ symbols, as userspace won't have them available. Instead always define the flag, but only respect it based on the config option. Signed-off-by: Christoph Hellwig Reviewed-by: Vladimir Murzin --- arch/xtensa/include/uapi/asm/mman.h | 6 +----- include/uapi/asm-generic/mman-common.h | 8 +++----- mm/nommu.c | 4 +++- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/arch/xtensa/include/uapi/asm/mman.h b/arch/xtensa/include/uapi/asm/mman.h index be726062412b..ebbb48842190 100644 --- a/arch/xtensa/include/uapi/asm/mman.h +++ b/arch/xtensa/include/uapi/asm/mman.h @@ -56,12 +56,8 @@ #define MAP_STACK 0x40000 /* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x80000 /* create a huge page mapping */ #define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */ -#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED -# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be +#define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be * uninitialized */ -#else -# define MAP_UNINITIALIZED 0x0 /* Don't support this flag */ -#endif /* * Flags for msync diff --git a/include/uapi/asm-generic/mman-common.h b/include/uapi/asm-generic/mman-common.h index abd238d0f7a4..cb556b430e71 100644 --- a/include/uapi/asm-generic/mman-common.h +++ b/include/uapi/asm-generic/mman-common.h @@ -19,15 +19,13 @@ #define MAP_TYPE 0x0f /* Mask for type of mapping */ #define MAP_FIXED 0x10 /* Interpret addr exactly */ #define MAP_ANONYMOUS 0x20 /* don't use a file */ -#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED -# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be uninitialized */ -#else -# define MAP_UNINITIALIZED 0x0 /* Don't support this flag */ -#endif /* 0x0100 - 0x80000 flags are defined in asm-generic/mman.h */ #define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */ +#define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be + * uninitialized */ + /* * Flags for mlock */ diff --git a/mm/nommu.c b/mm/nommu.c index d8c02fbe03b5..ec75a0dffd4f 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -1349,7 +1349,9 @@ unsigned long do_mmap(struct file *file, add_nommu_region(region); /* clear anonymous mappings that don't ask for uninitialized data */ - if (!vma->vm_file && !(flags & MAP_UNINITIALIZED)) + if (!vma->vm_file && + (!IS_ENABLED(CONFIG_MMAP_ALLOW_UNINITIALIZED) || + !(flags & MAP_UNINITIALIZED))) memset((void *)region->vm_start, 0, region->vm_end - region->vm_start); -- 2.20.1