Received: by 10.213.65.68 with SMTP id h4csp2574743imn; Mon, 9 Apr 2018 05:51:45 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+F9IAAtptmR5sBy0FzGJw/ckZ/jW7DLtQ0i9e9kg5UYeg2zDaKPCTDSmerrfZC8l4LqoW9 X-Received: by 10.98.87.151 with SMTP id i23mr29088829pfj.175.1523278305071; Mon, 09 Apr 2018 05:51:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523278305; cv=none; d=google.com; s=arc-20160816; b=G22yaqJ3GZ26AJlOe3gCUTV/bNgi+oWYHICtgECfqE5dMYCSxFmSnolv94nOCtpy83 iRjqWBSp0MNUptpHsuKvW0fMzqQXjU8wJT6IrAd5xN8GfGDuw7TAQqSHwbqwY1NGKyoy R8VK9HPrRvtBjPO64qlUuGWIgbVHHUIGgi6w9qdje1N3LuRJBrXYx0K6AFmuI87kNXny UI/humTzl3EGOX69VXi9Fm14YkEJR6d8Xg5QY32wg+jlBbOEGYV3HCs8rcv2EVfJD544 Bh8nKzZMeUoeBztCMmSabB1g65ZKmbucVXqhu3iLFdA/qJ2W+pvrziXGigqrDVOkS/Hn YfNQ== 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:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=Fii+tlQj+XJobvrf64y7gBR7ksWPs+so2uqb4EaBXvU=; b=ljvbHDOzE3RG4nx3Nz4TqxSwK24klav2fY9+7EtuVPC+DyV48v4lidSvU10PnYpsZO dKq/dDmV8QZUUuUoyOEC7H4KP27UNiwcLH3wYObK8c+USYAvRpVXemK7z/48PNR1iF8Z mxrHSkWovHV7AQGEsGLquKpxa764/T9AIIR6GxnsUDy08/A4XKRrVM4k8edf8Xd589IQ U+UzW0YvBWY7HVkIyTv+2Wz8iWP8mjTHj8EcO8Yw35XcGMlpc/2HzOHHhra0g3OWbOOW M+GPkcOZfOg6+UO9f31xS/Be9LjbM86BnQye4SI5gpYBEie7mgXh2Y0YnZ8zc/g1E+n7 yF5Q== ARC-Authentication-Results: i=1; mx.google.com; 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 e13si199583pff.238.2018.04.09.05.51.07; Mon, 09 Apr 2018 05:51:45 -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; 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 S1751919AbeDIMsH (ORCPT + 99 others); Mon, 9 Apr 2018 08:48:07 -0400 Received: from mx2.suse.de ([195.135.220.15]:40539 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751834AbeDIMsG (ORCPT ); Mon, 9 Apr 2018 08:48:06 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1E213AF06; Mon, 9 Apr 2018 12:48:05 +0000 (UTC) Date: Mon, 9 Apr 2018 14:48:03 +0200 From: Jean Delvare To: Parag Warudkar Cc: Sasha Levin , stable@vger.kernel.org, linux-kernel@vger.kernel.org, Ingo Molnar , Thomas Gleixner Subject: Re: [PATCH AUTOSEL for 4.15 142/189] firmware: dmi_scan: Fix handling of empty DMI strings Message-ID: <20180409144803.08293fe4@endymion> In-Reply-To: References: <20180409001637.162453-1-alexander.levin@microsoft.com> <20180409001637.162453-142-alexander.levin@microsoft.com> Organization: SUSE Linux X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.31; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Parag, On Sun, 8 Apr 2018 21:21:19 -0400, Parag Warudkar wrote: > On Sun, Apr 8, 2018 at 8:18 PM, Sasha Levin > wrote: > > > From: Jean Delvare > > > > [ Upstream commit a7770ae194569e96a93c48aceb304edded9cc648 ] > > > > [snip] > > > > > > * Strings starting with 8 spaces are all considered empty, even if > > non-space characters follow (sounds like a weird thing to do, but > > I have actually seen occurrences of this in DMI tables before.) > > > > Unless I am misreading the patch we will now allocate memory for > len(spaces)+len(string) for this case. Correct. > Have you seen BIOSes with lots of string occurrences? A fair number, yes, but most of them were thankfully not in strings we are saving. Also note that most of them only have 1 or 2 leading spaces, not 8+, so this commit makes no difference for them. > If so what's the point of allocating memory for the leading spaces? Presented like that, it sounds like we are silly. But look at things the other way around: what's the point of storing these leading spaces in the DMI table in the first place? Whenever this happens, the hardware manufacturer is to blame, not us. As much as possible, we should stick to the specification and assume the other party does as well. Stripping the leading spaces would be trivial, but hiding their mistakes does not help hardware manufacturers in the long run anyway. If they can't see that it's wrong, it's harder for them to fix it. > IOW, what happens if we strip leading space before allocating? At boot time, we save a few bytes of memory, on the affected systems only. No code cost, but possibly some confusion as to why we strip leading spaces (which are rare) but not trailing spaces (which in my experience are more frequent.) At run time, the exact matching of the affected DMI strings would be less error-prone (although strings having leading spaces are likely to also have trailing spaces, annihilating the benefits.) Non-exact matching would be marginally faster, again only for the affected systems. As a conclusion, it's doable, but the benefit is very small and limited to a few broken systems, and it has the downside of not discouraging low-quality tables, so my position is that it's not worth it and not desirable. -- Jean Delvare SUSE L3 Support