Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6115128imm; Mon, 23 Jul 2018 11:41:19 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcFVmMU5VQM2mDb/qp492FU6GL1csBjb7ID+OGj0DOBZIsxG8/tw5hO6+7nEXP6qUyXLNl/ X-Received: by 2002:a63:a44a:: with SMTP id c10-v6mr13120862pgp.198.1532371279477; Mon, 23 Jul 2018 11:41:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532371279; cv=none; d=google.com; s=arc-20160816; b=JsYNszTBDh1gZ7Gzzh9LAtFzrU6pC+/U3ISp0JHSd8x+27e08Db+rNzcjBxFI9kUb0 kNkDJIuErZjM4OeLtzTC98seBslr4FnQ9V+RrKJ5WjZuUcS198RCE66Qdyql4T9CC2Dr Blj22Y/31gNO1RSoaMKB/i1GNzq9KJTJ2hBA1LFY1BzrLeUqMQPlf64PO7nQAKMfbLAP 4TMdjXmjsmAwYWZAi2kRJioAn1yzEUblUwsVcoUB0QVY0DU+kZT34LOipp9ldqLFQp8H ETXyCKhUeOS2EQytB5isf1uiHW37g18/oAmRpbHSDf3ZJwEdvq5i/GfprNCSRZFX9nMw eS/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=03YB4mgAcHqi5NsutqHB2E5ECI+CGD2sMgBRDPTSf3Q=; b=PJcsBt0vXkIBySD/DRnGYaXY9vAZEtqVq5UnmUliLyuBGm+/UvV7SVkoeT3D9gjmHw VaNm8BEy3T5FvDsvPkjKku8x/OY+FMNOz+IjyRw2pOhx5A1LhYLPhSvCRh6fZX/ox63l Ov2UoS0GDbcj3lExo4BPQ7YvAi9aMY91J70H1bmwO20fD0zAupnaUK9ENv5GLv+kVvLy qIpeFINg9RuFiQx32uQ33Qeplnquijd/sTP1ldziWmS4pXWTOyV84VVl11KFO+Dn387x LStDsE7XbncHOn1kRBeM48dU8t8o40Gf5/N7jjgwSCVYt96A9quAuqOobzJJ2ETm3Irr KoxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mSwePgeQ; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 65-v6si9028824pld.451.2018.07.23.11.41.04; Mon, 23 Jul 2018 11:41:19 -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=@gmail.com header.s=20161025 header.b=mSwePgeQ; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388184AbeGWTmC (ORCPT + 99 others); Mon, 23 Jul 2018 15:42:02 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:36955 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387982AbeGWTmC (ORCPT ); Mon, 23 Jul 2018 15:42:02 -0400 Received: by mail-pg1-f194.google.com with SMTP id n7-v6so991784pgq.4 for ; Mon, 23 Jul 2018 11:39:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=03YB4mgAcHqi5NsutqHB2E5ECI+CGD2sMgBRDPTSf3Q=; b=mSwePgeQ1ZCXNt526GE6efkmIizktdEc6TI2poSmRcukCny/WnJU0ZHgi0UKruGkej BdCQET8k9kKb7Ci0dYZi1icDbfmzyZ3ten3SKD5S/5H8d5rFxaBtw5+WisXWOz/mfx9p M1hc0U3rw5P7hFIijC3G2yqyk/nnHaEc9CS3iJqHVxeR8SdpuY6o5TXibVqEjceBdC2t VsrOsCUr5oiZLZcNRmwxzuQaP/lEYq4EFcXwmL5lVUu/bqW1/VvGZ4WBj34x9RHzIj5u Cb92Y4ONWX6GttrcONqEur+ecKA4xt4R8SZ7I+OK0vHfH57k/XMfA4KCPqSquWpEzsC7 7KFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=03YB4mgAcHqi5NsutqHB2E5ECI+CGD2sMgBRDPTSf3Q=; b=CB6YUPFpSNBcQ7Y34ROBuHiZ1/PdwEbNTNmOGlhsLQLBx2DcVdYJGLqzlsAB/6GSZu +17fAu89LrMxgSRddLLw+cw1NamK466rBUNHSnAypSlGAfEqwLNuCbEESOiUujGWdZrp t9DuZ6B6zmbn8lp92yBaNh538veyNszDuCR/A50H3W2+DAHENe/XJ78NTCQzZgAtjKqb xj59LmZywcf4iNj4y7XnKFVWYY5sC1E/PJfutCmGYNwUAx93iISQYigaPY0L0ZcZ8FMY dgPYKifbcMIuBa9xj7uSwoiYidA2pfDkOPBsxej7Qn9bJIsnsL17ySlQ/5Ig3QdfpcbB JPSw== X-Gm-Message-State: AOUpUlGS2QujXEWxVbBgKe78P6wnwas5sfK/BtEAUo8YM6JEc13nmzxR Calo/FLCBdeXFTP/jfg9zb8= X-Received: by 2002:a62:571b:: with SMTP id l27-v6mr14451353pfb.29.1532371170598; Mon, 23 Jul 2018 11:39:30 -0700 (PDT) Received: from dtor-ws ([2620:0:1000:1511:8de6:27a8:ed13:2ef5]) by smtp.gmail.com with ESMTPSA id b67-v6sm15144088pfd.74.2018.07.23.11.39.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 11:39:29 -0700 (PDT) Date: Mon, 23 Jul 2018 11:39:27 -0700 From: Dmitry Torokhov To: Guenter Roeck Cc: Anton Vasilyev , Greg Kroah-Hartman , Samuel Holland , Pan Bian , linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: Re: [PATCH] firmware: vpd: Fix section enabled flag on vpd_section_destroy Message-ID: <20180723183927.GH100814@dtor-ws> References: <20180723164857.24460-1-vasilyev@ispras.ru> <20180723171336.GA15900@roeck-us.net> <20180723172305.GD100814@dtor-ws> <20180723182710.GB2964@roeck-us.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180723182710.GB2964@roeck-us.net> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 23, 2018 at 11:27:10AM -0700, Guenter Roeck wrote: > On Mon, Jul 23, 2018 at 10:23:05AM -0700, Dmitry Torokhov wrote: > > On Mon, Jul 23, 2018 at 10:13:36AM -0700, Guenter Roeck wrote: > > > On Mon, Jul 23, 2018 at 07:48:57PM +0300, Anton Vasilyev wrote: > > > > static struct ro_vpd and rw_vpd are initialized by vpd_sections_init() > > > > in vpd_probe() based on header's ro and rw sizes. > > > > In vpd_remove() vpd_section_destroy() performs deinitialization based > > > > on enabled flag, which is set to true by vpd_sections_init(). > > > > This leads to call of vpd_section_destroy() on already destroyed section > > > > for probe-release-probe-release sequence if first probe performs > > > > ro_vpd initialization and second probe does not initialize it. > > > > > > > > > > I am not sure if the situation described can be seen in the first place. > > > The second probe would only not perform ro_vpd initialization if it fails > > > prior to that, ie if it fails to allocate memory or if there is a > > > consistency problem. In that case the remove function would not be called. > > > > > > However, there is a problem in the code: A partially failed probe will > > > leave the system in inconsistent state. Example: ro section initializes, > > > rw section fails to initialize. The probe will fail, but the ro section > > > will not be destroyed, its sysfs attributes still exist, and its memory > > > is still mapped. It would make more sense to fix _that_ problem. > > > Essentially, vpd_sections_init() should clean up after itself after it > > > fails to initialize a section. > > > > > > Note that I am not convinced that the "enabled" flag is needed in the first > > > place. It is only relevant if vpd_section_destroy() is called, which only > > > happens from the remove function. The remove function is only called if the > > > probe function succeeded. In that case it is always set for both sections. > > > > The problem will happen if coreboot memory changes between 2 probes so > > that header.ro_size is not 0 on the first pass and is 0 on the second > > pass. Not quite likely to ever happen in real life, but resetting a flag > > is pretty cheap to not do it. > > > > If that can happen between probes, meaning it is not guaranteed to be > constant during the lifetime of the system, doesn't that mean it can > happen anytime ? I think we can assume that the data is stable while coreboot device is registered, but I can imagine one can theoretically have a debug coreboot data provider that can supply different coreboot parameters across load/unload. I.e. we have coreboot_table-acpi.c and coreboot_table-of.c, we might create coreboot_table-test.c to feed arbitrary data to the subsystem. Thanks. -- Dmitry