mm/page_alloc.c: add additional checking and return value for the 'table->data'
Subsystems (2)
PATCH 1/1 mm/page_alloc.c: add additional checking and return value for the 'table->data'
If 'table->data' is invalid, also need check its length to know whether is invalid, firstly.
When __parse_numa_zonelist_order() fails, also need save the related error code for return.
Beautify code ('char*' --> 'char *') to pass "./scripts/checkpatch.pl"
Signed-off-by Chen Gang <[email protected]>
--- mm/page_alloc.c | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-)
mm/page_alloc.c +11 -4
@@ -3250,18 +3250,25 @@ int numa_zonelist_order_handler(ctl_table *table, int write,static DEFINE_MUTEX (zl_order_mutex);mutex_lock (&zl_order_mutex); -if (write) -strcpy (saved_string, (char *)table->data); +if (write) { +if (strlen ((char *)table->data) >=NUMA_ZONELIST_ORDER_LEN ) { + ret = -EINVAL ; + goto out; + } +strcpy (saved_string, (char *)table->data); + } ret =proc_dostring (table, write, buffer, length, ppos);if (ret) goto out;if (write) {int oldval = user_zonelist_order; -if (__parse_numa_zonelist_order ((char *)table->data)) { + + ret =__parse_numa_zonelist_order ((char *)table->data); +if (ret) {/* * bogus value. restore saved string */ -strncpy ((char *)table->data, saved_string, +strncpy ((char *)table->data, saved_string,NUMA_ZONELIST_ORDER_LEN ); user_zonelist_order = oldval; }else if (oldval != user_zonelist_order) {
Signature · 7 lines
1.7.7.6 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>