Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp469318ybk; Wed, 20 May 2020 04:22:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPZH3QcIzr8JoTTQ1WOMDphWN/QRpa7MYG2ZNnMXNgV0HnZhv0Oq0/NeqwvZgoY0kTTLVc X-Received: by 2002:a50:ace4:: with SMTP id x91mr2901561edc.361.1589973753993; Wed, 20 May 2020 04:22:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589973753; cv=none; d=google.com; s=arc-20160816; b=lpk82mz7i7c99En0JPEZ9iCvxL71//8Qtz4FDXQwmQxmimcnDUllX3tNLMZyFYO0AU SNBtm3eiGfzCNCA9eQ+gYkPdOHQIXvUKIyJXrGiRtvFUcYO5JwYxDV5j5Qtsjn27/SIG IP5GGR8tAP/YHjtYys9cKMlyIpzytx/XTSAmtqvHr3kuxwsXTRApBQc6PNEVl7ZV1TaA ZiFHkU7ou75OrsNaEFppdckyX5Bcsd7MwzDR1LiqsPdoOV6dMyt7tUx6pypyiAIiBZ0v DgV9BbjKX600vSXxH4GFMmGiXr1IGVfv2c41JC3CxaV3che9zMoAJJhMIwwhX8ZF5IaG BZCg== 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; bh=56SGhcyK7h3nlixc/WhwZR2DoIL8pNFZvChxJ3qBgro=; b=KDR6wvWB01HILIrAKWoRUit+ERqmGSAm03VyHDgW5lt4yyuuLUOcOekZKR6w4NMwSm g169VjVxfnBTKL0JeefUrihDMD8zgUIH+sM4vrixtRKPTp2Kl6TVyX+tj0sD4l7n1Fla aMcdIb2mnLYwtDJ2veNWbHOXiVYiKbFUQO7oWlVPu1oOHBbzRXHp9LIyB7GLIexUAki5 rSZNd+Fk+75bzZUoGTe76HM1/WQwdQcdnKhP5I2MjYe6ftOGd5vt8Jud1xkgSEZThpq5 onkBVCNKO9SAEdqRuCZDRj5U5nJxJZ0qiCREj3qjMG4KRKhgXOK7+5Rwv5VkIg3MmQYv rbpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=TxfYKVxY; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn4si1289820edb.398.2020.05.20.04.22.11; Wed, 20 May 2020 04:22:33 -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=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=TxfYKVxY; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726688AbgETLUm (ORCPT + 99 others); Wed, 20 May 2020 07:20:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726436AbgETLUl (ORCPT ); Wed, 20 May 2020 07:20:41 -0400 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB0A7C05BD43 for ; Wed, 20 May 2020 04:20:39 -0700 (PDT) Received: by mail-ej1-x641.google.com with SMTP id yc10so3272657ejb.12 for ; Wed, 20 May 2020 04:20:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=56SGhcyK7h3nlixc/WhwZR2DoIL8pNFZvChxJ3qBgro=; b=TxfYKVxYVFfCs8i2Vi9BQbNqxUsBlp737CU0QRWDFGflGGUqQ4KL0DrSCj9f5f8B9A srhor7uAaj568a/aA6w2KN1ZCj78ruiLf0w8AbVcmpl077VvtkSUPqEd5VpkpSCdIUb9 Cfjv1GMVvlTf5E8AbNLN3bn55sKNfaVjuvKp4= 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=56SGhcyK7h3nlixc/WhwZR2DoIL8pNFZvChxJ3qBgro=; b=GKbGqnNlv4Mk4dIlx0dZTe+mdPeqBLEpv/NphoovOJg+Xs2FW61mLMcoVq9Uwf2jKF +ajBxER3Iss+txqCwrLpG0bWguBvwg218o+pjOgUkOkpBBNWuZc55S2jmOmoRvrulN8y 7OInItZxYvykOG7zgPFD0tNXAyRbB99Z9ATY+RcuKS40sOFe+AXNdhWfKOqL0Z8gNWLp iDX7P5I2NhVIdQZKEfRjxAmPlGvMhizGXqe92FJp/mmNUtV1yv7S1jkGbFfZmfhmium/ zRKFb/b6cgDGH5qc65rp28p58PnA7RHCccHQvz34jcZXqlC3qzzBficU4d8Lnyh8zHna FghA== X-Gm-Message-State: AOAM530MugiFI364cyXMzTNhd+7Ukuk8FMORpXoGE3yT6N73faJ9wchG e7l+elv7zMMCQlcA0gvI/GXbzR6n8v+r0DTFQ26xVQ== X-Received: by 2002:a17:906:1199:: with SMTP id n25mr3543965eja.14.1589973638596; Wed, 20 May 2020 04:20:38 -0700 (PDT) MIME-Version: 1.0 References: <000000000000b4684e05a2968ca6@google.com> <9a56a79a-88ed-9ff4-115e-ec169cba5c0b@oracle.com> In-Reply-To: <9a56a79a-88ed-9ff4-115e-ec169cba5c0b@oracle.com> From: Miklos Szeredi Date: Wed, 20 May 2020 13:20:27 +0200 Message-ID: Subject: Re: kernel BUG at mm/hugetlb.c:LINE! To: Mike Kravetz Cc: Colin Walters , syzbot , Andrew Morton , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm , Miklos Szeredi , syzkaller-bugs , Al Viro 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 On Tue, May 19, 2020 at 2:35 AM Mike Kravetz wrote: > > On 5/18/20 4:41 PM, Colin Walters wrote: > > > > On Tue, May 12, 2020, at 11:04 AM, Miklos Szeredi wrote: > > > >>> However, in this syzbot test case the 'file' is in an overlayfs filesystem > >>> created as follows: > >>> > >>> mkdir("./file0", 000) = 0 > >>> mount(NULL, "./file0", "hugetlbfs", MS_MANDLOCK|MS_POSIXACL, NULL) = 0 > >>> chdir("./file0") = 0 > >>> mkdir("./file1", 000) = 0 > >>> mkdir("./bus", 000) = 0 > >>> mkdir("./file0", 000) = 0 > >>> mount("\177ELF\2\1\1", "./bus", "overlay", 0, "lowerdir=./bus,workdir=./file1,u"...) = 0 > > > > Is there any actual valid use case for mounting an overlayfs on top of hugetlbfs? I can't think of one. Why isn't the response to this to instead only allow mounting overlayfs on top of basically a set of whitelisted filesystems? > > > > I can not think of a use case. I'll let Miklos comment on adding whitelist > capability to overlayfs. I've not heard of overlayfs being used over hugetlbfs. Overlayfs on tmpfs is definitely used, I guess without hugepages. But if we'd want to allow tmpfs _without_ hugepages but not tmpfs _with_ hugepages, then we can't just whitelist based on filesystem type, but need to look at mount options as well. Which isn't really a clean solution either. > IMO - This BUG/report revealed two issues. First is the BUG by mmap'ing > a hugetlbfs file on overlayfs. The other is that core mmap code will skip > any filesystem specific get_unmapped area routine if on a union/overlay. > My patch fixes both, but if we go with a whitelist approach and don't allow > hugetlbfs I think we still need to address the filesystem specific > get_unmapped area issue. That is easy enough to do by adding a routine to > overlayfs which calls the routine for the underlying fs. I think the two are strongly related: get_unmapped_area() adjusts the address alignment, and the is_file_hugepages() call in ksys_mmap_pgoff() adjusts the length alignment. Is there any other purpose for which f_op->get_unmapped_area() is used by a filesystem? Thanks, Miklos