From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751866AbdIUU4G (ORCPT ); Thu, 21 Sep 2017 16:56:06 -0400 Received: from esa2.dell-outbound.iphmx.com ([68.232.149.220]:8786 "EHLO esa2.dell-outbound.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751728AbdIUU4E (ORCPT ); Thu, 21 Sep 2017 16:56:04 -0400 From: X-LoopCount0: from 10.166.132.198 X-IronPort-AV: E=Sophos;i="5.42,426,1500958800"; d="scan'208";a="988734018" X-DLP: DLP_GlobalPCIDSS To: CC: , , , , Subject: RE: [PATCH 07/12] platform/x86: dell-wmi-smbios: Use Dell WMI descriptor check Thread-Topic: [PATCH 07/12] platform/x86: dell-wmi-smbios: Use Dell WMI descriptor check Thread-Index: AQHTMvkLB15muQ+2uE+cH7qnXcxd8KK/sU/Q Date: Thu, 21 Sep 2017 20:56:02 +0000 Message-ID: <611e782b142740b6955ff86457933eb8@ausx13mpc120.AMER.DELL.COM> References: <1001812b63d73bf3ccd5ea6c76604cae0fa1525a.1505999739.git.mario.limonciello@dell.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.143.242.75] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id v8LKuBDj004715 > -----Original Message----- > From: Andy Shevchenko [mailto:andy.shevchenko@gmail.com] > Sent: Thursday, September 21, 2017 11:44 AM > To: Limonciello, Mario > Cc: dvhart@infradead.org; LKML ; Platform Driver > ; quasisec@google.com; Pali Rohár > > Subject: Re: [PATCH 07/12] platform/x86: dell-wmi-smbios: Use Dell WMI > descriptor check > > On Thu, Sep 21, 2017 at 4:57 PM, Mario Limonciello > wrote: > > The Dell WMI descriptor check is used as an indication that WMI > > calls are safe to run both when used with the notification > > ASL/GUID pair as well as the SMBIOS calling ASL/GUID pair. > > > > As some code in dell-wmi-smbios is already a prerequisite for > > dell-wmi, move the code for performing the descriptor check into > > dell-wmi-smbios and let both drivers use it from there. > > > + desc_buffer = (u32 *)obj->buffer.pointer; > > + > > > + if (desc_buffer[0] != 0x4C4C4544 && desc_buffer[1] != 0x494D5720) > > I was thinking about strncmp() here for a full line, though decide not > to push it anyhow. Those IDs is binary data, can be anything and you > have comment of what is expected here. > > But I think it would be nice to create a separate definitions and make > comments there. > > > + dev_warn(&wdev->dev, "Dell descriptor buffer has invalid signature > (%*ph)\n", > > + 8, desc_buffer); > > %8ph ? > > > + > > + if (desc_buffer[2] != 0 && desc_buffer[2] != 1) > > + dev_warn(&wdev->dev, "Dell descriptor buffer has unknown version > (%d)\n", > > + desc_buffer[2]); > > %u ? u32 can't be negative and you basically allow it. > > > + > > + if (desc_buffer[3] != 4096) > > + dev_warn(&wdev->dev, "Dell descriptor buffer has invalid buffer length > (%d)\n", > > + desc_buffer[3]); > > Ditto. > > > P.S. I noticed this all in old code, so, you can address my comments > in a separate patch if you find them useful. > Yeah this is all old code. I've made some adjustments to it in v2 in a completely separate patch that comes after the patch it's "moved". I'll submit back after other feedback to this series.