Skip to contentSkip to conversation

audit: Replace deprecated strcpy() with strscpy()

PATCH Applied Thorsten Blum 2 participants 4 messages Jul 18, 2025 – Aug 11, 2025 Audit

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 audit: Replace deprecated strcpy() with strscpy()

strcpy() is deprecated; use strscpy() instead.

---
 kernel/audit_tree.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/audit_tree.c +4 -2
index b0eae2a3c895..1605df0a171e 100644
@@ -93,8 +93,10 @@ static struct kmem_cache *audit_tree_mark_cachep __ro_after_init;
 static struct audit_tree *alloc_tree(const char *s)
 {
 	struct audit_tree *tree;
+	size_t sz;
 
-	tree = kmalloc(struct_size(tree, pathname, strlen(s) + 1), GFP_KERNEL);
+	sz = strlen(s) + 1;
+	tree = kmalloc(struct_size(tree, pathname, sz), GFP_KERNEL);
 	if (tree) {
 		refcount_set(&tree->count, 1);
 		tree->goner = 0;
@@ -103,7 +105,7 @@ static struct audit_tree *alloc_tree(const char *s)
 		INIT_LIST_HEAD(&tree->list);
 		INIT_LIST_HEAD(&tree->same_root);
 		tree->root = NULL;
-		strcpy(tree->pathname, s);
+		strscpy(tree->pathname, s, sz);
 	}
 	return tree;
 }
Signature · 1 line
2.50.1
maintainer
#1 lore raw
Quoted 8 lines · Thorsten Blum

strcpy() is deprecated; use strscpy() instead.

---
 kernel/audit_tree.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

This looks fine to me, but as we are at -rc6 I'm going to hold off on merging this until after the upcoming merge window.

Signature · 1 line
paul-moore.com
maintainer
#2 lore raw
Quoted 4 lines · Paul Moore
Quoted 3 lines · Thorsten Blum

strcpy() is deprecated; use strscpy() instead.

Quoted 8 lines
Quoted 5 lines
---
 kernel/audit_tree.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

This looks fine to me, but as we are at -rc6 I'm going to hold off on merging this until after the upcoming merge window.

Merged into audit/dev-staging for testing, audit/dev will happen after merge window closes.

Signature · 1 line
paul-moore.com
maintainer Applied
#3 lore raw
Quoted 11 lines · Paul Moore
Quoted 10 lines · Paul Moore
Quoted 8 lines · Thorsten Blum

strcpy() is deprecated; use strscpy() instead.

---
 kernel/audit_tree.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 5 lines
Quoted 2 lines

This looks fine to me, but as we are at -rc6 I'm going to hold off on merging this until after the upcoming merge window.

Merged into audit/dev-staging for testing, audit/dev will happen after merge window closes.

Merged into audit/dev, thanks!

Signature · 1 line
paul-moore.com