Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4334773rwb; Tue, 8 Nov 2022 15:48:37 -0800 (PST) X-Google-Smtp-Source: AMsMyM51C6RkiQyW+W0jUnUSj/6wzVBftN2Hg0iMXvfKnCcAQvE+ohkBchYZY8/8mC3rWR8qh1Pi X-Received: by 2002:a63:1110:0:b0:46f:b040:f5a with SMTP id g16-20020a631110000000b0046fb0400f5amr43201799pgl.84.1667951316883; Tue, 08 Nov 2022 15:48:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667951316; cv=none; d=google.com; s=arc-20160816; b=af9ehquAQ4R3ptFQ3TTve5kJWjjQs59EtEaGcE5K+siZlN830rSgK6ifCHLYTx6yR4 Y2s34lhze9ovp989k5V7YFBq6c06sOMzqDr6xzrVB8O2DU/+0ppXVbF801ZizNEuG1kU uZKLLgf0PKF62nVeUy3gvkTw+rswzfaBsiNTd5lcDm6PFB4hUjSqT5lIOTKIbuCMQuU3 gnVxwxUK8dngnXxIyBJ581ul6dFWfj3xGkJC1z9vus28NadPq62tSAzuiHeuYrmOVwXC X94Wjf/aC6S0C+qYrUWgA9GpMjvDl20QMSyqsgbHd+pbmZyaBEMWh5bpN5izpLptV2J2 he6w== 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=mi+8/yG2AkmYuv7ZYdDMOOQ0yi94luJeVwqutgIMn6w=; b=I3aC7BzjgQjAU8MfobLSbVhvuXnKlqMvwcCG7MkaL5scEwa9ycWr5D+avNYQYwhaBk 2QzMqny03Z9/0E6wZ9zq4M/yTGbF8sgmld7PHfPAej7LT8VIck9MGw3CDrZhKfGeTWo+ 3z9ig2s6BJzxaxmEov5OpLmp1+P6hSulVRXGfn9qBeKHs+gDu3TUv2vww+WRaEtE8GNA UMJsPEBoB5Wj2+CeWfOyCquHIGdmXt+klRrWUelDpFikLVM4fI4qBjXdWhaI+Qz3M12X rjfNWRgvvrNXahJzZOTSkz4Bwst58k/VuSJXUrZG2dEaEtgpe2NWoB4+l0/bOh9WmQhs UxNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eQ7Cu07z; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l37-20020a635b65000000b0046f3dfb87fasi3113473pgm.191.2022.11.08.15.48.24; Tue, 08 Nov 2022 15:48:36 -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=@redhat.com header.s=mimecast20190719 header.b=eQ7Cu07z; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229792AbiKHX0w (ORCPT + 92 others); Tue, 8 Nov 2022 18:26:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbiKHX0v (ORCPT ); Tue, 8 Nov 2022 18:26:51 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FD00554D9 for ; Tue, 8 Nov 2022 15:25:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667949912; 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=mi+8/yG2AkmYuv7ZYdDMOOQ0yi94luJeVwqutgIMn6w=; b=eQ7Cu07zArXHDJExN9RBQuC2BvttQMP2LQPAwrfCCj3qrS9gLRdAB4e3DLcAoMXuBhDFCc m7KGI4AdZZ804AlDKOjF+Ds/eVQSbErvHIn+c1qybHVLnvgMPRKjFNafMwIEpjlY32R389 qfYMs/wWvGw+0iFu/idBPCRQWxJNRzc= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-647-nMF4z_RKNwacwH8JffDQXg-1; Tue, 08 Nov 2022 18:25:09 -0500 X-MC-Unique: nMF4z_RKNwacwH8JffDQXg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2F300380673C; Tue, 8 Nov 2022 23:25:09 +0000 (UTC) Received: from localhost (ovpn-12-86.pek2.redhat.com [10.72.12.86]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 767F4492B05; Tue, 8 Nov 2022 23:25:08 +0000 (UTC) Date: Wed, 9 Nov 2022 07:25:05 +0800 From: Baoquan He To: Stephen Brennan , Andrew Morton Cc: Vivek Goyal , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Dave Young Subject: Re: [PATCH] vmcoreinfo: Warn if we exceed vmcoreinfo data size Message-ID: References: <20221027205008.312534-1-stephen.s.brennan@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221027205008.312534-1-stephen.s.brennan@oracle.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 10/27/22 at 01:50pm, Stephen Brennan wrote: > Though vmcoreinfo is intended to be small, at just one page, useful > information is still added to it, so we risk running out of space. > Currently there is no runtime check to see whether the vmcoreinfo buffer > has been exhausted. Add a warning for this case. > > Currently, my static checking tool[1] indicates that a good upper bound > for vmcoreinfo size is currently 3415 bytes, but the best time to add > warnings is before the risk becomes too high. > > [1] https://github.com/brenns10/kernel_stuff/blob/master/vmcoreinfosize/vmcoreinfosize.py > > Signed-off-by: Stephen Brennan > --- > kernel/crash_core.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/kernel/crash_core.c b/kernel/crash_core.c > index a0eb4d5cf557..87ef6096823f 100644 > --- a/kernel/crash_core.c > +++ b/kernel/crash_core.c > @@ -383,6 +383,9 @@ void vmcoreinfo_append_str(const char *fmt, ...) > memcpy(&vmcoreinfo_data[vmcoreinfo_size], buf, r); > > vmcoreinfo_size += r; > + > + WARN_ONCE(vmcoreinfo_size == VMCOREINFO_BYTES, > + "vmcoreinfo data exceeds allocated size, truncating"); > } Yeah, sounds like a good idea. Thanks. Acked-by: Baoquan He