Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp544367imd; Fri, 26 Oct 2018 12:41:27 -0700 (PDT) X-Google-Smtp-Source: AJdET5dECn+VTe6GM/KF78UVWfWMlj2Q3a5YZdxY+hgxOA6F3VEZN6C1liJa7VUFoTZ0d5jRPTTz X-Received: by 2002:a63:1302:: with SMTP id i2-v6mr4850064pgl.380.1540582887654; Fri, 26 Oct 2018 12:41:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540582887; cv=none; d=google.com; s=arc-20160816; b=ZccevNiGTqwmL0Vz75ql83cVGbxVYGXRBAA9L5R1ISTq1H+2STaLjICIiA7/MF9KqJ 5bgQhbuzRyNHY0Z0WJYKTDhfIdE34yHkoE6cODGY1Carlmxj2/HcWqjc1gmyaDabgw/Y WU4risZrdvRShOZ64umHq+Eth4MCbQod4WLFmZRznPM6Y4b2KtwHEvsowaLSZncwQJgY 3CsZpSaUuD9UxcENBrwQ2aaeULlzRYPfFauY/tsecIn32mzo/MpU9VHCrV3bcmxadF8L Z5N7ZbsZXaEGWsViiZrs8c5BGnYljbdMRlQuIurbd4cOssxkYrmvgjN0+T4BBj9B5vj3 WnCQ== 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 :references:in-reply-to:mime-version:dkim-signature; bh=mXdfZEjoJu02sLfhwsZo7dmcaw5jh/4mpH+k4B3M32M=; b=k0K6alFvnZsl7gbedKjdO8PKSDvSxWAz4pePqmDltOZugMSbJT78I0mOtFRP0I+l/v 9sVbvJ2PRscoSP3oDcNk4lcK1mpmIFyMhEpvnuYYH9lmPcFPubplF4UN6FK+1zJF1L3K VoY2Q6uWD16qQP0WWHgwZF+/b12i8+iKVgY+U2xgR8zP+eSFFvES/hfLjNIwgMRAJpDO JLosMjwiUmmvEHOiNrw1H2Womx5AeWNiJ7gHLho9tPVdI3Is5gdLkENIlJruBTZuveSs Jdp/4fb1JGSd1npQcfGnZtyGP4jkqcLzO7+tux9hlG+0HFxjVQcv0RBqzNNF2pEgRr2W lfCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=irAVEsgZ; 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 w20-v6si11932925pgh.571.2018.10.26.12.41.11; Fri, 26 Oct 2018 12:41:27 -0700 (PDT) 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=irAVEsgZ; 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 S1727844AbeJ0ERg (ORCPT + 99 others); Sat, 27 Oct 2018 00:17:36 -0400 Received: from mail-yw1-f65.google.com ([209.85.161.65]:38407 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726565AbeJ0ERg (ORCPT ); Sat, 27 Oct 2018 00:17:36 -0400 Received: by mail-yw1-f65.google.com with SMTP id d126-v6so924861ywa.5 for ; Fri, 26 Oct 2018 12:39:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=mXdfZEjoJu02sLfhwsZo7dmcaw5jh/4mpH+k4B3M32M=; b=irAVEsgZHcyCQ+8spbLqPx4vUt3bc0RxxuUDUah3myPMqRaDZrGoinxkSwpGDR8+c4 cVfsLJ9pCMmx4E7nmSAHplDP9+k5xqVGJsiAg0CU1bPTU+Ywmo1l+Iduv6mAtCrQoZlI KPWkOSVcFNkzEllcI0VaoupLSBYGZB2PxpkeQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=mXdfZEjoJu02sLfhwsZo7dmcaw5jh/4mpH+k4B3M32M=; b=rAwid65GzS5WuouQiv7xshqA5CjjARLOqSP6elL8D6MqHc1P4CbwEChigZDUAha1ZY MI5kklRvShWPUkX49n+tpFEaPG1G5hLGadfhfhdraV2E+DWWbq89MZaBBP/QU7XoPGr6 Ag14P6PYB084ou5AKkaneloM4CcipS8L2bGfvqNkwH9WndnDcbTJ/IyvZHUfXPkFA3Mh KZnXUY0/s6rN3XABb5HpUeKHPhtIvig8q5LTuMdqbskkZ+ZFRhlc9AUNoMKan5LDTJ48 ItSzOacwyUBHJ3/ZEPctJ8aSKAvieg86AjCwrZcdEhfMkOjXl8M3BlkLLvgwMdRtvJ41 sdwQ== X-Gm-Message-State: AGRZ1gK0HlcPfpexAQ3RShj2qUaDGMI+k497Tn7xKQ81IhdLZBtXHQgL zVDmSN42hSHG1HxSTnkuPqeYZ4Dc+10KgA== X-Received: by 2002:a81:2bc6:: with SMTP id r189-v6mr5015106ywr.118.1540582756544; Fri, 26 Oct 2018 12:39:16 -0700 (PDT) Received: from mail-yw1-f48.google.com (mail-yw1-f48.google.com. [209.85.161.48]) by smtp.gmail.com with ESMTPSA id v19-v6sm4595585ywv.19.2018.10.26.12.39.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Oct 2018 12:39:15 -0700 (PDT) Received: by mail-yw1-f48.google.com with SMTP id x185-v6so932894ywa.0 for ; Fri, 26 Oct 2018 12:39:14 -0700 (PDT) X-Received: by 2002:a0d:cd84:: with SMTP id p126-v6mr5059785ywd.288.1540582754351; Fri, 26 Oct 2018 12:39:14 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:3990:0:0:0:0:0 with HTTP; Fri, 26 Oct 2018 12:39:13 -0700 (PDT) In-Reply-To: <20181026180042.52199-5-joel@joelfernandes.org> References: <20181026180042.52199-1-joel@joelfernandes.org> <20181026180042.52199-5-joel@joelfernandes.org> From: Kees Cook Date: Fri, 26 Oct 2018 20:39:13 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC 5/6] pstore: donot treat empty buffers as valid To: "Joel Fernandes (Google)" Cc: LKML , kernel-team@android.com, Anton Vorontsov , Colin Cross , Tony Luck 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 Fri, Oct 26, 2018 at 7:00 PM, Joel Fernandes (Google) wrote: > pstore currently calls persistent_ram_save_old even if a buffer is > empty. While this appears to work, it is simply not the right thing to > do and could lead to bugs so lets avoid that. It also prevent misleading > prints in the logs which claim the buffer is valid. I need to be better convinced that a present zero length record is the same as a non-present record. This seems true, but there is potentially still metadata available from a backend. What were the misleading prints in logs? -Kees > > Signed-off-by: Joel Fernandes (Google) > --- > fs/pstore/ram_core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c > index 0792595ebcfb..1299aa3ea734 100644 > --- a/fs/pstore/ram_core.c > +++ b/fs/pstore/ram_core.c > @@ -495,7 +495,7 @@ static int persistent_ram_post_init(struct persistent_ram_zone *prz, u32 sig, > > sig ^= PERSISTENT_RAM_SIG; > > - if (prz->buffer->sig == sig) { > + if (prz->buffer->sig == sig && buffer_size(prz)) { > if (buffer_size(prz) > prz->buffer_size || > buffer_start(prz) > buffer_size(prz)) > pr_info("found existing invalid buffer, size %zu, start %zu\n", > -- > 2.19.1.568.g152ad8e336-goog > -- Kees Cook