Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp6217032rwb; Wed, 18 Jan 2023 02:37:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXsb55Ujs8gbF5IGD9ICv5UozgXyScViADx8MrXQ7Ctds87DncQP4JRPkITEMml6SzbERSmF X-Received: by 2002:a17:906:e247:b0:84d:3928:66b6 with SMTP id gq7-20020a170906e24700b0084d392866b6mr6260553ejb.40.1674038255922; Wed, 18 Jan 2023 02:37:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674038255; cv=none; d=google.com; s=arc-20160816; b=l9vFYKlz6jv6YPeVAKYk6iQr4bJ82Y/DTxxss+PgWsagLMRD/12jbbZQrHgPvRYy4y BA6s3FdxvV8zDtZRUIHvwVoWv3DeWZImNpN1SgwMeaM7hrZ5/gjtWgd+n9vnfBO3qzAt My0RPlpSmM+LSeawvncHrHKhkTDR++e4xpjzCUjDNNMSkQ9fbywm5bSs7MXo+NAatJLk OhUKgFO+B7L3WMV3JhFDWv4a5tz0NVq8D3LiGNA+KrETcMaKh3Ru4cx4V9KGh5ItvXcl x4n8dXFruQv6dv4WbjhFdvBCkLX470xcmOIi8mq0y866cQzKYnk/0DZfY62vNHtdzxQw /rmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=bVp7KTcQDbxHoHXUlHU1XAYm2vJ+8Qy42f6yOSykfsw=; b=MFkuDilb59HzHpTAa9wbYX3dNHGu5Ozthc9QwOzhZrItwYL+r6+jVe+zrwtVX+jJVo yVywDPmtfj57G1+4d/CKFo9DpKsMeOW6wEjL+2pcQJmL6o9iKrpgj020PPrT3/wQNohU pYjSBiGJKirJ+qWNusYfbtfaKtRwIvMNoo84POP8Ubaj0NBVnOuxdLU2hRG3/+NobYjf 5GV8t2u3VVDbvlO0I+CbzYR7SzOZzjD4dNuqYs4ptPgqPGvwoDgvjcwY/+WbNMFQ1aiM tc+/KyXY/OKQo8NitXeSww8hGIOx9iknNtYJIc5ZaDtMDRza7V/nNwxVbBNsIYP+pgmg dtsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=n495Qf5S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id vi5-20020a170907d40500b0086fcc2f95c7si9390995ejc.289.2023.01.18.02.37.25; Wed, 18 Jan 2023 02:37:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=n495Qf5S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229650AbjARK0j (ORCPT + 45 others); Wed, 18 Jan 2023 05:26:39 -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> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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