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 BCA36C433E0 for ; Sun, 24 Jan 2021 08:14:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 78B2222582 for ; Sun, 24 Jan 2021 08:14:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726634AbhAXIOp (ORCPT ); Sun, 24 Jan 2021 03:14:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbhAXIOY (ORCPT ); Sun, 24 Jan 2021 03:14:24 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 436F0C061573 for ; Sun, 24 Jan 2021 00:13:43 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1611476021; 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=b6ARxzSACzyN+3uDousJyVDfsRj+7AoBf0/EqK7Wevo=; b=ju2C0Bpuk+7J6SdtXoy1c/2wdsIrYKvl68F2WVm2dF5KsWz6PJcpN4zXr6giuGOlmHaji4 GdQXWJ7k8bUDu+n9rqPdeqUpnmqtL0MiLH2zYYCKuDjNDA9Hown7jYKLTbAtk1Ap3/xJag eAY2FKjzwHPtT9yq1+HdPMMdZmJoop+nuCnG/Y9rpCvuDQGs0PMZjPJUYYkXnBUXuJpDT+ wRi3BqTnMzDXIvSmYR+UPs1SY1Y/1iQR1NgJgVLPhwOD8N5IXkmaxlEJ5ukwuAkmhqGcZx c0tQCpbnQ9zUf9FvpHHpSv62/3oSKCJKBgf2KhMZdFT/6aUaOXOHCt9+TXBh9g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1611476021; 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=b6ARxzSACzyN+3uDousJyVDfsRj+7AoBf0/EqK7Wevo=; b=ZVApe2/BGMB8Z9yvEQPOFkfDD8fQeODI2LIeNozQvLfSfbiaCO6tUMqgGt/fYne++hBlen BavINN/sX6n4CcAw== To: Sven Schnelle Cc: Petr Mladek , Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , linux-kernel@vger.kernel.org Subject: Re: [PATCH] printk: fix buffer overflow potential for print_text() In-Reply-To: References: <20210114170412.4819-1-john.ogness@linutronix.de> <87v9bomtd0.fsf@jogness.linutronix.de> Date: Sun, 24 Jan 2021 09:19:40 +0106 Message-ID: <87k0s2n45n.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sven, Thanks for the outstanding analysis! On 2021-01-23, Sven Schnelle wrote: >> 1401 if (buf_size > 0) >> 1402 text[len] = 0; > > I don't think i have really understood how all the printk magic works, > but using r->text_buf[len] seems to be the correct place to put the > zero byte in that case? Yes, you are correct! @text is pointing to the beginning of the currently processed line, not the beginning of the buffer. I will submit a patch to fix our recent fix (unless you would like to do that). Thank you for all your help with this! John Ogness