Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp5793846imm; Sat, 19 May 2018 09:45:57 -0700 (PDT) X-Google-Smtp-Source: AB8JxZogwzqg2/zO0uq8DlAkrenQab/vufESb5KzOUsx3zjL9x8FfJ048A1WtFpbx+TDEbuyyPaS X-Received: by 2002:a63:b046:: with SMTP id z6-v6mr10753653pgo.16.1526748357255; Sat, 19 May 2018 09:45:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526748357; cv=none; d=google.com; s=arc-20160816; b=IBbkL7sM42SomOY7PtIbwDMH6nKN6Uvw946kzarLEXhawOcK+Hnc1u3G0igG9nYmIh IN7mQtc/SjKV49ZqH//WENaHMfnr6ckY9IzmUE1jfpMGI894vnQkRpjeu2s0gU3RekbO UMDciP+3tPVy46sBuFGEzHjCMCnihb+cy0Hw4hsSPRvl0aQVGwUM0mufCepS/rPVcHsT g6qmo2unz29okhlgFusVSP8odVLJcpQ3PFFOTMDAf5bwMsLhdIqv4icE+zOW5fPrULT/ 5xrKfoObx/SVnDoVq8Thrjqyit47Mdg6SUgQi4Su4iCV/kLQkTKqlYHGX/c3WySkHX7o e/cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=8bpPf0olyRI6jUPRaPbNycp5j7piUqrk1VNHT1igqYw=; b=fdoO3PC3DuoBBsH4GO+thOVI8ZBUXtx0sMVOXvZIFO4LxKWVOWnjfMKpEst17ctpIt npWSGvOPcpLALDW9W+8giR26w0sbAYsrV3Iog+D2PcjuCh+ur2J8xZ196uXxBj5mqthC 3frLhfCx+dUXn65Jb9TIodi7PF0z1K3Hvv+mCk5m+U7ezM4SbShXhfcHyiODtpnKhp/Z AozqVSHOCTB4J6vd+po8HBprAWnOB+6HI/CS452Ld4hRcp3vN7kmF/hclWxCh47nq61e kRWgRuzeWieJqMRjcQsv9PUFNZm97wu5OtOErLN8jEfqtyxMW76z+vqw/nBeXGmGVHR+ GCUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=PmT6+1Iz; 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 z188-v6si9707947pfz.335.2018.05.19.09.45.41; Sat, 19 May 2018 09:45:57 -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=@linux-foundation.org header.s=google header.b=PmT6+1Iz; 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 S1752453AbeESQpd (ORCPT + 99 others); Sat, 19 May 2018 12:45:33 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:36460 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752280AbeESQpc (ORCPT ); Sat, 19 May 2018 12:45:32 -0400 Received: by mail-io0-f196.google.com with SMTP id d73-v6so9802928iog.3 for ; Sat, 19 May 2018 09:45:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8bpPf0olyRI6jUPRaPbNycp5j7piUqrk1VNHT1igqYw=; b=PmT6+1IzFpaZVGhWp55pXLtI0TROikmTOy5WfIcoZwFTwCd/csC79kSneZ7ixa7Ch0 OTehof/ZdiiPFK5Lacco7+aEzgMS9xOt9qsrMqpvX9Kz7fEbm1FIMYp6ebexGI8owe+1 VvW/wVYPxihkZ5osHvOT3P7gBBuuUo5iT/2EE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8bpPf0olyRI6jUPRaPbNycp5j7piUqrk1VNHT1igqYw=; b=EdIGpBrun8D+vBykfSD1YThpdQrMMU2CSQSktpb59VZgBeOt56zTBPF2z9bmtRUS/5 g+LrcFVxo7sGPcdRqCz8CxKD3bWqeBywOAfwRTAgHBAKaEj7NQ8DpLxxtbWG2wbIrWdw iCMQ7jDT+BIkodz/FYlyg/5SZdtT2VgllNGAmiBtlvVZiSLt4Gxp41+G3TlqULOcOyX0 dDCwPGmx5d5TNqwI4GDgvNjSN6g9vYrguKDm1W1ROjenwHz07E1KUhr9rl6+LYwFoQoO IjQD0GcgXV5FWxVFBRK3SbzYelKQkOz4gvO6ei/SWE4XMk3gACV3A9NrpxbnosHG9o/M dn3Q== X-Gm-Message-State: ALKqPweYlpcWwsUwKKIL51dt/v/+15aPEf8AG2yPbGEkj83PzlkCdkI8 3yS9w20zEnB9J6GBhr/erkOLz08mki4KTIjbT74= X-Received: by 2002:a6b:6803:: with SMTP id d3-v6mr15069040ioc.48.1526748331613; Sat, 19 May 2018 09:45:31 -0700 (PDT) MIME-Version: 1.0 References: <20180519034338.GV30522@ZenIV.linux.org.uk> In-Reply-To: From: Linus Torvalds Date: Sat, 19 May 2018 09:45:20 -0700 Message-ID: Subject: Re: [PATCH] procfs: fix mmap() for /proc/vmcore To: gor@linux.ibm.com Cc: Al Viro , Andrew Morton , Linux Kernel Mailing List , Heiko Carstens Content-Type: multipart/mixed; boundary="000000000000f7c2a5056c91cbcb" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --000000000000f7c2a5056c91cbcb Content-Type: text/plain; charset="UTF-8" On Sat, May 19, 2018 at 4:39 AM Vasily Gorbik wrote: > Would work, but file_mmap_size_max first checks > if (S_ISREG(inode->i_mode)) > return inode->i_sb->s_maxbytes; > before > if (file->f_mode & FMODE_UNSIGNED_OFFSET) > return 0; > so, as it is this patch does not fix the issue. Right you are. We could easily reverse the order of those two checks, but since clearly the s_maxbytes case hadn't gotten as much coverage as I thought it had, let's just simplify file_mmap_size_max() instead, and just make the limit be MAX_LFS_FILESIZE for regular files too, the way we already do for block devices (instead of trying to figure out the size of the block device). That way we won't be introducing changes to s_maxbytes late in the rc series, and we'll only affect the new logic. Plus regular files was never what that logic really was introduced to protect against anyway. It's the random ad-hoc mmap implementations in drivers that it really aimed to protect. So for now, I've committed the minimal fixlet that doesn't affect any existing code (just the new max file size logic), and maybe this can be revisited for 4.18. Linus --000000000000f7c2a5056c91cbcb Content-Type: application/x-patch; name="0001-mmap-relax-file-size-limit-for-regular-files.patch" Content-Disposition: attachment; filename="0001-mmap-relax-file-size-limit-for-regular-files.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_jhdmgx450 RnJvbSA0MjM5MTNhZDRhZTViM2U4ZmI4OTgzZjcwOTY5ZmI1MjIyNjFiYTI2IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBMaW51cyBUb3J2YWxkcyA8dG9ydmFsZHNAbGludXgtZm91bmRh dGlvbi5vcmc+CkRhdGU6IFNhdCwgMTkgTWF5IDIwMTggMDk6Mjk6MTEgLTA3MDAKU3ViamVjdDog W1BBVENIXSBtbWFwOiByZWxheCBmaWxlIHNpemUgbGltaXQgZm9yIHJlZ3VsYXIgZmlsZXMKCkNv bW1pdCBiZTgzYmJmODA2ODIgKCJtbWFwOiBpbnRyb2R1Y2Ugc2FuZSBkZWZhdWx0IG1tYXAgbGlt aXRzIikgd2FzCmludHJvZHVjZWQgdG8gY2F0Y2ggcHJvYmxlbXMgaW4gdmFyaW91cyBhZC1ob2Mg Y2hhcmFjdGVyIGRldmljZSBkcml2ZXJzCmRvaW5nIG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