Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp424704rwb; Sat, 14 Jan 2023 02:47:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXvGUQwgSYAfr90kIhUmNZhw7PXSUlu7C3YESnrH+uip4wh9Xn6p6nBPLU69kj+XU1DBmhmR X-Received: by 2002:a50:9b14:0:b0:482:e3b9:f46e with SMTP id o20-20020a509b14000000b00482e3b9f46emr2542401edi.39.1673693225477; Sat, 14 Jan 2023 02:47:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673693225; cv=none; d=google.com; s=arc-20160816; b=g68Bw+RMeoIgYpR8Se31HGiUrqFeggHx68uDuI4UP2g4nYN0dd9uVTUsOwq/VXb38e G8EComNOnev4x8zKCABP5EVQl6YyQeQ0a58UhvpJNCjMsMeZVkuf3qUAw7MKheQxFZ5T szLjE8PeYnBxryJZWEO27bILPQWDrXaTOSHyZYi5A6LPOdZPwpvvcCaT+ECUGbHmlKLX 4M16JofPTDC7UMCVgaLTZqJHZfQkfllsXztvNLKpxJi5o10Bbi3CC2inKZQDRTMrpImn qz9YnWpHNVwqXuP6sibHYABs1WWvuDyniiLunfd0nIzknjCt5hvU9LujN8gWkwRkZUGa VntQ== 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=z7++H4V6hNi27Aju7rRR2cyddaE4xHSSiZpHf+T0Adk=; b=YBwsNIpq0X+SEXZPVVeDBnPoXXijFarS3Y5LIhIfL+qxxx7bDpaLZKTx9Olgv9bdS5 SRMcRuntvgW66K/tBg9AIGdx6k2cgTNPNb5E6THBwuq2SlwlMcy8SixTLIezpXxEeKMn BQ3EE2/gFEOOM1WmaRDCxXjjiTwy0Kaoyvzd/ulzupv+XHBAqlTuFsNQlgsp6c/vcUhL LQ+VauNNPsulnpumxilzWdGSRuDKZPdm5uvL7pCeOYCElhyyhJRr6uqqS2X46bm6uDIL Wov4LZJQi6uO+aUNKZoMC5HpKBJyhwyOiQHtIdtVszb2juymTk278XNe1EPzGeFTdHZq HDLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mV7xtcEZ; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i9-20020a05640242c900b0048ee2e45defsi30234749edc.288.2023.01.14.02.46.52; Sat, 14 Jan 2023 02:47:05 -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=@chromium.org header.s=google header.b=mV7xtcEZ; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229992AbjANKOj (ORCPT + 51 others); Sat, 14 Jan 2023 05:14:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230009AbjANKOh (ORCPT ); Sat, 14 Jan 2023 05:14:37 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3697C76B9 for ; Sat, 14 Jan 2023 02:14:36 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id d3so25797931plr.10 for ; Sat, 14 Jan 2023 02:14:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=z7++H4V6hNi27Aju7rRR2cyddaE4xHSSiZpHf+T0Adk=; b=mV7xtcEZZKXbUW9dgq8/GV7se/rEBkykyqaKRNHFY4Fmq7YnxLKKgkT3XlWlkOkSEi DdPH/RI2Co1aDZiw/v8Q1E7d0wNYORp4D4T3ZgOBbbh6EmIeh2M2H5W3hD0VbFY0KXMj NS+QI/p/J33e46oq+trhdZYGCLOtLmR+elU50= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=z7++H4V6hNi27Aju7rRR2cyddaE4xHSSiZpHf+T0Adk=; b=wfav/t8IUC/NZ7Fh/0SMgz0UrvGkkKvbVRMlzgpQy4OGLgTqQt6r9LFmt7lCeytCpQ Ot+7OJm5u7q16V7+2Z0AgXyjLRD1Ci0QIsXp8BXLyf/cksSwTjKJyZjrCkPVFp3L01tn zLwbadOhiKOrBWKVLEtmKtttt+FsebY4HX7qEqkN+1FXnUgki+ey8Ni6jBXzchEZ8MJ1 wqhf0s2TLDP+yx7fY1C7svDleizk0B3fLsmz9F6PRsntfUAMrK4CtzD69vIbFxTj6Evk fTYPV/oedVgPBZL2C3zwrBATxFY1BXth16ChTWjo7yKrWyiF0uw6sNtoRRSt2g9eT3Ib cUVQ== X-Gm-Message-State: AFqh2kr2Cm/FBMOV/qSXSrnID8VtVxOT3aXbV2ct3Y8RpXnEprR8lxuW O5WhEjGHzrpQY9Mg2rQ57RIrpA== X-Received: by 2002:a17:902:a5c1:b0:191:1729:d7e7 with SMTP id t1-20020a170902a5c100b001911729d7e7mr87541846plq.67.1673691275745; Sat, 14 Jan 2023 02:14:35 -0800 (PST) Received: from google.com (KD124209188001.ppp-bb.dion.ne.jp. [124.209.188.1]) by smtp.gmail.com with ESMTPSA id n13-20020a170903110d00b001925ec4664esm15604019plh.172.2023.01.14.02.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Jan 2023 02:14:35 -0800 (PST) Date: Sat, 14 Jan 2023 19:14:29 +0900 From: Sergey Senozhatsky To: coverity-bot Cc: John Ogness , Steven Rostedt , Sergey Senozhatsky , Petr Mladek , 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 Message-ID: References: <202301131544.D9E804CCD@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202301131544.D9E804CCD@keescook> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 (23/01/13 15:46), coverity-bot wrote: > *** CID 1530570: Memory - corruptions (OVERRUN) > kernel/printk/printk.c:2738 in console_prepend_dropped() > 2732 /* Truncate the message, but keep it terminated. */ > 2733 pmsg->outbuf_len = outbuf_sz - (len + 1); > 2734 outbuf[pmsg->outbuf_len] = 0; > 2735 } > 2736 > 2737 memmove(outbuf + len, outbuf, pmsg->outbuf_len + 1); > vvv CID 1530570: Memory - corruptions (OVERRUN) > vvv Overrunning buffer pointed to by "scratchbuf" of 1024 bytes by passing it to a function which accesses it at byte offset 1998 using argument "len" (which evaluates to 1999). [Note: The source code implementation of the function has been overridden by a builtin model.] > 2738 memcpy(outbuf, scratchbuf, len); > 2739 pmsg->outbuf_len += len; > 2740 } > 2741 #else > 2742 #define console_prepend_dropped(pmsg, dropped) > 2743 #endif /* CONFIG_PRINTK */ [..] > Human notes from Kees: > > I'm not sure how it got 1998, but I do see that snprintf() should > probably be scnprintf(), otherwise "len" might be a lie (i.e. it'll hold > what it WANTED to write, rather than what it actually wrote). Cannot imagine how "** %lu printk messages dropped **\n" can expand into 1998 bytes. Does coverity have a "verbose" mode?