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 24AA9C433E2 for ; Fri, 22 May 2020 10:06:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A0375205CB for ; Fri, 22 May 2020 10:05:59 +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="jw5fHtL/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A0375205CB 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 D78B180008; Fri, 22 May 2020 06:05:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D29EC80007; Fri, 22 May 2020 06:05:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C3FD680008; Fri, 22 May 2020 06:05:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0019.hostedemail.com [216.40.44.19]) by kanga.kvack.org (Postfix) with ESMTP id AC1FC80007 for ; Fri, 22 May 2020 06:05:58 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 72A1D2493 for ; Fri, 22 May 2020 10:05:58 +0000 (UTC) X-FDA: 76843923996.03.pen42_8b5ecb24af120 X-HE-Tag: pen42_8b5ecb24af120 X-Filterd-Recvd-Size: 5655 Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Fri, 22 May 2020 10:05:57 +0000 (UTC) Received: by mail-ed1-f66.google.com with SMTP id e10so8893034edq.0 for ; Fri, 22 May 2020 03:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=DtZfx2mo8Milc18ngyMfW1PIcYKBj/EvVpvJqR76B+Y=; b=jw5fHtL/RIM8xz3E7sdN0sc8voc91MwoIIXai4ooDW3LkOeQGwMZMR5x4k7IoykRVw nceGbEdL8kBLjrHQGcoqPbP3QWGcrvwJlGepODGT+tTiexRgI7/fxoU9Dg/0t/nOj0Ax W8a0S8U1i4xN8yv0ngkz1Mjhi30imTAiGDmW0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=DtZfx2mo8Milc18ngyMfW1PIcYKBj/EvVpvJqR76B+Y=; b=Oyct/KVYhCmN4ntgZFhKU+WmV7R4WnsfNCgK/oZnP2XVhteo3WY0tES9I1jp/duiTk rnJ6CLU5a9u0gmO/CnnLYXgNW75M6CsrDkf/13B5Y74aEw4a+JJbIsnwxZMchyf52oxn tleQflrSTVGrsrV0YB6IOH0iU1PoxmyMPmiPTGUy9c71eN+AtdchX5gDg9MPkVO0rEke 5n2iKNrbaJrZ0yZMd4GexZvxkMuftXKCJeMSrY+iGdiLA7HaUlfww6ktSvC3TRDtSzc8 QnYAZy444R9uaENk38nMbuiz4FIKGNRJ3NXRnD6BeU9Fh8r0wCfHpBgcze4AKkkhI4Lr ib9g== X-Gm-Message-State: AOAM533OYAz35iBSMzo95Nfcy5vqyjSPjZB9nfJ7nN0PaO14fNjaHCjd De6VKG8b/Wmuj6w8Wkl6yuB4hw== X-Google-Smtp-Source: ABdhPJxesQBnmboD62I4SZU4WGLsBVnkI5YIilNVuotJbFhyVWl5+N/8HBerDSceQ46v2AtGVAVygQ== X-Received: by 2002:a50:dac4:: with SMTP id s4mr2416371edj.84.1590141956086; Fri, 22 May 2020 03:05:56 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id s17sm7132537edr.84.2020.05.22.03.05.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 03:05:55 -0700 (PDT) Date: Fri, 22 May 2020 12:05:53 +0200 From: Miklos Szeredi 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 , linux-unionfs@vger.kernel.org Subject: Re: kernel BUG at mm/hugetlb.c:LINE! Message-ID: <20200522100553.GE13131@miu.piliscsaba.redhat.com> References: <000000000000b4684e05a2968ca6@google.com> <9a56a79a-88ed-9ff4-115e-ec169cba5c0b@oracle.com> <78313ae9-8596-9cbe-f648-3152660be9b3@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <78313ae9-8596-9cbe-f648-3152660be9b3@oracle.com> 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 Wed, May 20, 2020 at 10:27:15AM -0700, Mike Kravetz wrote: > I am fairly confident it is all about checking limits and alignment. The > filesystem knows if it can/should align to base or huge page size. DAX has > some interesting additional restrictions, and several 'traditional' filesystems > check if they are 'on DAX'. Okay, I haven't looked at DAX vs. overlay. I'm sure it's going to come up at some point, if it hasn't already. > > In a previous e-mail, you suggested hugetlb_get_unmapped_area could do the > length adjustment in hugetlb_get_unmapped_area (generic and arch specific). > I agree, although there may be the need to add length overflow checks in > these routines (after round up) as this is done in core code now. However, > this can be done as a separate cleanup patch. > > In any case, we need to get the core mmap code to call filesystem specific > get_unmapped_area if on a union/overlay. The patch I suggested does this > by simply calling real_file to determine if there is a filesystem specific > get_unmapped_area. The other approach would be to provide an overlayfs > get_unmapped_area that calls the underlying filesystem get_unmapped_area. That latter is what's done for all other stacked operations in overlayfs. Untested patch below. Thanks, Miklos --- fs/overlayfs/file.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -757,6 +757,17 @@ static loff_t ovl_remap_file_range(struc remap_flags, op); } +static unsigned long ovl_get_unmapped_area(struct file *file, + unsigned long uaddr, unsigned long len, + unsigned long pgoff, unsigned long flags) +{ + struct file *realfile = file->private_data; + + return (realfile->f_op->get_unmapped_area ?: + current->mm->get_unmapped_area)(realfile, + uaddr, len, pgoff, flags); +} + const struct file_operations ovl_file_operations = { .open = ovl_open, .release = ovl_release, @@ -774,6 +785,7 @@ const struct file_operations ovl_file_op .copy_file_range = ovl_copy_file_range, .remap_file_range = ovl_remap_file_range, + .get_unmapped_area = ovl_get_unmapped_area, }; int __init ovl_aio_request_cache_init(void)