public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Michael Walle' <michael@walle.cc>, Xu Yilun <yilun.xu@intel.com>,
	Tom Rix <trix@redhat.com>, Jean Delvare <jdelvare@suse.com>,
	Guenter Roeck <linux@roeck-us.net>, Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	"David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: "linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: RE: [PATCH v2 1/5] hwmon: introduce hwmon_sanitize_name()
Date: Wed, 30 Mar 2022 02:57:15 +0000	[thread overview]
Message-ID: <16d8b45eba7b44e78fa8205e6666f2bd@AcuMS.aculab.com> (raw)
In-Reply-To: <20220329160730.3265481-2-michael@walle.cc>

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)


  reply	other threads:[~2022-03-30  2:57 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29 16:07 [PATCH v2 0/5] hwmon: introduce hwmon_sanitize() Michael Walle
2022-03-29 16:07 ` [PATCH v2 1/5] hwmon: introduce hwmon_sanitize_name() Michael Walle
2022-03-30  2:57   ` David Laight [this message]
2022-03-30  3:46     ` Guenter Roeck
2022-03-30  9:20       ` David Laight
2022-03-30 13:58         ` Andrew Lunn
2022-03-30  6:50   ` Xu Yilun
2022-03-30 10:11     ` David Laight
2022-03-30 14:51       ` Xu Yilun
2022-03-30 15:23         ` Guenter Roeck
2022-03-31 14:45           ` Russell King (Oracle)
2022-03-31 14:51             ` Michael Walle
2022-03-31 14:58               ` Russell King (Oracle)
2022-03-31 15:12                 ` Michael Walle
2022-03-31 17:11                 ` Guenter Roeck
2022-03-30 14:23   ` Guenter Roeck
2022-03-30 14:50     ` David Laight
2022-03-30 15:13       ` Guenter Roeck
2022-03-29 16:07 ` [PATCH v2 2/5] hwmon: intel-m10-bmc-hwmon: use devm_hwmon_sanitize_name() Michael Walle
2022-03-30  6:52   ` Xu Yilun
2022-03-29 16:07 ` [PATCH v2 3/5] net: sfp: use hwmon_sanitize_name() Michael Walle
2022-03-30 19:40   ` Russell King (Oracle)
2022-03-31 14:46   ` Russell King (Oracle)
2022-03-29 16:07 ` [PATCH v2 4/5] net: phy: nxp-tja11xx: use devm_hwmon_sanitize_name() Michael Walle
2022-03-29 16:07 ` [PATCH RFC v2 5/5] hwmon: move hwmon_is_bad_char() into core Michael Walle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=16d8b45eba7b44e78fa8205e6666f2bd@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=hkallweit1@gmail.com \
    --cc=jdelvare@suse.com \
    --cc=kuba@kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=linux@roeck-us.net \
    --cc=michael@walle.cc \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=trix@redhat.com \
    --cc=yilun.xu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox