Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5578631imm; Tue, 12 Jun 2018 09:54:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJopSGhOTbsNiDzZPXasKLm+LQSfhCeF9N8T7kq97Isx1DUsnNZVCM55OmRalIzQUsY3cCL X-Received: by 2002:a65:4487:: with SMTP id l7-v6mr972001pgq.357.1528822499183; Tue, 12 Jun 2018 09:54:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528822499; cv=none; d=google.com; s=arc-20160816; b=ix5OQDYSFlOenEo4Dp3erK5drW8eMfiHILCXw1o8w9w7Ub0xsiM2asDvfNUYf3qIb6 JW01gW+I8NpgnUz6JKfC11Ty+C+JDjJTCUqBvkfSqdbadh0jEtpyh0ll2gBTut2DWI6n uFIDz4EZO+bpg3u4REgcR88XErCFO0guBqRYdo51eGjV7MVi6vLXnqleup8Vpks0WinC iLrqw8xDmQqA1T6zYmONtIZLICM+UYUb9FA9JLkqwfFSyQaz+4ad7R0bzuOjZbzEXG72 txHZ+cz9WZjfmVSVWdfqSYjRFSh1jOeHB1BNm/bZjEba12g5wT3dlSSTGN9VAy7UCY3H l28g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=7JVCwMNaj2IwDh4hEdZHDd8nDsXQkHBmo8v4ACr25PQ=; b=bde9TclE822GIw6V7qia4Ev8t1lrAcHLUqcsSyCQgXxIKSN8/AAkXACPAUqlokZ6pt KGQjPT+ZPjIBHoJWWHijLS/sLEsNXzx6ZSbCbSFhzWCUGmBqb/xHodC1J2WieBS6BBRN cufJq5xF0jS0DI0wPUX8SaLv1HXduzNq71eemWNX5oX01LkMQopSCQj9MoG7GAxuBSfI X7t9CyZOdpqHsMrjjnZ0Uq7FmbFxlzoK0h2MIld/UvD1IfRCtO1wnyFMuXaS/WCDg37b buXYw4dyOya07UFjGqdAnhbpoc/R1wtwlxYxa0DaryE77GSaPqNzCXttiqIg6jQFpKCP ZP7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1SojoRO3; 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 u133-v6si435326pgb.357.2018.06.12.09.54.44; Tue, 12 Jun 2018 09:54:59 -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=pass header.i=@kernel.org header.s=default header.b=1SojoRO3; 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 S934385AbeFLQx1 (ORCPT + 99 others); Tue, 12 Jun 2018 12:53:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:52410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933912AbeFLQxX (ORCPT ); Tue, 12 Jun 2018 12:53:23 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8C3F3208B7; Tue, 12 Jun 2018 16:53:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528822403; bh=VK1ErH3wh7IVfmNkUt4GwO7s9rsqCjY3UHGh5a38CZ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1SojoRO31YCreSCRl9LzXimtCRsz26ctbjW7DRjkUtUkmzBBjHExBQkMnBG4Q9KBL u3BDca9qf8HAoQ7py9NGp03PwYkfcN861qZmVKFgNJ3Qjl4hfoLt7faIc3ZRlpNDnu P4c7wZLtlFehlsbM0/Z1WZuPXBLcv62WqSBKOIKA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vasily Gorbik , Al Viro , Linus Torvalds Subject: [PATCH 4.4 04/24] mmap: relax file size limit for regular files Date: Tue, 12 Jun 2018 18:51:48 +0200 Message-Id: <20180612164816.778917851@linuxfoundation.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180612164816.587001852@linuxfoundation.org> References: <20180612164816.587001852@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Linus Torvalds commit 423913ad4ae5b3e8fb8983f70969fb522261ba26 upstream. Commit be83bbf80682 ("mmap: introduce sane default mmap limits") was introduced to catch problems in various ad-hoc character device drivers doing mmap and getting the size limits wrong. In the process, it used "known good" limits for the normal cases of mapping regular files and block device drivers. It turns out that the "s_maxbytes" limit was less "known good" than I thought. In particular, /proc doesn't set it, but exposes one regular file to mmap: /proc/vmcore. As a result, that file got limited to the default MAX_INT s_maxbytes value. This went unnoticed for a while, because apparently the only thing that needs it is the s390 kernel zfcpdump, but there might be other tools that use this too. Vasily suggested just changing s_maxbytes for all of /proc, which isn't wrong, but makes me nervous at this stage. So instead, just make the new mmap limit always be MAX_LFS_FILESIZE for regular files, which won't affect anything else. It wasn't the regular file case I was worried about. I'd really prefer for maxsize to have been per-inode, but that is not how things are today. Fixes: be83bbf80682 ("mmap: introduce sane default mmap limits") Reported-by: Vasily Gorbik Cc: Al Viro Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1278,7 +1278,7 @@ static inline int mlock_future_check(str static inline u64 file_mmap_size_max(struct file *file, struct inode *inode) { if (S_ISREG(inode->i_mode)) - return inode->i_sb->s_maxbytes; + return MAX_LFS_FILESIZE; if (S_ISBLK(inode->i_mode)) return MAX_LFS_FILESIZE;