public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tty: vt: keyboard: do not copy an extra-byte in copy_to_user
@ 2021-11-06  9:20 Ajay Garg
  2021-11-06 11:23 ` Pavel Skripkin
  0 siblings, 1 reply; 22+ messages in thread
From: Ajay Garg @ 2021-11-06  9:20 UTC (permalink / raw)
  To: linux-serial, linux-kernel; +Cc: Ajay Garg

Both (statically-allocated) "user_kdgkb->kb_string" and
(dynamically-allocated) "kbs" are of length "len", so we must
not copy more than "len" bytes.

Signed-off-by: Ajay Garg <ajaygargnsit@gmail.com>
---
 drivers/tty/vt/keyboard.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index c7fbbcdcc346..dfef7de8a057 100644
--- a/drivers/tty/vt/keyboard.c
+++ b/drivers/tty/vt/keyboard.c
@@ -2070,7 +2070,7 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
 		len = strlcpy(kbs, func_table[kb_func] ? : "", len);
 		spin_unlock_irqrestore(&func_buf_lock, flags);
 
-		ret = copy_to_user(user_kdgkb->kb_string, kbs, len + 1) ?
+		ret = copy_to_user(user_kdgkb->kb_string, kbs, len) ?
 			-EFAULT : 0;
 
 		break;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2021-11-10  9:33 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-06  9:20 [PATCH] tty: vt: keyboard: do not copy an extra-byte in copy_to_user Ajay Garg
2021-11-06 11:23 ` Pavel Skripkin
2021-11-06 12:05   ` Ajay Garg
2021-11-06 12:39     ` Pavel Skripkin
2021-11-06 16:40   ` David Laight
2021-11-06 19:20     ` Ajay Garg
2021-11-06 19:46       ` Ajay Garg
2021-11-06 20:18         ` Pavel Skripkin
2021-11-06 20:30           ` Ajay Garg
2021-11-06 20:34             ` Pavel Skripkin
2021-11-06 20:44               ` Ajay Garg
2021-11-06 20:48                 ` Pavel Skripkin
2021-11-08  8:59                   ` Ajay Garg
2021-11-08 11:58                     ` Pavel Skripkin
2021-11-08 12:12                       ` Ajay Garg
2021-11-10  5:22                   ` Jiri Slaby
2021-11-10  7:37                     ` Pavel Skripkin
2021-11-10  8:57                       ` Ajay Garg
2021-11-10  9:06                         ` Greg KH
2021-11-10  9:32                           ` Ajay Garg
2021-11-06 19:56       ` Pavel Skripkin
2021-11-06 20:07         ` Ajay Garg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox