Re: [PATCH v11 2/2] ptrace,syscall_user_dispatch: checkpoint/restore support for SUD

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 02/21, Gregory Price wrote:
>
> +struct ptrace_sud_config {
> +	__u8  mode;
> +	__u8  pad[7];
              ^^^^^^
Why?

> +int syscall_user_dispatch_get_config(struct task_struct *task, unsigned long size,
> +		                     void __user *data)
> +{
> +	struct syscall_user_dispatch *sd = &task->syscall_dispatch;
> +	struct ptrace_sud_config config;
> +	if (size != sizeof(struct ptrace_sud_config))
> +		return -EINVAL;

Andrei, do we really need this check?

> +
> +	if (test_task_syscall_work(task, SYSCALL_USER_DISPATCH))
> +		config.mode = PR_SYS_DISPATCH_ON;
> +	else
> +		config.mode = PR_SYS_DISPATCH_OFF;
> +
> +	config.offset = sd->offset;
> +	config.len = sd->len;
> +	config.selector = (__u64)sd->selector;

As the kernel test robot reports, this is not -Wpointer-to-int-cast friendly.
Please use uintptr_t. See for example ptrace_get_rseq_configuration(). Same
for syscall_user_dispatch_set_config().

> +	if (copy_to_user(data, &config, sizeof(config))) {

This leaks info in (uninitialized) config.pad[]. You can probably simply make
config.mode __u64 as well.

Minor, but sizeof(struct ptrace_sud_config) above vs this sizeof(config)) doesn't
look consistent to me...

> +static int sys_ptrace(int request, pid_t pid, void *addr, void *data)
> +{
> +	return syscall(SYS_ptrace, request, pid, addr, data);
> +}

Why can't you simply use ptrace() ?

Oleg.




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux