Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp13958pxb; Wed, 30 Mar 2022 21:28:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPvclcxu4h4cJ+Ch1q7uK4MZ4ByichNIxnKV5/rAp/22S5CccO+VG9CQMKnH4bu+h42Bcu X-Received: by 2002:a17:902:6901:b0:156:4aad:fad7 with SMTP id j1-20020a170902690100b001564aadfad7mr3167985plk.33.1648700893437; Wed, 30 Mar 2022 21:28:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648700893; cv=none; d=google.com; s=arc-20160816; b=BvieBKI1qryZaL0DNMXh3sD6AruIeoTcsIJL6S+BmTl/dXG7xFbqMZSoUylG7j/AFJ 8cAFD9CM+8q2f7HpfRCyU0YXMocXxHw9SLi5LX4z8HzLhoaUx2OzUQCK7/7IKKrh7WvO WIIWmnyw/7mCzUn+8ORoeKYC8zUVCy4G2om4k6FXUBPlVjtomj0ltrpVhtFJbyISGLRs XxolBKZFs72TvlMaOON4TvB2ua9UbV6McIQXwePWqzI7tKtSHaM3aOrL9b6AG1It9GAX Y7kRGsc1F0MctsU/sB2fjBv8oCStGZzLUWRk3j9Q2bwzmrE1aL9WDyE5ZdZ2DwAkBKlK 7Udg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=BQdraDJ59xMC2mx+WoHLAyajzS4OCD2VrYvz1y4RWKg=; b=J5YeznJ0jgjdVG2367MchUOJx/5HG5zd1lXUYGx4izC55L5kzMChTtECCqtvxmGVbQ utEPQVIlAfLtOdQc2g2WyuGRKuZ+saQk18yGPPbJ1blSn8L0Gx4oLjRhU+vN99OBE+3t RGOd0kPXIoPyL0gObzxD1J2z+8xS/a61HAoYkOI2S951D4Six7Kp1It53uWLU16uK1j9 iW60LxjkpxGgy5MSSxSqcyuHlOoYigEyOD6bxx8qqNl7M/KMl4ikrkOZXc21DJOwG9TH QjjTHY8oQzVk53o4zTIbZ0RbxCWzHox7KNaAgMlxi6YWmznHCcG6cxLUVFwkKjyFIM7Q Y62w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id o12-20020a63920c000000b003816043f03csi21406297pgd.561.2022.03.30.21.28.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 21:28:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 075641C8863; Wed, 30 Mar 2022 20:23:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242168AbiC3C7I convert rfc822-to-8bit (ORCPT + 99 others); Tue, 29 Mar 2022 22:59:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237953AbiC3C7H (ORCPT ); Tue, 29 Mar 2022 22:59:07 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6310C17538F for ; Tue, 29 Mar 2022 19:57:20 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-260-sKBCBKFINtqPnd_8YrB5ZA-1; Wed, 30 Mar 2022 03:57:17 +0100 X-MC-Unique: sKBCBKFINtqPnd_8YrB5ZA-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 30 Mar 2022 03:57:16 +0100 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.033; Wed, 30 Mar 2022 03:57:15 +0100 From: David Laight To: 'Michael Walle' , Xu Yilun , Tom Rix , Jean Delvare , Guenter Roeck , Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Jakub Kicinski , Paolo Abeni CC: "linux-hwmon@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" Subject: RE: [PATCH v2 1/5] hwmon: introduce hwmon_sanitize_name() Thread-Topic: [PATCH v2 1/5] hwmon: introduce hwmon_sanitize_name() Thread-Index: AQHYQ4dUrIB0cQMH/kajVzJ0H3I8wazXOSsg Date: Wed, 30 Mar 2022 02:57:15 +0000 Message-ID: <16d8b45eba7b44e78fa8205e6666f2bd@AcuMS.aculab.com> References: <20220329160730.3265481-1-michael@walle.cc> <20220329160730.3265481-2-michael@walle.cc> In-Reply-To: <20220329160730.3265481-2-michael@walle.cc> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Walle > Sent: 29 March 2022 17:07 > > More and more drivers will check for bad characters in the hwmon name > and all are using the same code snippet. Consolidate that code by adding > a new hwmon_sanitize_name() function. I'm assuming these 'bad' hwmon names come from userspace? Like ethernet interface names?? Is silently changing the name of the hwmon entries the right thing to do at all? What happens if the user tries to create both "foo_bar" and "foo-bar"? I'm sure that is going to go horribly wrong somewhere. It would certainly make sense to have a function to verify the name is actually valid. Then bad names can be rejected earlier on. I'm also intrigued about the list of invalid characters: +static bool hwmon_is_bad_char(const char ch) +{ + switch (ch) { + case '-': + case '*': + case ' ': + case '\t': + case '\n': + return true; + default: + return false; + } +} If '\t' and '\n' are invalid why are all the other control characters allowed? I'm guessing '*' is disallowed because it is the shell wildcard? So what about '?'. Then I'd expect '/' to be invalid - but that isn't checked. Never mind all the values 0x80 to 0xff - they are probably worse than whitespace. OTOH why are any characters invalid at all - except '/'? David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)