From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, BUG6152_INVALID_DATE_TZ_ABSURD,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS,INVALID_DATE_TZ_ABSURD,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F83BC433E0 for ; Thu, 14 Jan 2021 16:02:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5271523B1A for ; Thu, 14 Jan 2021 16:02:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729272AbhANQBc (ORCPT ); Thu, 14 Jan 2021 11:01:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726881AbhANQBb (ORCPT ); Thu, 14 Jan 2021 11:01:31 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14C76C061574 for ; Thu, 14 Jan 2021 08:01:04 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1610640060; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=73B8Qve9y0JoijTWYi5Jyf92JaqGXWY23hQFwIxZv8Y=; b=1MTb4dnT8kfdDDpxQ/8tMoJEy/2MYa6bI9AkRN31Lx650zE+/9G1ZHc/V7d0gKdZBOoXxh twrJbIRYMVwevc89y6NhL2FG3NTjgo0QeDaP71r9+J0E1rcocXrKrYWWpwIGUjhHkBBqEf Ij9TSpD4yZbhmSIWQNC/VVGS0bhBXNCk6RCFwdzgJcOZgEANB4gG7kVqvHD1xiIAbs8fT4 RIqA/Jz3XtmetH6jVcVe0klIxqI/5FFtz4JOKjPWfA75Zz/9CIji6rQ3ymH1X+7iTsHvcK o3lvgu9Ccip90BowtIsMrmYrZYYZt9q/RExZg4wv6rlq2EB3th3a26wALrTr5g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1610640060; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=73B8Qve9y0JoijTWYi5Jyf92JaqGXWY23hQFwIxZv8Y=; b=0mbIr5uhSdPzfZ0v/K+IdCcM3QRupqGqD+k3PY4MVToS2VhdPvQ5v8eqM0OqGZMStmGWN9 eSpE0MCGCgT0acDQ== To: Petr Mladek Cc: Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , linux-kernel@vger.kernel.org Subject: Re: RFC: printk: kmsg_dump_get_line_nolock() buffer overflow In-Reply-To: References: <87im8038v7.fsf@jogness.linutronix.de> Date: Thu, 14 Jan 2021 17:06:59 +0106 Message-ID: <87im7zecec.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-01-14, Petr Mladek wrote: > It is pitty that I have missed this. I remember that I discussed > exactly this problem before, see > https://lore.kernel.org/lkml/20190710080402.ab3f4qfnvez6dhtc@axis.com/ > > And I did exactly the same mistake. I have missed the two users in > "arch/powerpc" and "arch/um". > > It is clear that this problem happens repeatedly. Yes, because the semantics are poor and undocumented. > Now, the change in record_printk_text() behavior affects also other > callers. For example, syslog_print() fills the buffer completely > as well now. I could imagine a userspace code that does the same > mistake and it works just by chance. No, syslog_print() works fine. There are only 2 users that think they can blindly add a byte at buffer[len]. Their code looks scary just seeing it. > We should restore the original record_printk_text() behavior > and add the comment explaining why it is done this way. OK. > And I would even explicitly add the trailing '\0' as suggested at > https://lore.kernel.org/lkml/20190710121049.rwhk7fknfzn3cfkz@pathway.suse.cz/#t OK. But then this becomes official semantics so powerpc/um no longer need to append a terminator. John Ogness