Unverified Commit 334fac02 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!12548 fs/inode: Prevent dump_mapping() accessing invalid dentry.d_name.name

parents d12e74ed 1a35d29a
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ void __dump_page(struct page *page, const char *reason)
		struct hlist_node *dentry_first;
		struct dentry *dentry_ptr;
		struct dentry dentry;
		char fname[64] = {};
		unsigned long ino;

		/*
@@ -155,13 +156,14 @@ void __dump_page(struct page *page, const char *reason)
			pr_warn("aops:%ps ino:%lx with invalid dentry %px\n",
					a_ops, ino, dentry_ptr);
		} else {
			if (strncpy_from_kernel_nofault(fname, dentry.d_name.name, 63) < 0)
				strscpy(fname, "<invalid>", sizeof(fname));
			/*
			 * if dentry is corrupted, the %pd handler may still
			 * crash, but it's unlikely that we reach here with a
			 * corrupted struct page
			 * Even if strncpy_from_kernel_nofault() succeeded,
			 * the fname could be unreliable
			 */
			pr_warn("aops:%ps ino:%lx dentry name:\"%pd\"\n",
					a_ops, ino, &dentry);
			pr_warn("aops:%ps ino:%lx dentry name(?):\"%s\"\n",
					a_ops, ino, fname);
		}
	}
out_mapping: