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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B7C2C004D4 for ; Wed, 18 Jan 2023 10:26:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229953AbjARK01 (ORCPT ); Wed, 18 Jan 2023 05:26:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229563AbjARK0F (ORCPT ); Wed, 18 Jan 2023 05:26:05 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF0EE5DC28; Wed, 18 Jan 2023 01:31:20 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 6C73E20C5D; Wed, 18 Jan 2023 09:31:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1674034279; h=from:from:reply-to: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=bVp7KTcQDbxHoHXUlHU1XAYm2vJ+8Qy42f6yOSykfsw=; b=n495Qf5SXOkdloH73gDVq4FvILM4H5GRWv25FvN0hgfoJWOj7Dk8oP1z3pHYZRuGI6zitG eilW4gukzty5h+F7kdWDBvvJ0x0YlpSaeLJTljal56TtFfA6SxNOQtIHGe6sz+JnhpxVmq 3HcQXJPVCUYlRi1LTHHAxSGiN2FnCZY= Received: from suse.cz (unknown [10.100.208.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id D346C2C141; Wed, 18 Jan 2023 09:31:18 +0000 (UTC) Date: Wed, 18 Jan 2023 10:31:16 +0100 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , coverity-bot , "Gustavo A . R . Silva" , linux-next@vger.kernel.org, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, coverity-bot Subject: Re: [PATCH] printk: Use scnprintf() to print the message about the dropped messages on a console Message-ID: References: <20230117161031.15499-1-pmladek@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230117161031.15499-1-pmladek@suse.com> Precedence: bulk List-ID: X-Mailing-List: linux-next@vger.kernel.org On Tue 2023-01-17 17:10:31, Petr Mladek wrote: > Use scnprintf() for printing the message about dropped messages on > a console. It returns the really written length of the message. > It prevents potential buffer overflow when the returned length is > later used to copy the buffer content. > > Note that the previous code was safe because the scratch buffer was > big enough and the message always fit in. But scnprintf() makes > it more safe, definitely. > > Reported-by: coverity-bot > Addresses-Coverity-ID: 1530570 ("Memory - corruptions") > Fixes: c4fcc617e148 ("printk: introduce console_prepend_dropped() for dropped messages") > Link: https://lore.kernel.org/r/202301131544.D9E804CCD@keescook > Signed-off-by: Petr Mladek JFYI, the patch has been comitted into printk/linux.git, branch rework/buffers-cleanup. Best Regards, Petr