MT#57093 shortcut copy-out

Only copy the output part of the kernel I/O structures.

Change-Id: I11fbec83f63d0e2f68d0c5c7c1cc4270a320f277
pull/1642/head
Richard Fuchs 3 years ago
parent 8b4d337e86
commit 5efbd6deab

@ -3549,7 +3549,7 @@ static inline ssize_t proc_control_read_write(struct file *file, char __user *ub
int err;
enum rtpengine_command cmd;
char scratchbuf[512];
size_t readlen;
size_t readlen, writelen, writeoffset;
union {
struct rtpengine_command_noop *noop;
@ -3605,8 +3605,15 @@ static inline ssize_t proc_control_read_write(struct file *file, char __user *ub
// copy in the entire request
readlen = input_req_sizes[cmd];
if (!readlen)
if (!readlen) {
readlen = buflen;
writelen = buflen;
writeoffset = 0;
}
else {
writelen = buflen - readlen;
writeoffset = readlen;
}
err = -EFAULT;
if (copy_from_user(msg.storage, ubuf, readlen))
goto err_table_free;
@ -3681,7 +3688,7 @@ static inline ssize_t proc_control_read_write(struct file *file, char __user *ub
if (writeable) {
err = -EFAULT;
if (copy_to_user(ubuf, msg.storage, buflen))
if (copy_to_user(ubuf + writeoffset, msg.storage + writeoffset, writelen))
goto err_free;
}

Loading…
Cancel
Save