Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2251162pxb; Sun, 24 Jan 2021 00:16:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJyi6CoTjNE+zSDBaU+azWDQy3FHEsO3LLHefs1M3tURVD9B4IWnZSVx5vVsMfP/CRc5sKit X-Received: by 2002:a17:906:f755:: with SMTP id jp21mr288564ejb.22.1611476173544; Sun, 24 Jan 2021 00:16:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611476173; cv=none; d=google.com; s=arc-20160816; b=NWap3hs/Cacx7XmccZe81EtRhTd/jFbEk6lBlAjOv2gR5bqr1QWOZDWhCDqz+n2thD 756sUCiNr4K341ctg+JDlDxZXxwYJUMPJDclP5afU3xDFaSSDOmYwVgrPtohJ4fUZ5F1 A+FxRvCP4FnwWMNclagv/fkME7KJcNo7X/gnO+VIuFbJiX/9ZismO24oftYjf/EQgABm LuyXBMy3w2pq8rS2eWBTbOnVJ1OcL43QwF6vMgT8owO1vCxu20xBZPXlIVHQ2qCZUM5B ciHNu/BKDil7eCr/gECGFEYss34dqbQljec7GqGbWrc7MQyIRANXNPoAFkDYkwt2bP2D Q/Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=b6ARxzSACzyN+3uDousJyVDfsRj+7AoBf0/EqK7Wevo=; b=tEdBZN+i9NMxaWaIViuarOtsBZbz1O7mLEvPwpm7kciCCuPlqm7UB1NlPSftGYApde TfzIjTLxyRnP7n3f6xsmL6II5PelL/xFURPFEbgHJ5cc4D1/AG0thAwB+hE2cheyvVkb hdxyg9AvY6vjBg6PK6wRmyvJiSphxONqSede55XiFxDMO/89JeOkVQFcfm4Xk8PZPLEy uvsOBFSEuCaZ8EyZSjpU8LFfe9nMAPvfBNxc5cEKP8vpw5f0JmcxKWQaK9hWquBQLWSG jtVfSMio9MYIPHKLOBsdjoacC+NrokcexFIAye4gk8kDJLc0h4rA+kyB1tuzpAOTUact 8vwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ju2C0Bpu; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="ZVApe2/B"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i5si5698814edy.526.2021.01.24.00.15.50; Sun, 24 Jan 2021 00:16:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ju2C0Bpu; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="ZVApe2/B"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726038AbhAXIOl (ORCPT + 99 others); Sun, 24 Jan 2021 03:14:41 -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