Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp4401386rwb; Mon, 16 Jan 2023 23:47:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXvVl/Kdjeq+lAdFe5TyxD656nz1CQ/nRQczYRPYNW7zVvZBcHNeAqPRYTRU4H+gRSzAXKaF X-Received: by 2002:a05:6a00:2a04:b0:575:fd73:fc94 with SMTP id ce4-20020a056a002a0400b00575fd73fc94mr3156267pfb.23.1673941648836; Mon, 16 Jan 2023 23:47:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673941648; cv=none; d=google.com; s=arc-20160816; b=FEJpVu62/wbAlSLbdQsTB/fr0BVPSykAXqHsF6DFZjFRudDV7lTRv9qxeAsb9Gr74A FOi2wsPU+4q0v+XK/rLkIxdXoygRED5FobePUPcVX5oUDswdr17Te20VDq9mJz0sQ6pi n3rWhI7LAIm6+Qa6ZvRSN05jZh2AkoZ0x9CQ4A9+KAUj7jnGkUDR8tTZbN5ghL5sadd0 3GYudTgpckv8qzxX2bHFFrDGUCETJwPVgdpd+QHnr9ui9LMc1g0T+9r2Sw/wF843B/t5 H7ovuheJsDducZWGIxM8zlH7Mi3wny0IRPzftNQ8dzjjfoAQYLFiO9zSUPTWbPFdu12Q ZxkQ== 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=srv2GPQhiE1Dhl1/auwiFRncHX4gfzvbGImsSJ79J+Q=; b=XlQPOD5d4FbcwbuxOVfS9NB1FvOtIoqGMU7lWJL5Mim9kbmQAMvd1h10ukfFn5QnHE 5SUlKCTHgY8AZfGgwZ4BNUY14pX3wH3NVbIN4duOTJrsNRrvpCmVZfuZGU3+RTkt6BOo DSyuugF1JpBphrLWY9ki5mSVw8m6TBuBxe9JkpTDDt3MWPm837ZKPLWlZ9PeQsNPxr17 BjsaxxmODF0lPip9PD6V1flw0Bc0Ch772zYHW8B1f6aeX66AtG6fa3YuYxp+ibOjHgIX qKBhdhcnKAg8L5rOPkFE03JN9b5hE6BymSHR4rCPQvLwV4RSb0BONo5rbN42Jobw409J FajQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=N5FXQDrJ; dkim=neutral (no key) header.i=@linutronix.de; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s6-20020a056a0008c600b00576dee77c98si34535272pfu.299.2023.01.16.23.47.23; Mon, 16 Jan 2023 23:47:28 -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=@linutronix.de header.s=2020 header.b=N5FXQDrJ; dkim=neutral (no key) header.i=@linutronix.de; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235772AbjAQHLq (ORCPT + 49 others); Tue, 17 Jan 2023 02:11:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235457AbjAQHLm (ORCPT ); Tue, 17 Jan 2023 02:11:42 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2545722A34; Mon, 16 Jan 2023 23:11:41 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1673939498; 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=srv2GPQhiE1Dhl1/auwiFRncHX4gfzvbGImsSJ79J+Q=; b=N5FXQDrJmNvq9K5ggT5Lt9nzMbnDCT/VdVzSOZIbLCYaYb+gYa9VaqMpUw3YzqV7TzgnHA r8KWDPwEoG7ily3qvyBoDmAadyA2ydG5pMy6hmnEDr/I6GxJ/WPyO87YVGNcaIfLDImxL/ JL4blMYCNFLlqramv/HNX0+z8a43sB6GL+VUW741X0z3g0Vivj1e4/XCZqZJ7UmfqcFrrI Krpt64EXe0nIUotYaK943tghT2Lt3RmJK2rhyaF5D3+xk8JXS/qAeR6RhY40oRtNycMfga hmIISa9FYYViIah4oQSvydDaDpxF3ZMBJdyWDNXneI2TUK8xpKgW9xYl3S2btw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1673939498; 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=srv2GPQhiE1Dhl1/auwiFRncHX4gfzvbGImsSJ79J+Q=; b=7V/AMKwUnWmITUVAEK1EgSV2EPk4/wzTvqngjnqZt1nh5KIBBtk0NeplGwuOmIcIdvPLov Ubbb1qq5CThovzBg== To: Sergey Senozhatsky , Petr Mladek Cc: Sergey Senozhatsky , coverity-bot , Steven Rostedt , linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-next@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: Coverity: console_prepend_dropped(): Memory - corruptions In-Reply-To: References: <202301131544.D9E804CCD@keescook> Date: Tue, 17 Jan 2023 08:16:48 +0106 Message-ID: <877cxl3abr.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, 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 2023-01-17, Sergey Senozhatsky wrote: > On (23/01/16 17:35), Petr Mladek wrote: >> len = snprintf(scratchbuf, scratchbuf_sz, >> "** %lu printk messages dropped **\n", dropped); > > Wouldn't > > if (WARN_ON_ONCE(len + PRINTK_PREFIX_MAX >= outbuf_sz)) > return; > > prevent us from doing something harmful? Sure. But @0len is supposed to contain the number of bytes in @scratchbuf, which theoretically it does not. snprintf() is the wrong function to use here, even if there is not real danger in this situation. John Ogness