From patchwork Tue Sep 1 15:08:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 310373 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=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 49493C433E7 for ; Tue, 1 Sep 2020 16:10:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 11D0F2067C for ; Tue, 1 Sep 2020 16:10:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598976620; bh=YH+ZfWRuTKPhQSveWFLTA34VHtcTmqp1ZmpGVqjZ3+k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=AaNFovGE8A2urJtm0IySo2HfpCI48kC1V37FHfFQ6AQZ3iB1szgVnWq4qw4Hg5Lsm jw5FA3vaHe3mbC7wxfErnrgByjR/v9vVIP+fHzrHrH/pOZlYwKe5VUsexYD1u5af5n +HxFApcTs4AHF9n6/r+azjntZTDFJstKBRftZhtQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731106AbgIAQKO (ORCPT ); Tue, 1 Sep 2020 12:10:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:47484 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729599AbgIAPi0 (ORCPT ); Tue, 1 Sep 2020 11:38:26 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 4173B2168B; Tue, 1 Sep 2020 15:38:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598974704; bh=YH+ZfWRuTKPhQSveWFLTA34VHtcTmqp1ZmpGVqjZ3+k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2HCHWsiEFKh+RU27l9KEiHvbCn98wupyR2knmsl5GypxgfF5ocpEzQ4WUwJFtgcnP rAXXxxVkLGIVJ0ZA88Zdyt5kaimmDsbvNH+O7SlHGaz9lNDvL0qqkFeDH3tUT6ii2P fTBp2e2nnvxVPUJV+YQdf2JShpZ1zpv9pplFOj2I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+d6ec23007e951dadf3de@syzkaller.appspotmail.com, Amir Goldstein , Mike Kravetz , Andrew Morton , Miklos Szeredi , Al Viro , Matthew Wilcox , Colin Walters , Linus Torvalds , Sasha Levin Subject: [PATCH 5.8 063/255] hugetlbfs: prevent filesystem stacking of hugetlbfs Date: Tue, 1 Sep 2020 17:08:39 +0200 Message-Id: <20200901151003.744842719@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901151000.800754757@linuxfoundation.org> References: <20200901151000.800754757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Mike Kravetz [ Upstream commit 15568299b7d9988063afce60731df605ab236e2a ] syzbot found issues with having hugetlbfs on a union/overlay as reported in [1]. Due to the limitations (no write) and special functionality of hugetlbfs, it does not work well in filesystem stacking. There are no know use cases for hugetlbfs stacking. Rather than making modifications to get hugetlbfs working in such environments, simply prevent stacking. [1] https://lore.kernel.org/linux-mm/000000000000b4684e05a2968ca6@google.com/ Reported-by: syzbot+d6ec23007e951dadf3de@syzkaller.appspotmail.com Suggested-by: Amir Goldstein Signed-off-by: Mike Kravetz Signed-off-by: Andrew Morton Acked-by: Miklos Szeredi Cc: Al Viro Cc: Matthew Wilcox Cc: Colin Walters Link: http://lkml.kernel.org/r/80f869aa-810d-ef6c-8888-b46cee135907@oracle.com Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/hugetlbfs/inode.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index ef5313f9c78fe..f936bcf02cce7 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1364,6 +1364,12 @@ hugetlbfs_fill_super(struct super_block *sb, struct fs_context *fc) sb->s_magic = HUGETLBFS_MAGIC; sb->s_op = &hugetlbfs_ops; sb->s_time_gran = 1; + + /* + * Due to the special and limited functionality of hugetlbfs, it does + * not work well as a stacking filesystem. + */ + sb->s_stack_depth = FILESYSTEM_MAX_STACK_DEPTH; sb->s_root = d_make_root(hugetlbfs_get_root(sb, ctx)); if (!sb->s_root) goto out_free;