Commit 35e15475 authored by Petr Mladek's avatar Petr Mladek
Browse files

Merge branch 'for-5.2-vsprintf-hardening' into for-linus

parents 3ec25826 ce9d3ece
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -58,6 +58,14 @@ A raw pointer value may be printed with %p which will hash the address
before printing. The kernel also supports extended specifiers for printing
pointers of different types.

Some of the extended specifiers print the data on the given address instead
of printing the address itself. In this case, the following error messages
might be printed instead of the unreachable information::

	(null)	 data on plain NULL address
	(efault) data on invalid address
	(einval) invalid data on a valid address

Plain Pointers
--------------

+22 −3
Original line number Diff line number Diff line
@@ -239,6 +239,7 @@ plain_format(void)
#define PTR ((void *)0x456789ab)
#define PTR_STR "456789ab"
#define PTR_VAL_NO_CRNG "(ptrval)"
#define ZEROS ""

static int __init
plain_format(void)
@@ -268,7 +269,6 @@ plain_hash_to_buffer(const void *p, char *buf, size_t len)
	return 0;
}


static int __init
plain_hash(void)
{
@@ -325,6 +325,24 @@ test_hashed(const char *fmt, const void *p)
	test(buf, fmt, p);
}

static void __init
null_pointer(void)
{
	test_hashed("%p", NULL);
	test(ZEROS "00000000", "%px", NULL);
	test("(null)", "%pE", NULL);
}

#define PTR_INVALID ((void *)0x000000ab)

static void __init
invalid_pointer(void)
{
	test_hashed("%p", PTR_INVALID);
	test(ZEROS "000000ab", "%px", PTR_INVALID);
	test("(efault)", "%pE", PTR_INVALID);
}

static void __init
symbol_ptr(void)
{
@@ -462,8 +480,7 @@ struct_rtc_time(void)
		.tm_year = 118,
	};

	test_hashed("%pt", &tm);

	test("(%ptR?)", "%pt", &tm);
	test("2018-11-26T05:35:43", "%ptR", &tm);
	test("0118-10-26T05:35:43", "%ptRr", &tm);
	test("05:35:43|2018-11-26", "%ptRt|%ptRd", &tm, &tm);
@@ -572,6 +589,8 @@ static void __init
test_pointer(void)
{
	plain();
	null_pointer();
	invalid_pointer();
	symbol_ptr();
	kernel_ptr();
	struct_resource();
+271 −160

File changed.

Preview size limit exceeded, changes collapsed.