From: Shihuang Liu <shlomojune6@gmail.com>
To: linux-input@vger.kernel.org, linux-hardening@vger.kernel.org
Cc: 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,
Shihuang Liu <shlomojune6@gmail.com>
Subject: [PATCH 3/5] Input: mouse - replace strlcat() with strscpy()
Date: Sat, 17 Oct 2026 01:04:09 +0800 [thread overview]
Message-ID: <20261016170411.51025-4-shlomojune6@gmail.com> (raw)
In-Reply-To: <20261016170411.51025-1-shlomojune6@gmail.com>
The appletouch, bcm5974 and synaptics_usb drivers build the
physical path by appending a constant "/input0" suffix with
strlcat() after usb_make_path().
In preparation for removing the deprecated strlcat() API[1],
replace it with strnlen() followed by strscpy() into the remainder
of the buffer, as commit 34b228b739f5 ("HID: usbhid: replace
strlcat with better alternatives") did for the usbhid drivers.
Link: https://github.com/KSPP/linux/issues/370 [1]
Signed-off-by: Shihuang Liu <shlomojune6@gmail.com>
---
drivers/input/mouse/appletouch.c | 4 +++-
drivers/input/mouse/bcm5974.c | 4 +++-
drivers/input/mouse/synaptics_usb.c | 4 +++-
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c
index eebeb57515e1c..aa43f7ae274ce 100644
--- a/drivers/input/mouse/appletouch.c
+++ b/drivers/input/mouse/appletouch.c
@@ -832,6 +832,7 @@ static int atp_probe(struct usb_interface *iface,
struct usb_endpoint_descriptor *ep;
int error;
const struct atp_info *info = (const struct atp_info *)id->driver_info;
+ size_t len;
/* set up the endpoint information */
/* use only the first interrupt-in endpoint */
@@ -875,7 +876,8 @@ static int atp_probe(struct usb_interface *iface,
goto err_free_buffer;
usb_make_path(udev, dev->phys, sizeof(dev->phys));
- strlcat(dev->phys, "/input0", sizeof(dev->phys));
+ len = strnlen(dev->phys, sizeof(dev->phys));
+ strscpy(dev->phys + len, "/input0", sizeof(dev->phys) - len);
input_dev->name = "appletouch";
input_dev->phys = dev->phys;
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
index e772bac3b64c0..64e26cca2c2c4 100644
--- a/drivers/input/mouse/bcm5974.c
+++ b/drivers/input/mouse/bcm5974.c
@@ -928,6 +928,7 @@ static int bcm5974_probe(struct usb_interface *iface,
struct bcm5974 *dev;
struct input_dev *input_dev;
int error = -ENOMEM;
+ size_t len;
/* find the product index */
cfg = bcm5974_get_config(udev);
@@ -990,7 +991,8 @@ static int bcm5974_probe(struct usb_interface *iface,
/* create bcm5974 device */
usb_make_path(udev, dev->phys, sizeof(dev->phys));
- strlcat(dev->phys, "/input0", sizeof(dev->phys));
+ len = strnlen(dev->phys, sizeof(dev->phys));
+ strscpy(dev->phys + len, "/input0", sizeof(dev->phys) - len);
input_dev->name = "bcm5974";
input_dev->phys = dev->phys;
diff --git a/drivers/input/mouse/synaptics_usb.c b/drivers/input/mouse/synaptics_usb.c
index 880a0c79148cd..e1a4a9746dbee 100644
--- a/drivers/input/mouse/synaptics_usb.c
+++ b/drivers/input/mouse/synaptics_usb.c
@@ -279,6 +279,7 @@ static int synusb_probe(struct usb_interface *intf,
unsigned int intf_num = intf->cur_altsetting->desc.bInterfaceNumber;
unsigned int altsetting = min(intf->num_altsetting, 1U);
int error;
+ size_t len;
error = usb_set_interface(udev, intf_num, altsetting);
if (error) {
@@ -354,7 +355,8 @@ static int synusb_probe(struct usb_interface *intf,
strlcat(synusb->name, " (Stick)", sizeof(synusb->name));
usb_make_path(udev, synusb->phys, sizeof(synusb->phys));
- strlcat(synusb->phys, "/input0", sizeof(synusb->phys));
+ len = strnlen(synusb->phys, sizeof(synusb->phys));
+ strscpy(synusb->phys + len, "/input0", sizeof(synusb->phys) - len);
input_dev->name = synusb->name;
input_dev->phys = synusb->phys;
--
2.43.0
next prev parent reply other threads:[~2026-10-16 17:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 17:04 [PATCH 0/5] Input: replace strlcat() with strscpy() in USB input drivers Shihuang Liu
2026-10-16 17:04 ` [PATCH 1/5] Input: joystick - replace strlcat() with strscpy() Shihuang Liu
2026-10-16 17:04 ` [PATCH 2/5] Input: misc " Shihuang Liu
2026-10-16 17:04 ` Shihuang Liu [this message]
2026-10-16 17:04 ` [PATCH 4/5] Input: tablet " Shihuang Liu
2026-10-16 17:04 ` [PATCH 5/5] 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=20261016170411.51025-4-shlomojune6@gmail.com \
--to=shlomojune6@gmail.com \
--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