Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7662776pxb; Thu, 18 Feb 2021 16:58:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPIgoT4eTVO+uOk3i3gkskhFyIHFMyCc6bcn993ea0TAAYrXZf4maQqfrShHgtiUV0U+zO X-Received: by 2002:aa7:d817:: with SMTP id v23mr6429868edq.192.1613696293493; Thu, 18 Feb 2021 16:58:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613696293; cv=none; d=google.com; s=arc-20160816; b=wvITWVCUVOgk+gWfTKN2H2NRxseyf+J8RR0++ZUYQ+MiwWDzWUMVMKnqq7JMoSSrt2 wHVls+qqyY9CAo6C0ubQqSbIFDHL5Ir/lgQJnTJHI6XrOXD2kcx5ABg5dbr+h5DbTNjD pa1jJdqtnuCFOfoB2YfFZtEHBWcLlzutI0GcbWpJzSUSR+AkMsCrfCwmb1l8Fma/Qwk0 wyUr0mSEYm9xnWkUTTdigkZpxskGphLedLyPhDBcXQBMXwokUBPh5+DolAXCKFGRKqT3 3aajOyVMjTWmhfnWmkWPjpSbNxwr+ZFN35kRMzzRi4qbR0UYwUvmoKfye4IduLo+/M+l 1GKw== 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; bh=2RFqjHWDWrWTLpKVFa5U5PvI9t/CcGNz+2vMPISqBko=; b=fTswaQMXjv0r3S2G4gLmSTPwuYoNd1XaafT7Ph4cAYt3X/z1XJ/ilZLuz9GUHmkOI7 8BZjDLf+SxEru23ufPjVHRGrm0JHrIY91PyfQk6BfPT6GI4zs4JsjW2CA0+zQJ7qOg+8 yWItRHxXA7Tt0JytptozIlDTJ8rxmnMlGEbJwpqfSOhk7td+Eu6vbc0cmnqnwqJ4waGj 6QVnyiMvMOgu1FWPQDrBlQT+PKiwBZpO1AVqhvQewa69/gaeE0Gcf+Ywq49bojG56Xu3 TWon91sH6RK/DkDIGTllKWVUL43qLts/hlBTXBfk259c1SfCqx9LfABJyz09rh8ooQcv 2uMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lf5si2175341ejc.293.2021.02.18.16.57.50; Thu, 18 Feb 2021 16:58:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229763AbhBSAzF (ORCPT + 99 others); Thu, 18 Feb 2021 19:55:05 -0500 Received: from mx2.suse.de ([195.135.220.15]:60570 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbhBSAzE (ORCPT ); Thu, 18 Feb 2021 19:55:04 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 996CCABAE; Fri, 19 Feb 2021 00:54:23 +0000 (UTC) Date: Fri, 19 Feb 2021 01:54:23 +0100 From: Jiri Bohac To: Kees Cook Cc: Tony Luck , Anton Vorontsov , Colin Cross , Matteo Croce , linux-kernel@vger.kernel.org Subject: Re: pstore: fix compression Message-ID: <20210219005423.p2y5ob6637pp245n@dwarf.suse.cz> References: <20210218111547.johvp5klpv3xrpnn@dwarf.suse.cz> <161368019685.305632.7880211837303066992.b4-ty@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <161368019685.305632.7880211837303066992.b4-ty@chromium.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 18, 2021 at 12:30:03PM -0800, Kees Cook wrote: > Eek; thanks for the catch! thanks for applying the fix; BTW, with the compression broken, I was not getting any dmesg stored in ERST at all, not even uncompressed. After instrumenting the code with a lot of debug printks I found that writing erst_erange.size worth of data into the ERST fails and the maximum writeable size is 98 bytes smaler: Details: - erst_erange.size = 65536 - this results in erst_info.bufsize = 65336 - pstore_compress() returned -EINVAL (because of the just-fixed typo), zipped_len = -EINVAL. - pstore_dump calls copy_kmsg_to_buffer to only copy bufsize bytes from big_oops_buf to psinfo->buf; record.size = bufsize = 65336 psinfo->write(&record) then fails with -EINVAL; by more tracing inside the ERST code I found the -EINVAL was produced by __erst_write_to_storage() after apei_exec_ctx_get_output() returned val=ERST_STATUS_FAILED=3 and this got translated into -EINVAL by erst_errno(). Once the compression was fixed everything started working because the records are much smaller after the compression (~30kB). My next thought was to find the largest possible record that could be written successfully. I modified the ERST init code to decrease erst_info.bufsize by a value specified on the cmdline. The maximum writable record was 65238 bytes long (i.e. erst_erange.size - sizeof(struct cper_pstore_record) - 98). With this hack I got 65238 bytes of uncompressed dmesg stored to ERST. Any idea what might be causing this? As far as I can tell, there are no other records in the ERST (checked through the erst-dbg interface). Tested on a HPE ProLiant DL120 Gen10 server. Thanks! -- Jiri Bohac SUSE Labs, Prague, Czechia