Linux-Fsdevel Archive on lore.kernel.org help / color / mirror / Atom feed
From: Mike Kravetz <mike.kravetz@oracle.com> To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, overlayfs <linux-unionfs@vger.kernel.org>, linux-kernel@vger.kernel.org Cc: Al Viro <viro@zeniv.linux.org.uk>, Miklos Szeredi <miklos@szeredi.hu>, Matthew Wilcox <willy@infradead.org>, Colin Walters <walters@verbum.org>, Andrew Morton <akpm@linux-foundation.org>, syzbot <syzbot+d6ec23007e951dadf3de@syzkaller.appspotmail.com>, syzkaller-bugs <syzkaller-bugs@googlegroups.com>, Mike Kravetz <mike.kravetz@oracle.com> Subject: [PATCH v4 2/2] ovl: call underlying get_unmapped_area() routine. propogate FMODE_HUGETLBFS Date: Thu, 11 Jun 2020 17:46:44 -0700 [thread overview] Message-ID: <20200612004644.255692-2-mike.kravetz@oracle.com> (raw) In-Reply-To: <20200612004644.255692-1-mike.kravetz@oracle.com> The core routine get_unmapped_area will call a filesystem specific version of get_unmapped_area if it exists in file operations. If a file is on a union/overlay, overlayfs does not contain a get_unmapped_area f_op and the underlying filesystem routine may be ignored. Add an overlayfs f_op to call the underlying f_op if it exists. The routine is_file_hugetlbfs() is used to determine if a file is on hugetlbfs. This is determined by f_mode & FMODE_HUGETLBFS. Copy the mode to the overlayfs file during open so that is_file_hugetlbfs() will work as intended. These two issues can result in the BUG as shown in [1]. [1] https://lore.kernel.org/linux-mm/000000000000b4684e05a2968ca6@google.com/ Reported-by: syzbot+d6ec23007e951dadf3de@syzkaller.appspotmail.com Signed-off-by: Miklos Szeredi <miklos@szeredi.hu> Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com> --- fs/overlayfs/file.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index 87c362f65448..41e5746ba3c6 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -124,6 +124,8 @@ static int ovl_real_fdget(const struct file *file, struct fd *real) return ovl_real_fdget_meta(file, real, false); } +#define OVL_F_MODE_TO_UPPER (FMODE_HUGETLBFS) + static int ovl_open(struct inode *inode, struct file *file) { struct file *realfile; @@ -140,6 +142,9 @@ static int ovl_open(struct inode *inode, struct file *file) if (IS_ERR(realfile)) return PTR_ERR(realfile); + /* Copy modes from underlying file */ + file->f_mode |= (realfile->f_mode & OVL_F_MODE_TO_UPPER); + file->private_data = realfile; return 0; @@ -757,6 +762,21 @@ static loff_t ovl_remap_file_range(struct file *file_in, loff_t pos_in, remap_flags, op); } +#ifdef CONFIG_MMU +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); +} +#else +#define ovl_get_unmapped_area NULL +#endif + const struct file_operations ovl_file_operations = { .open = ovl_open, .release = ovl_release, @@ -774,6 +794,7 @@ const struct file_operations ovl_file_operations = { .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) -- 2.25.4
next prev parent reply other threads:[~2020-06-12 0:57 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-06-12 0:46 [PATCH v4 1/2] hugetlb: use f_mode & FMODE_HUGETLBFS to identify hugetlbfs files Mike Kravetz 2020-06-12 0:46 ` Mike Kravetz [this message] 2020-06-14 12:50 ` [PATCH v4 2/2] ovl: call underlying get_unmapped_area() routine. propogate FMODE_HUGETLBFS Amir Goldstein 2020-06-12 1:53 ` [PATCH v4 1/2] hugetlb: use f_mode & FMODE_HUGETLBFS to identify hugetlbfs files Matthew Wilcox 2020-06-12 1:58 ` Al Viro 2020-06-12 21:51 ` Mike Kravetz 2020-06-13 6:53 ` Amir Goldstein 2020-06-13 14:38 ` Matthew Wilcox 2020-06-13 19:12 ` Mike Kravetz 2020-06-15 7:53 ` Miklos Szeredi 2020-06-15 10:05 ` Amir Goldstein 2020-06-15 13:01 ` Miklos Szeredi 2020-06-15 23:45 ` Mike Kravetz 2020-06-16 9:01 ` Miklos Szeredi 2020-06-15 8:24 ` Miklos Szeredi 2020-06-15 17:48 ` Mike Kravetz 2020-06-12 6:28 ` [RFC PATCH] hugetlb: hugetlbfs_file_operations can be static kernel test robot
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200612004644.255692-2-mike.kravetz@oracle.com \ --to=mike.kravetz@oracle.com \ --cc=akpm@linux-foundation.org \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=linux-unionfs@vger.kernel.org \ --cc=miklos@szeredi.hu \ --cc=syzbot+d6ec23007e951dadf3de@syzkaller.appspotmail.com \ --cc=syzkaller-bugs@googlegroups.com \ --cc=viro@zeniv.linux.org.uk \ --cc=walters@verbum.org \ --cc=willy@infradead.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).