Thread (22 messages) 22 messages, 5 authors, 2021-11-10

Re: [PATCH] tty: vt: keyboard: do not copy an extra-byte in copy_to_user

From: Ajay Garg <hidden>
Date: 2021-11-06 20:30:33
Also in: lkml

quoted
2.
== Calculate the actual length of kbs, add 1, and then copy those many
bytes to user-buffer ==

ret = copy_to_user(user_kdgkb->kb_string, kbs, len + 1) ?
                         -EFAULT : 0;
=>
ret = copy_to_user(user_kdgkb->kb_string, kbs, strlen(kbs) + 1) ?
                         -EFAULT : 0;
But isn't strlen(kbs) is guaranteed to be equal to strlcpy() return
value in this case? As I said in previous emails,
strlen(func_table[kb_func]) < sizeof(user_kdgkb->kb_string) by design of
this function.
That's the whole point of the discussion :)

The method "vt_do_kdgkb_ioctl" does not manage "func_table[kb_func]".
Thus, the method does not know whether or not
strlen(func_table[kb_func]) < sizeof(user_kdgkb->kb_string).

The intention is to make the method itself robust, without relying on
any external "chances" :)
Do we need extra strlen() call here? Let's see what more experienced
people think about it :)
Yep, let's wait for more feedback ..
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help