Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp301732imj; Thu, 7 Feb 2019 04:39:47 -0800 (PST) X-Google-Smtp-Source: AHgI3IY9Jp88kFWplJ6y9zfqmh2an1gxbayEihQHIWUNsdZ0mvLLCH/oZ4FX+Cdz1uNvn4KTyklB X-Received: by 2002:a17:902:bc3:: with SMTP id 61mr16390511plr.15.1549543187300; Thu, 07 Feb 2019 04:39:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549543187; cv=none; d=google.com; s=arc-20160816; b=gRylAjq3LfqFM8N2RBTovue85N3+ZM+j54B/pEc+D2v/7+jZ6RuMDGbNKisKbiyTrh W58B2h8w2pjNyOQj3t+4WUFaxlnMKavBmcTeh9gp+N+nS6R+jqTgT0NlZzDFvaevWxQn m5jJgsNrAo6tv5L4aW6gtc9UEySsUpDj+keqInR1Fpf3Nt6nurHm4CUGoEHipfxhH/S+ D4uERdmJ3k5qVpLVqBPnVhzjZMLSeNrP37pcPkLMh7hNphX+Qycibkr+ihna0VMWoaT4 cJe82uXPogd3yZqPv7JpXUBoH5lX7pvsUfPSyXcfwJZZuqeMnjE/41a5g4OiE3+QtoxG 1B+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=u9UsQ9HV0XLiET0AzbmEzLO78hJ/kCLH5gRK0jtQWxM=; b=Vra8hVukzmW/sC8ibYHIu8u1AO563lWTR0BE13MzgQm9sPInWr1TdFyFd0VABgd1Uz 18CN9JdwHziBPKi9OnaID2hFV5p4PN669EEgpVmWjh/sj5agBZEu9bRH1rRUu084iMVQ I8NMNqg0sGxqnY1LvkpDAV0w4GBBFboO31W3Bq3K+XaBhxEKiZ6aQE1lCpAMEA85a6zf iD5Pom91pGOqUBoFdu8p6ptQMCp3w8nWQ2/flZ1dM0qUdQQlLV/84B5cP2Sifs9CLCH0 yzWLJ6J5bkKWtWObypScyzV6MU54N1rwS92UHnoMCx5ZShCcPybusYBDsSemkCEP/RF/ G/Sg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mok.nu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si9620661plc.277.2019.02.07.04.39.31; Thu, 07 Feb 2019 04:39:47 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mok.nu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726855AbfBGMj0 (ORCPT + 99 others); Thu, 7 Feb 2019 07:39:26 -0500 Received: from proxy01.fsdata.se ([89.221.252.211]:21547 "EHLO mail-gw01.fsdata.se" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726769AbfBGMj0 (ORCPT ); Thu, 7 Feb 2019 07:39:26 -0500 Received: from localhost (94.234.45.123) by DAG01.HMC.local (192.168.46.11) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 7 Feb 2019 13:39:14 +0100 Date: Thu, 7 Feb 2019 13:39:13 +0100 From: Mattias Jacobsson <2pi@mok.nu> To: Andy Shevchenko CC: Masahiro Yamada , , Darren Hart , "Andy Shevchenko" , Pali =?utf-8?B?Um9ow6Fy?= , Platform Driver , Linux Kernel Mailing List , <2pi@mok.nu> Subject: Re: [PATCH v3 2/3] platform/x86: wmi: add WMI support to MODULE_DEVICE_TABLE() Message-ID: <20190207123912.wjniyxjgagc3hfo2@mok.nu> References: <20190203190423.lmsix5la6ioyawwi@mok.nu> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-Originating-IP: [94.234.45.123] X-ClientProxiedBy: PROXY01.HMC.local (192.168.46.51) To DAG01.HMC.local (192.168.46.11) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-02-05, Andy Shevchenko wrote: > On Sun, Feb 3, 2019 at 9:04 PM Mattias Jacobsson <2pi@mok.nu> wrote: > > On 2019-01-30, Andy Shevchenko wrote: > > > On Wed, Jan 30, 2019 at 5:15 PM Mattias Jacobsson <2pi@mok.nu> wrote: > > > > > + if (len < 0 || len >= 500) { > > > > > > Would it even possible to get a negative number here? > > > Same for any other number than slightly bigger than 36. > > > > snprintf returns a negative number on error. BTW AFAIU the code from > > file2alias.c gets dynamically linked against a libc. > > OK. > > > > So, what about simple > > > > > > { > > > DEF_FIELD_ADDR(...); > > > size_t len; > > > > > > len = strlen(*guid_string); > > > if (len != ...) { > > > ... > > > } > > > sprintf(...); > > > return 1; > > > } > > > > > > ? > > > > Then we are missing the check that we are within the bounds of alias > > I don't see how. By checking a length of string we be sure, that the > result would have a non-arbitrary length. If you do s/500/ALIAS_SIZE/ on the patch? My code is written with that in mind, I guess that wasn't totally clear. BTW I've posted [1] to introduce the ALIAS_SIZE macro. [1]: https://lore.kernel.org/lkml/20190207123022.7961-1-2pi@mok.nu/ > > > as well as the negative code from s*printf(). snprintf() does this nicely > > for us. > > This one I agree with, means in the above example we may do > > return sprintf(...); > > if callers recognize just a sign, or > > len = sprintf(...); > if (len < 0) > return len; // -1? 0? > > return 1; > > otherwise. Great > > -- > With Best Regards, > Andy Shevchenko Thanks, Mattias