mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	coredump: don't pointlessly check and spew warnings
When a write happens it doesn't make sense to check perform checks on
the input. Skip them.
Whether a fixes tag is licensed is a bit of a gray area here but I'll
add one for the socket validation part I added recently.
Link: https://lore.kernel.org/20250821-moosbedeckt-denunziant-7908663f3563@brauner
Fixes: 16195d2c7d ("coredump: validate socket name as it is written")
Reported-by: Brad Spengler <brad.spengler@opensrcsec.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
			
			
This commit is contained in:
		
							parent
							
								
									41a86f6242
								
							
						
					
					
						commit
						be1e028302
					
				
					 2 changed files with 5 additions and 1 deletions
				
			
		| 
						 | 
					@ -1466,11 +1466,15 @@ static int proc_dostring_coredump(const struct ctl_table *table, int write,
 | 
				
			||||||
	ssize_t retval;
 | 
						ssize_t retval;
 | 
				
			||||||
	char old_core_pattern[CORENAME_MAX_SIZE];
 | 
						char old_core_pattern[CORENAME_MAX_SIZE];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (write)
 | 
				
			||||||
 | 
							return proc_dostring(table, write, buffer, lenp, ppos);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	retval = strscpy(old_core_pattern, core_pattern, CORENAME_MAX_SIZE);
 | 
						retval = strscpy(old_core_pattern, core_pattern, CORENAME_MAX_SIZE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	error = proc_dostring(table, write, buffer, lenp, ppos);
 | 
						error = proc_dostring(table, write, buffer, lenp, ppos);
 | 
				
			||||||
	if (error)
 | 
						if (error)
 | 
				
			||||||
		return error;
 | 
							return error;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!check_coredump_socket()) {
 | 
						if (!check_coredump_socket()) {
 | 
				
			||||||
		strscpy(core_pattern, old_core_pattern, retval + 1);
 | 
							strscpy(core_pattern, old_core_pattern, retval + 1);
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2048,7 +2048,7 @@ static int proc_dointvec_minmax_coredump(const struct ctl_table *table, int writ
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
 | 
						int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!error)
 | 
						if (!error && !write)
 | 
				
			||||||
		validate_coredump_safety();
 | 
							validate_coredump_safety();
 | 
				
			||||||
	return error;
 | 
						return error;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue