Commit 9ad38265 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Linus Torvalds

mm/debug: switch dump_page to get_kernel_nofault

This is simpler to use than copy_from_kernel_nofault().  Also make some of
the related error messages less verbose.
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Acked-by: default avatarMike Rapoport <rppt@linux.ibm.com>
Acked-by: default avatarVlastimil Babka <vbabka@suse.cz>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: William Kucharski <william.kucharski@oracle.com>
Link: http://lkml.kernel.org/r/20200709202117.7216-5-willy@infradead.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0b93d59e
...@@ -115,54 +115,50 @@ void __dump_page(struct page *page, const char *reason) ...@@ -115,54 +115,50 @@ void __dump_page(struct page *page, const char *reason)
else if (PageAnon(page)) else if (PageAnon(page))
type = "anon "; type = "anon ";
else if (mapping) { else if (mapping) {
const struct inode *host; struct inode *host;
const struct address_space_operations *a_ops; const struct address_space_operations *a_ops;
const struct hlist_node *dentry_first; struct hlist_node *dentry_first;
const struct dentry *dentry_ptr; struct dentry *dentry_ptr;
struct dentry dentry; struct dentry dentry;
/* /*
* mapping can be invalid pointer and we don't want to crash * mapping can be invalid pointer and we don't want to crash
* accessing it, so probe everything depending on it carefully * accessing it, so probe everything depending on it carefully
*/ */
if (copy_from_kernel_nofault(&host, &mapping->host, if (get_kernel_nofault(host, &mapping->host) ||
sizeof(struct inode *)) || get_kernel_nofault(a_ops, &mapping->a_ops)) {
copy_from_kernel_nofault(&a_ops, &mapping->a_ops, pr_warn("failed to read mapping contents, not a valid kernel address?\n");
sizeof(struct address_space_operations *))) {
pr_warn("failed to read mapping->host or a_ops, mapping not a valid kernel address?\n");
goto out_mapping; goto out_mapping;
} }
if (!host) { if (!host) {
pr_warn("mapping->a_ops:%ps\n", a_ops); pr_warn("aops:%ps\n", a_ops);
goto out_mapping; goto out_mapping;
} }
if (copy_from_kernel_nofault(&dentry_first, if (get_kernel_nofault(dentry_first, &host->i_dentry.first)) {
&host->i_dentry.first, sizeof(struct hlist_node *))) { pr_warn("aops:%ps with invalid host inode %px\n",
pr_warn("mapping->a_ops:%ps with invalid mapping->host inode address %px\n", a_ops, host);
a_ops, host);
goto out_mapping; goto out_mapping;
} }
if (!dentry_first) { if (!dentry_first) {
pr_warn("mapping->a_ops:%ps\n", a_ops); pr_warn("aops:%ps\n", a_ops);
goto out_mapping; goto out_mapping;
} }
dentry_ptr = container_of(dentry_first, struct dentry, d_u.d_alias); dentry_ptr = container_of(dentry_first, struct dentry, d_u.d_alias);
if (copy_from_kernel_nofault(&dentry, dentry_ptr, if (get_kernel_nofault(dentry, dentry_ptr)) {
sizeof(struct dentry))) { pr_warn("aops:%ps with invalid dentry %px\n", a_ops,
pr_warn("mapping->aops:%ps with invalid mapping->host->i_dentry.first %px\n", dentry_ptr);
a_ops, dentry_ptr);
} else { } else {
/* /*
* if dentry is corrupted, the %pd handler may still * if dentry is corrupted, the %pd handler may still
* crash, but it's unlikely that we reach here with a * crash, but it's unlikely that we reach here with a
* corrupted struct page * corrupted struct page
*/ */
pr_warn("mapping->aops:%ps dentry name:\"%pd\"\n", pr_warn("aops:%ps dentry name:\"%pd\"\n", a_ops,
a_ops, &dentry); &dentry);
} }
} }
out_mapping: out_mapping:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment