Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2183952imu; Thu, 17 Jan 2019 09:43:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN6tbM/c7mldMqq6Cy0Kv7I3aElKTSJHcIoHkr6Z0e9yLCDRrbWYF5uothyO7QWdWnBoC58M X-Received: by 2002:a63:5c22:: with SMTP id q34mr14216322pgb.417.1547746991032; Thu, 17 Jan 2019 09:43:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547746991; cv=none; d=google.com; s=arc-20160816; b=nHMBValsluTLA3kw4QSNo0s1db7KE52t5igst1GGXr4Y8V4Z/mvJea8Y1fLJF97ajc 5am6B6trEvXbkQbeeaLIr7sXpjTV97ENI1Z6nb3J3uFmCjiwRgt/4jb4CtywD6lII4og SI2LvL2nZuTYmF81QuWksbJEbTrBgvmMYfJIF3u8WIixJD4PYO2GSbACwqiPUrSrtd5/ 0RPiG1hX0Oky1+C/+YI1fqbKk0AfG4jnUmFz0zSPNPWECY1SE1nVfdcZtwmCwBoZHoQl z8hq2sPfwo4SrEfHM1+Z4TRvRyPNSbjkOXKUa6hQYr3pBRnKa6DWPPymT+LS0U4pCKVs WaWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=9NH/nNdAELJO+XX2r9h3AuIOg98tGgx6St0RefpZQA4=; b=AkpzJ4VHk+Rk+2XkKEVCcWN7MuXOh58raSo131Fiv7qY/f+aRBfZKCTjJDG5bpoWEV A+10VH/4ok/A2voOqb6ka5MIQa4kW2QFhZfuKTTtunumRwNmx5WmvlGhLTPkJfjl/auj Bk1IHF65jpbRyXqwrvVwKm8bNOi3VJZiONIqW0Y7dp8C3bqu5m/AqXBLU6wMyjSz3fJL orM1hXg4X2hfw+IelLrbw0Tw8Hf8KYDNarqIsF4ppDH468HamWy0fREp4kNfr+7NKer3 E4wPL5YCQWq+fLkxAy97KO3Yu2NwIWrg0CR5cR/vn+ilZ5vpLF0lziWrCuFP9ZShk5Uw EL1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=T0Z4JLfn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z186si2137780pgd.90.2019.01.17.09.42.55; Thu, 17 Jan 2019 09:43:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=T0Z4JLfn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727213AbfAQRLi (ORCPT + 99 others); Thu, 17 Jan 2019 12:11:38 -0500 Received: from mail-vs1-f67.google.com ([209.85.217.67]:34732 "EHLO mail-vs1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725878AbfAQRLi (ORCPT ); Thu, 17 Jan 2019 12:11:38 -0500 Received: by mail-vs1-f67.google.com with SMTP id y27so6710672vsi.1 for ; Thu, 17 Jan 2019 09:11:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9NH/nNdAELJO+XX2r9h3AuIOg98tGgx6St0RefpZQA4=; b=T0Z4JLfnMp6XuQB31A8RKP7WphX7sY6WgvX+4tfIoDjyoCuLGyUfV8XhV8Zuh5jCCu Pf3umkvMa9TNjQ+I7YigjnavGhUcMYboLngOHaa70kHbPCdMQIzkEeiZg2B3MZ2+wM9u TIM/Pex5NBW1vlQ2ApRkW/34TwIJgqr5MMlxk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9NH/nNdAELJO+XX2r9h3AuIOg98tGgx6St0RefpZQA4=; b=pmDRsi5/J/4uxmCWKVe2LYgSRkLyC7/q8ZBaKrSAJ51Tf+23dHbg77T3k/8CHntXuu DsIJ9ckJwXfaNfYIUdqxbsloBz1a74d999WkGmo+5iwYLffwjwcKsM2Z+Dy2bmUslvDC iedc9E5yocouGEkP0YRA+rvZWIk/cO96OpJ4/V1jz2Ry/Al5TIDOwd4uCxgKi6/kkxfu 9U9WTamIgi6WNRily2w61F40+E8VL+avKg1NXCifUFc3L88Wo7U3suZ5AEQBogMzgRye bl0FjS3YEiqMc5K6UVwGJqTJz0nvGptlEXyssCb5emu0fBOh1xBQTcwnbNfRpOaMGeNx Q9Zw== X-Gm-Message-State: AJcUukfrfywssV0j0u17a+cAcEehtiAZ7OF8mS6c9Ht0RDZHMAS+XnHr ebPMtUkUidQ9Szq9sMvnXL6hQ9izb4Q= X-Received: by 2002:a67:d804:: with SMTP id e4mr6481018vsj.7.1547745096059; Thu, 17 Jan 2019 09:11:36 -0800 (PST) Received: from mail-vk1-f176.google.com (mail-vk1-f176.google.com. [209.85.221.176]) by smtp.gmail.com with ESMTPSA id n206sm57649943vkn.36.2019.01.17.09.11.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Jan 2019 09:11:35 -0800 (PST) Received: by mail-vk1-f176.google.com with SMTP id n126so2419680vke.12 for ; Thu, 17 Jan 2019 09:11:34 -0800 (PST) X-Received: by 2002:a1f:298e:: with SMTP id p136mr6005109vkp.40.1547745093881; Thu, 17 Jan 2019 09:11:33 -0800 (PST) MIME-Version: 1.0 References: <20190117062620.23908-1-saiprakash.ranjan@codeaurora.org> In-Reply-To: <20190117062620.23908-1-saiprakash.ranjan@codeaurora.org> From: Kees Cook Date: Thu, 17 Jan 2019 09:11:21 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] pstore/ram: Fix console ramoops to show the previous boot logs To: Sai Prakash Ranjan Cc: Joel Fernandes , Anton Vorontsov , Colin Cross , Tony Luck , Guenter Roeck , Rajendra Nayak , Vivek Gautam , Sibi Sankar , Stephen Boyd , Doug Anderson , linux-arm-kernel , LKML , linux-arm-msm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 16, 2019 at 10:27 PM Sai Prakash Ranjan wrote: > > commit b05c950698fe ("pstore/ram: Simplify ramoops_get_next_prz() > arguments") changed update assignment in getting next persistent > ram zone by adding a check for record type. But the check always > returns true since the record type is assigned 0. And this breaks > console ramoops by showing current console log instead of previous > log on warm reset and hard reset (actually hard reset should not > be showing any logs). > > Fix this by having persistent ram zone type check instead of record > type check. Tested this on SDM845 MTP and dragonboard 410c. > > Reproducing this issue is simple as below: > > 1. Trigger hard reset and mount pstore. Will see console-ramoops > record in the mounted location which is the current log. > > 2. Trigger warm reset and mount pstore. Will see the current > console-ramoops record instead of previous record. > > Fixes: b05c950698fe ("pstore/ram: Simplify ramoops_get_next_prz() arguments") > Signed-off-by: Sai Prakash Ranjan Whoops! Thanks for catching this! I've adjusted the patch slightly (no need for a local variable), and will send this to Linus. -Kees > > --- > > I guess commit msg can be improved. > --- > fs/pstore/ram.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c > index 96f7d32cd184..441a44215456 100644 > --- a/fs/pstore/ram.c > +++ b/fs/pstore/ram.c > @@ -128,7 +128,7 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], int id, > struct pstore_record *record) > { > struct persistent_ram_zone *prz; > - bool update = (record->type == PSTORE_TYPE_DMESG); > + bool update; > > /* Give up if we never existed or have hit the end. */ > if (!przs) > @@ -138,6 +138,8 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], int id, > if (!prz) > return NULL; > > + update = (prz->type == PSTORE_TYPE_DMESG); > + > /* Update old/shadowed buffer. */ > if (update) > persistent_ram_save_old(prz); > -- > QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member > of Code Aurora Forum, hosted by The Linux Foundation > -- Kees Cook