Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6103804imm; Mon, 23 Jul 2018 11:28:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdR2ztvNAwF3v8LYq2fQwNqp/MaUU72YEM96ZqchpDeqPmx9AwrM6d2wHEiUGaaunO9I+2/ X-Received: by 2002:a63:5b0d:: with SMTP id p13-v6mr13393328pgb.202.1532370505708; Mon, 23 Jul 2018 11:28:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532370505; cv=none; d=google.com; s=arc-20160816; b=ZhDSs6TtLBE38xRg2ZInv2WpCE13UEAAn+nU69wnfOu+ugq/DUWho9DR+FWtKF36HW QMKYKfoqGMavMTxFDgzu6LKVcMUJfe4y0WupBLCMBAQhNwD0Hs3F9XHcEgcnLmvs+bHH 8U2Z6Mhoi2ObRFBI5ZssTYgi7yr2ZLhcrqGfSn2HK6HernZEzqZWUROz54fNvEnkh9zb xHvlLj/aVyz3u4oOCpbzzbeUoZvcjj/GrkOUWnI17N0+7Z7pn3m3ZZFkS/NUZTVtrzok 6ptnPI0fVJvqNwURRoOi72BXYHrNNu4vsTQOfXa/hm4Z/TnfX/rNR7ojuGvNr7E2cbBI tSsg== 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=QAD8VkzUnoxt0oaFEdR8oTU9ignL1cZncWX5BkYRV8k=; b=lqgfCdFrpnP1+/vgN8jyRm0Iu5XsmGTyMImGWgt7bDJ9IqUdJjR6JOAHdIsAl8+sOb Af01CNWh1RyRN6kZ/l5IfJv8UjY6O6tY0SceSv27Yj14K1sYe+9Mtq6o4mJnGG105gWi +00rg0K1C8Whpn3PTCycAoQV4NtKwwqF8Q3s/jUNkXQyhEulELzVJfPsRXY/9KCuc/sB zCFuLLY2G/j0Gh5TdRV25ZPZDSFO7O6eLiXF2F3ExdKKVsII/301tJQgRWTJ7ofZtJBZ wcOOS4PeQ3nDX57ANyZoh8Ecs14e9OKsITTOcRaKR144LJgabriT2CWwcrcf7If+52vh /5KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=LH0DuA27; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i1-v6si9987601pfa.219.2018.07.23.11.28.11; Mon, 23 Jul 2018 11:28:25 -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=fail header.i=@gmail.com header.s=20161025 header.b=LH0DuA27; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388154AbeGWT3l (ORCPT + 99 others); Mon, 23 Jul 2018 15:29:41 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:39680 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387873AbeGWT3l (ORCPT ); Mon, 23 Jul 2018 15:29:41 -0400 Received: by mail-oi0-f66.google.com with SMTP id d189-v6so2885792oib.6 for ; Mon, 23 Jul 2018 11:27:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=QAD8VkzUnoxt0oaFEdR8oTU9ignL1cZncWX5BkYRV8k=; b=LH0DuA27lHrEVHa27rly4RpH4+a844Hq3GScrlHfLdYKIEVptBKVEo8hUYJyjb477s InR3oiOA8tBhm/LpuOboFgtb8obc0TXSlCEXd9LJwxVCnPFUKlFZXm2PcU6jlHLx9Jsg N8jjWJ0UzKDJA80c5/S1a3Suu2YIdJDDfjE8rTZz43dQymazWRSVH0YSiHSekBTYfL0h XB4OiIYQzY9bHLzYP+JQEDbvzvh2NFtBy5rYewGNcNZiRQEPyyEkIfeMFSoS7mKpelxL osQMtqKiPyf9B3FL2nhQ3SQtPqwlAC6N2VdmQK+RVA7cpe/NZONrnOUJT95lko1umA+V 1IRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=QAD8VkzUnoxt0oaFEdR8oTU9ignL1cZncWX5BkYRV8k=; b=SfQR9WB/zfOvIWaqV/GQ1uxPW0yvJYFTFN0noK+YPWhcBnZpfOX/JD7YWU5yfPgRBT j82aDXbDzRs7Lly3Pmo1mdsZYnNo1QQ3SHM5OleVU0Q37RRsMQaINtxPBMgiDYVNIe3w EhW8qrzoONZ4M4Ie+HG/d1mRsNAmwdfZTBxVPGJzL8uJUXTQMUAWsdpuw77o2sIYlYvY 6OQfFjCLv2rLhew0M5PQNQnGph4VXvuiF8oW5z6kIP1sthlnQHRX7IAxtYOuLGFy9bJ3 hM2SKb7yttGlSP+AnN/b5WSW5g2I613KTx5fwLFj+KquJUOHo0JtOK9dkW9wKSi1XtD9 OqgQ== X-Gm-Message-State: AOUpUlFla9WIKG7pC7We/owfJKea9wBq/sqj1vRG4e/jf4HRgV2ipwPZ b1bi14yrnaVJMW5TDhLpuNA= X-Received: by 2002:aca:4c8e:: with SMTP id z136-v6mr10331085oia.170.1532370432402; Mon, 23 Jul 2018 11:27:12 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id v202-v6sm8691370oie.47.2018.07.23.11.27.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Jul 2018 11:27:11 -0700 (PDT) Date: Mon, 23 Jul 2018 11:27:10 -0700 From: Guenter Roeck To: Dmitry Torokhov 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: <20180723182710.GB2964@roeck-us.net> References: <20180723164857.24460-1-vasilyev@ispras.ru> <20180723171336.GA15900@roeck-us.net> <20180723172305.GD100814@dtor-ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180723172305.GD100814@dtor-ws> User-Agent: Mutt/1.5.24 (2015-08-30) 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 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 ? Guenter