From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E282C433E0 for ; Wed, 20 May 2020 11:20:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F322120758 for ; Wed, 20 May 2020 11:20:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=szeredi.hu header.i=@szeredi.hu header.b="TxfYKVxY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F322120758 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=szeredi.hu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4764780008; Wed, 20 May 2020 07:20:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 426E9900002; Wed, 20 May 2020 07:20:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3645180008; Wed, 20 May 2020 07:20:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0103.hostedemail.com [216.40.44.103]) by kanga.kvack.org (Postfix) with ESMTP id 1D3EB900002 for ; Wed, 20 May 2020 07:20:41 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D22053ABA for ; Wed, 20 May 2020 11:20:40 +0000 (UTC) X-FDA: 76836854640.01.bone71_5d28bc0cbd739 X-HE-Tag: bone71_5d28bc0cbd739 X-Filterd-Recvd-Size: 5139 Received: from mail-ej1-f65.google.com (mail-ej1-f65.google.com [209.85.218.65]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Wed, 20 May 2020 11:20:40 +0000 (UTC) Received: by mail-ej1-f65.google.com with SMTP id l21so3344027eji.4 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=UHtbBQgUXBQe2YRqQMTGC98rI+a0Kw2g9O4/r4NQIgIQUlnwdEVqNLCLEhmfd1WslO QLubRvAg0c6r5axVQwIr0Vk+P1KC3fKyPfGqUNcbAQTgmZwPLfnNf44a5pnIn441s+lb PLCu4gnpADHLKzTU35LSR97mfJCe943uBMjdoq5WQmDxLizRERnX32X19RaXswIDMFzR UoVeVuNbNugJEbwV2OO4TrrBulFF+KeVZVUEtJDPqHCjZSQFE1kUuRpCydI8iS6U5fbK NH2A0JKpxbDq3W3PIGZ6IxSjVDIMJnkJyOmsgyU79377y9QqYY0T17gY21zVTlokgVnF 31Ag== X-Gm-Message-State: AOAM533c8doaiUReqEaVEIPQ90leRQ2p3zMqliKPkQBrlZdkA9bN8myu XhDkGNTnoOjG2rxlAKnG/zgVkDDNSBF7aVkBeDLfbw== X-Google-Smtp-Source: ABdhPJx+P94dGQ64ppbHjlnXmNryVQv5No+atzEiem400vzryPPIDwWWuPy1i2M+gn6vmeZdZUDvyc08UUJyNWG+QyE= 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" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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