Subject: + printk-add-comment-about-tricky-check-for-text-buffer-size.patch added to -mm tree To: pmladek@xxxxxxx,fweisbec@xxxxxxxxx,jack@xxxxxxx,kay@xxxxxxxx,mhocko@xxxxxxx,rostedt@xxxxxxxxxxx From: akpm@xxxxxxxxxxxxxxxxxxxx Date: Tue, 18 Feb 2014 13:03:44 -0800 The patch titled Subject: printk: add comment about tricky check for text buffer size has been added to the -mm tree. Its filename is printk-add-comment-about-tricky-check-for-text-buffer-size.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/printk-add-comment-about-tricky-check-for-text-buffer-size.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/printk-add-comment-about-tricky-check-for-text-buffer-size.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Petr Mladek <pmladek@xxxxxxx> Subject: printk: add comment about tricky check for text buffer size There is no check for potential "text_len" overflow. It is not needed because only valid level is detected. It took me some time to understand why. It would deserve a comment ;-) Signed-off-by: Petr Mladek <pmladek@xxxxxxx> Cc: Steven Rostedt <rostedt@xxxxxxxxxxx> Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx> Cc: Jan Kara <jack@xxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxx> Cc: Kay Sievers <kay@xxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- kernel/printk/printk.c | 5 +++++ 1 file changed, 5 insertions(+) diff -puN kernel/printk/printk.c~printk-add-comment-about-tricky-check-for-text-buffer-size kernel/printk/printk.c --- a/kernel/printk/printk.c~printk-add-comment-about-tricky-check-for-text-buffer-size +++ a/kernel/printk/printk.c @@ -1561,6 +1561,11 @@ asmlinkage int vprintk_emit(int facility case 'd': /* KERN_DEFAULT */ lflags |= LOG_PREFIX; } + /* + * No need to check length here because vscnprintf + * put '\0' at the end of the string. Only valid and + * newly printed level is detected. + */ text_len -= end_of_header - text; text = (char *)end_of_header; } _ Patches currently in -mm which might be from pmladek@xxxxxxx are printk-remove-duplicated-check-for-log-level.patch printk-remove-obsolete-check-for-log-level-c.patch printk-add-comment-about-tricky-check-for-text-buffer-size.patch printk-use-also-the-last-bytes-in-the-ring-buffer.patch printk-do-not-compute-the-size-of-the-message-twice.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html