Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp308754ybk; Sat, 9 May 2020 03:34:45 -0700 (PDT) X-Google-Smtp-Source: APiQypJG8r7iIoQTbp1vrj/sCkAOu9kuPdkJv45E+1nxhr1tFEnCrEiwxvfFNbgBEcoPOrcmhGOV X-Received: by 2002:a17:906:cb98:: with SMTP id mf24mr5655977ejb.146.1589020485287; Sat, 09 May 2020 03:34:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589020485; cv=none; d=google.com; s=arc-20160816; b=PtZ16ccgU/D+G1m19YA3exOOOz67nSobb//vfInW9X6PgbGN/aENCA7/GWVMdfPGD8 bRcfNytiTjiP8vcStREzOfoN8stawm69r+c1zw8h9rj0iP57TyskUoLzr+tdgMox2zLI 5U03xMzAQvfOlLnvxD4VaHRsVBYZ2QbFDiUyIttnvgjw0goDi9br4IrQBLeF2I4C48IL V4G/HqjbZ3a7uhOh3z6j9NPMJdxYhTOCyL+KmYT1OwN2Y4DLzzHFKyGLyR4XPk+C00SO A46IkeH58+iHLG1CHpW+sTef7ArwFlZ1Ky+WwILTk4BIpTvtxHWQPTNQMpOiz2QRVaLG hdsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=HLQ3VOSAnmbQWx2hjguJMbDRDqNPzdImsPI9S4gwPyQ=; b=1DVDG5vuIKmP1/6xeIQYOF/CiSDa5aoITxQ17uo6rqGTwRQ5ZFvsVTW6DqKCZGFzzg h0HKKuJZppdHRCDOzk8MymBNEsAdV6HKgWPEEsC0yT8f/VVBshBcuLOVLS3WgTR0TxM/ DvYoWm9hh0DhfF1HEDtCb5JvdJbDDfMasyiAfP3PFKtd1C2WgSRrj/S8fTEOAbcTXieb UlpRnragzE5IQF4+iNZ0oEZTLtb+3mUmgeABzOEbARkgqFM+98MiKxEFSxrMbSIcaafl NQgogHEWoh/Sbu8cH5t2sTHbYXEUV35JszY9PHyo+0B38v4FQmusIu3/KNVkPRGPHuex ml7w== 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 f12si2542650edq.119.2020.05.09.03.34.21; Sat, 09 May 2020 03:34:45 -0700 (PDT) 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 S1727945AbgEIKc2 (ORCPT + 99 others); Sat, 9 May 2020 06:32:28 -0400 Received: from smtp2207-205.mail.aliyun.com ([121.197.207.205]:33256 "EHLO smtp2207-205.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726877AbgEIKc1 (ORCPT ); Sat, 9 May 2020 06:32:27 -0400 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.07436712|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.0310074-0.00171468-0.967278;FP=0|0|0|0|0|-1|-1|-1;HT=e01a16367;MF=liaoweixiong@allwinnertech.com;NM=1;PH=DS;RN=10;RT=10;SR=0;TI=SMTPD_---.HVnmYjV_1589020342; Received: from 172.16.10.102(mailfrom:liaoweixiong@allwinnertech.com fp:SMTPD_---.HVnmYjV_1589020342) by smtp.aliyun-inc.com(10.147.41.143); Sat, 09 May 2020 18:32:22 +0800 Subject: Re: [PATCH v4 00/12] pstore: mtd: support crash log to block and mtd device To: Kees Cook Cc: Anton Vorontsov , Colin Cross , Tony Luck , Petr Mladek , Sergey Senozhatsky , Steven Rostedt , linux-doc@vger.kernel.org, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org References: <20200508064004.57898-1-keescook@chromium.org> <202005080020.41C33738@keescook> From: WeiXiong Liao Message-ID: Date: Sat, 9 May 2020 18:32:28 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <202005080020.41C33738@keescook> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hi Kees Cook, On 2020/5/8 PM 3:27, Kees Cook wrote: > On Thu, May 07, 2020 at 11:39:52PM -0700, Kees Cook wrote: >> So far, I've identified the following stuff left to do: >> [...] >> - implement ramoops-like probe feature for pstore/blk > > With the following hack, I'm able to start testing the series: > > diff --git a/fs/pstore/blk.c b/fs/pstore/blk.c > index a736555e1ed3..7145da079267 100644 > --- a/fs/pstore/blk.c > +++ b/fs/pstore/blk.c > @@ -373,12 +373,14 @@ int psblk_register_blkdev(unsigned int major, unsigned int flags, > if (IS_ERR(binfo)) > return PTR_ERR(binfo); > > +#if 0 > /* only allow driver matching the @blkdev */ > if (!binfo->devt || MAJOR(binfo->devt) != major) { > pr_debug("invalid major %u (expect %u)\n", > major, MAJOR(binfo->devt)); > return -ENODEV; > } > +#endif > > /* hold bdev exclusively */ > bdev = psblk_get_bdev(holder); > @@ -423,7 +425,7 @@ void psblk_unregister_blkdev(unsigned int major) > struct psblk_device dev = {.read = psblk_generic_blk_read}; > void *holder = blkdev; > > - if (psblk_bdev && MAJOR(psblk_bdev->bd_dev) == major) { > + if (psblk_bdev/* && MAJOR(psblk_bdev->bd_dev) == major*/) { > psblk_unregister_device(&dev); > psblk_put_bdev(psblk_bdev, holder); > blkdev_panic_write = NULL; > @@ -476,6 +478,24 @@ int pstore_blk_usr_info(struct pstore_blk_info *info) > } > EXPORT_SYMBOL_GPL(pstore_blk_usr_info); > > +static int __init pstore_blk_init(void) > +{ > + int ret = 0; > + > + if (blkdev[0]) > + ret = psblk_register_blkdev(0, 0, NULL); > + > + return ret; > +} > +postcore_initcall(pstore_blk_init); > + > +static void __exit pstore_blk_exit(void) > +{ > + psblk_unregister_blkdev(0); > +} > +module_exit(pstore_blk_exit); > + > + > MODULE_LICENSE("GPL"); > MODULE_AUTHOR("WeiXiong Liao "); > MODULE_DESCRIPTION("pstore backend for block devices"); > > > Then I can get things up and running with: > > # insmod pstore.ko compress=off > # insmod pstore_zone.ko > # truncate pstore-blk.raw --size 100M > # losetup -f --show pstore-blk.raw > /dev/loop0 > # insmod pstore_blk.ko blkdev=/dev/loop0 kmsg_size=16 console_size=64 > > So far, I've hit a few bugs. The most obvious is that "rmmod" causes a > fault, so I think locking and other things need to be fixed up further. > After that, it looked like all the compressed files were failing to > decompress, which implies some kind of buffer offset problem. When I > loaded with pstore.compress=off I got readable logs, but there is a span > of garbage between the header and the body in > /sys/fs/pstore/dmesg-pstore-zone-1 etc. > Both of the above two bugs have been fix on series v6. The following diff is to fix "rmmod" bug. @@ -1273,8 +1273,8 @@ static void psz_free_zones(struct pstore_zone ***pszones, unsigned int *cnt) return; while (*cnt > 0) { - psz_free_zone(&zones[*cnt]); (*cnt)--; + psz_free_zone(&zones[*cnt]); } kfree(zones); *pszones = NULL; > Cool so far! It just needs a bit more testing a polish. :) > -- WeiXiong Liao