Skip to content

Commit 2af4aa3

Browse files
azeemshaikh38kees
authored andcommitted
staging: most: Replace all non-returning strlcpy with strscpy
strlcpy() reads the entire source buffer first. This read may exceed the destination size limit. This is both inefficient and can lead to linear read overflows if a source string is not NUL-terminated [1]. In an effort to remove strlcpy() completely [2], replace strlcpy() here with strscpy(). No return values were used, so direct replacement is safe. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy [2] KSPP#89 Signed-off-by: Azeem Shaikh <[email protected]> Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent f4a0659 commit 2af4aa3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/most/configfs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static ssize_t mdev_link_device_store(struct config_item *item,
204204
{
205205
struct mdev_link *mdev_link = to_mdev_link(item);
206206

207-
strlcpy(mdev_link->device, page, sizeof(mdev_link->device));
207+
strscpy(mdev_link->device, page, sizeof(mdev_link->device));
208208
strim(mdev_link->device);
209209
return count;
210210
}
@@ -219,7 +219,7 @@ static ssize_t mdev_link_channel_store(struct config_item *item,
219219
{
220220
struct mdev_link *mdev_link = to_mdev_link(item);
221221

222-
strlcpy(mdev_link->channel, page, sizeof(mdev_link->channel));
222+
strscpy(mdev_link->channel, page, sizeof(mdev_link->channel));
223223
strim(mdev_link->channel);
224224
return count;
225225
}
@@ -234,7 +234,7 @@ static ssize_t mdev_link_comp_store(struct config_item *item,
234234
{
235235
struct mdev_link *mdev_link = to_mdev_link(item);
236236

237-
strlcpy(mdev_link->comp, page, sizeof(mdev_link->comp));
237+
strscpy(mdev_link->comp, page, sizeof(mdev_link->comp));
238238
strim(mdev_link->comp);
239239
return count;
240240
}
@@ -250,7 +250,7 @@ static ssize_t mdev_link_comp_params_store(struct config_item *item,
250250
{
251251
struct mdev_link *mdev_link = to_mdev_link(item);
252252

253-
strlcpy(mdev_link->comp_params, page, sizeof(mdev_link->comp_params));
253+
strscpy(mdev_link->comp_params, page, sizeof(mdev_link->comp_params));
254254
strim(mdev_link->comp_params);
255255
return count;
256256
}

0 commit comments

Comments
 (0)