diff options
Diffstat (limited to 'kernel/sys.c')
| -rw-r--r-- | kernel/sys.c | 81 | 
1 files changed, 51 insertions, 30 deletions
| diff --git a/kernel/sys.c b/kernel/sys.c index 2969304c29fe..f9bc5c303e3f 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -103,12 +103,6 @@  #ifndef SET_TSC_CTL  # define SET_TSC_CTL(a)		(-EINVAL)  #endif -#ifndef MPX_ENABLE_MANAGEMENT -# define MPX_ENABLE_MANAGEMENT()	(-EINVAL) -#endif -#ifndef MPX_DISABLE_MANAGEMENT -# define MPX_DISABLE_MANAGEMENT()	(-EINVAL) -#endif  #ifndef GET_FP_MODE  # define GET_FP_MODE(a)		(-EINVAL)  #endif @@ -124,6 +118,12 @@  #ifndef PAC_RESET_KEYS  # define PAC_RESET_KEYS(a, b)	(-EINVAL)  #endif +#ifndef SET_TAGGED_ADDR_CTRL +# define SET_TAGGED_ADDR_CTRL(a)	(-EINVAL) +#endif +#ifndef GET_TAGGED_ADDR_CTRL +# define GET_TAGGED_ADDR_CTRL()		(-EINVAL) +#endif  /*   * this is where the system-wide overflow UID and GID are defined, for @@ -1279,11 +1279,13 @@ SYSCALL_DEFINE1(uname, struct old_utsname __user *, name)  SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)  { -	struct oldold_utsname tmp = {}; +	struct oldold_utsname tmp;  	if (!name)  		return -EFAULT; +	memset(&tmp, 0, sizeof(tmp)); +  	down_read(&uts_sem);  	memcpy(&tmp.sysname, &utsname()->sysname, __OLD_UTS_LEN);  	memcpy(&tmp.nodename, &utsname()->nodename, __OLD_UTS_LEN); @@ -1557,15 +1559,6 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,  			retval = -EPERM;  		if (!retval)  			retval = security_task_setrlimit(tsk, resource, new_rlim); -		if (resource == RLIMIT_CPU && new_rlim->rlim_cur == 0) { -			/* -			 * The caller is asking for an immediate RLIMIT_CPU -			 * expiry.  But we use the zero value to mean "it was -			 * never set".  So let's cheat and make it one second -			 * instead -			 */ -			new_rlim->rlim_cur = 1; -		}  	}  	if (!retval) {  		if (old_rlim) @@ -1576,10 +1569,9 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,  	task_unlock(tsk->group_leader);  	/* -	 * RLIMIT_CPU handling.   Note that the kernel fails to return an error -	 * code if it rejected the user's attempt to set RLIMIT_CPU.  This is a -	 * very long-standing error, and fixing it now risks breakage of -	 * applications, so we live with it +	 * RLIMIT_CPU handling. Arm the posix CPU timer if the limit is not +	 * infite. In case of RLIM_INFINITY the posix CPU timer code +	 * ignores the rlimit.  	 */  	 if (!retval && new_rlim && resource == RLIMIT_CPU &&  	     new_rlim->rlim_cur != RLIM_INFINITY && @@ -1773,8 +1765,8 @@ void getrusage(struct task_struct *p, int who, struct rusage *r)  	unlock_task_sighand(p, &flags);  out: -	r->ru_utime = ns_to_timeval(utime); -	r->ru_stime = ns_to_timeval(stime); +	r->ru_utime = ns_to_kernel_old_timeval(utime); +	r->ru_stime = ns_to_kernel_old_timeval(stime);  	if (who != RUSAGE_CHILDREN) {  		struct mm_struct *mm = get_task_mm(p); @@ -2269,6 +2261,8 @@ int __weak arch_prctl_spec_ctrl_set(struct task_struct *t, unsigned long which,  	return -EINVAL;  } +#define PR_IO_FLUSHER (PF_MEMALLOC_NOIO | PF_LESS_THROTTLE) +  SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,  		unsigned long, arg4, unsigned long, arg5)  { @@ -2456,15 +2450,9 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,  		up_write(&me->mm->mmap_sem);  		break;  	case PR_MPX_ENABLE_MANAGEMENT: -		if (arg2 || arg3 || arg4 || arg5) -			return -EINVAL; -		error = MPX_ENABLE_MANAGEMENT(); -		break;  	case PR_MPX_DISABLE_MANAGEMENT: -		if (arg2 || arg3 || arg4 || arg5) -			return -EINVAL; -		error = MPX_DISABLE_MANAGEMENT(); -		break; +		/* No longer implemented: */ +		return -EINVAL;  	case PR_SET_FP_MODE:  		error = SET_FP_MODE(me, arg2);  		break; @@ -2492,6 +2480,39 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,  			return -EINVAL;  		error = PAC_RESET_KEYS(me, arg2);  		break; +	case PR_SET_TAGGED_ADDR_CTRL: +		if (arg3 || arg4 || arg5) +			return -EINVAL; +		error = SET_TAGGED_ADDR_CTRL(arg2); +		break; +	case PR_GET_TAGGED_ADDR_CTRL: +		if (arg2 || arg3 || arg4 || arg5) +			return -EINVAL; +		error = GET_TAGGED_ADDR_CTRL(); +		break; +	case PR_SET_IO_FLUSHER: +		if (!capable(CAP_SYS_RESOURCE)) +			return -EPERM; + +		if (arg3 || arg4 || arg5) +			return -EINVAL; + +		if (arg2 == 1) +			current->flags |= PR_IO_FLUSHER; +		else if (!arg2) +			current->flags &= ~PR_IO_FLUSHER; +		else +			return -EINVAL; +		break; +	case PR_GET_IO_FLUSHER: +		if (!capable(CAP_SYS_RESOURCE)) +			return -EPERM; + +		if (arg2 || arg3 || arg4 || arg5) +			return -EINVAL; + +		error = (current->flags & PR_IO_FLUSHER) == PR_IO_FLUSHER; +		break;  	default:  		error = -EINVAL;  		break; | 
