mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx+linux-hardening@kernel.org>
To: linux-input@vger.kernel.org, linux-hardening@vger.kernel.org,
	 Marcus Folkesson <marcus.folkesson@gmail.com>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	 Ville Syrjala <syrjala@sci.fi>,
	Henk Vergonet <Henk.Vergonet@gmail.com>,
	 Henrik Rydberg <rydberg@bitmath.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/6] Input: joystick - use usb_make_subpath()
Date: Thu, 22 Oct 2026 12:03:02 +0200	[thread overview]
Message-ID: <atnepCUZOnMJatgG@debian> (raw)
In-Reply-To: <5wdnvsf6bepzpxzfizt4fs3325denwzeeksg3b3hpmzu3257tk@ms7kh4fcgz2k>

[-- Attachment #1: Type: text/plain, Size: 1350 bytes --]

Hi Shihuang,

> Date: 2026-10-22 15:36:39+0800
> From: Shihuang Liu <shlomojune6@gmail.com>
>
[...]
> > > -	usb_make_path(udev, pxrc->phys, sizeof(pxrc->phys));
> > > -	strlcat(pxrc->phys, "/input0", sizeof(pxrc->phys));
> > > +	usb_make_subpath(udev, pxrc->phys, sizeof(pxrc->phys), "input0");
> > 
> > To be honest, I think the composed approach is more readable.  You don't
> > need to learn a new _subpath function with all the details it has.
> > 
> > Everyone knows what a str*cat() (or str*cpy, FWIW) function does.
> > 
> > I'd rather improve this by adding strscat().  The reason for removing
> > strlcat(3) is that it is vulnerable to DoS, and that it is inefficient,
> > but it is good at producing readable code, and a replacement should not
> > degrade that.
> > 
> > 
> > Have a lovely day!
> > Alex
> > 
> Besides that, strscat() has other issues:
> 
> - The `sizeof(buf) - len` arithmetic is a classic source of
> off-by-one bugs.
> - any future change means re-deriving the offsets all over again.

The whole point of str*cat() functions is that you don't need to derive
the offsets at all.  Just look at the strlcat(3) code above: it doesn't
do any length calculations.

> I'd prefer to avoid strscat() here.
> 
> Thanks
> Shihuang


Cheers,
Alex

-- 
<https://www.alejandro-colomar.es>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2026-10-22 10:03 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21 12:31 [PATCH v2 0/6] USB: add usb_make_subpath() to replace strlcat() in input drivers Shihuang Liu
2026-10-21 12:31 ` [PATCH v2 1/6] USB: add usb_make_subpath() for formatted device subpaths Shihuang Liu
2026-10-21 13:17   ` Alejandro Colomar
2026-10-22  7:08     ` Shihuang Liu
2026-10-22  9:59       ` Alejandro Colomar
2026-10-21 15:20   ` Greg KH
2026-10-22  6:49     ` Shihuang Liu
2026-10-21 12:31 ` [PATCH v2 2/6] Input: joystick - use usb_make_subpath() Shihuang Liu
2026-10-21 13:21   ` Alejandro Colomar
2026-10-21 17:00     ` Dmitry Torokhov
2026-10-21 17:20       ` Alejandro Colomar
2026-10-22  7:36     ` Shihuang Liu
2026-10-22 10:03       ` Alejandro Colomar [this message]
2026-10-21 12:31 ` [PATCH v2 3/6] Input: misc " Shihuang Liu
2026-10-21 12:31 ` [PATCH v2 4/6] Input: mouse " Shihuang Liu
2026-10-21 12:31 ` [PATCH v2 5/6] Input: tablet " Shihuang Liu
2026-10-21 12:31 ` [PATCH v2 6/6] Input: touchscreen " Shihuang Liu
2026-10-22  7:09 ` [PATCH v2 RESEND 0/6] USB: add usb_make_subpath() to replace strlcat() in input drivers Shihuang Liu
2026-10-22  7:09   ` [PATCH v2 RESEND 1/6] USB: add usb_make_subpath() for formatted device subpaths Shihuang Liu
2026-10-22  7:09   ` [PATCH v2 RESEND 2/6] Input: joystick - use usb_make_subpath() Shihuang Liu
2026-10-22  7:09   ` [PATCH v2 RESEND 3/6] Input: misc " Shihuang Liu
2026-10-22  7:09   ` [PATCH v2 RESEND 4/6] Input: mouse " Shihuang Liu
2026-10-22  7:09   ` [PATCH v2 RESEND 5/6] Input: tablet " Shihuang Liu
2026-10-22  7:09   ` [PATCH v2 RESEND 6/6] Input: touchscreen " Shihuang Liu

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=atnepCUZOnMJatgG@debian \
    --to=alx+linux-hardening@kernel.org \
    --cc=Henk.Vergonet@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcus.folkesson@gmail.com \
    --cc=rydberg@bitmath.org \
    --cc=syrjala@sci.fi \
    /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

all inboxes | Powered by JetHome®