Skip to content

Commit 3240aad

Browse files
laoarakpm00
authored andcommitted
drm: replace strcpy() with strscpy()
To prevent errors from occurring when the src string is longer than the dst string in strcpy(), we should use strscpy() instead. This approach also facilitates future extensions to the task comm. Link: https://lkml.kernel.org/r/20241007144911.27693-8-laoar.shao@gmail.com Signed-off-by: Yafang Shao <laoar.shao@gmail.com> Suggested-by: Justin Stitt <justinstitt@google.com> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Justin Stitt <justinstitt@google.com> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Cc: Maxime Ripard <mripard@kernel.org> Cc: Thomas Zimmermann <tzimmermann@suse.de> Cc: David Airlie <airlied@gmail.com> Cc: Alejandro Colomar <alx@kernel.org> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com> Cc: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Christian Brauner <brauner@kernel.org> Cc: Eric Biederman <ebiederm@xmission.com> Cc: Eric Paris <eparis@redhat.com> Cc: James Morris <jmorris@namei.org> Cc: Jan Kara <jack@suse.cz> Cc: Kees Cook <keescook@chromium.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Matthew Wilcox <willy@infradead.org> Cc: Matus Jokay <matus.jokay@stuba.sk> Cc: Ondrej Mosnacek <omosnace@redhat.com> Cc: Paul Moore <paul@paul-moore.com> Cc: Quentin Monnet <qmo@kernel.org> Cc: "Serge E. Hallyn" <serge@hallyn.com> Cc: Simon Horman <horms@kernel.org> Cc: Stephen Smalley <stephen.smalley.work@gmail.com> Cc: Steven Rostedt (Google) <rostedt@goodmis.org> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 4373151 commit 3240aad

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

drivers/gpu/drm/drm_framebuffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb,
868868
INIT_LIST_HEAD(&fb->filp_head);
869869

870870
fb->funcs = funcs;
871-
strcpy(fb->comm, current->comm);
871+
strscpy(fb->comm, current->comm);
872872

873873
ret = __drm_mode_object_add(dev, &fb->base, DRM_MODE_OBJECT_FB,
874874
false, drm_framebuffer_free);

drivers/gpu/drm/i915/i915_gpu_error.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ i915_vma_coredump_create(const struct intel_gt *gt,
11131113
}
11141114

11151115
INIT_LIST_HEAD(&dst->page_list);
1116-
strcpy(dst->name, name);
1116+
strscpy(dst->name, name);
11171117
dst->next = NULL;
11181118

11191119
dst->gtt_offset = vma_res->start;
@@ -1413,7 +1413,7 @@ static bool record_context(struct i915_gem_context_coredump *e,
14131413
rcu_read_lock();
14141414
task = pid_task(ctx->pid, PIDTYPE_PID);
14151415
if (task) {
1416-
strcpy(e->comm, task->comm);
1416+
strscpy(e->comm, task->comm);
14171417
e->pid = task->pid;
14181418
}
14191419
rcu_read_unlock();
@@ -1459,7 +1459,7 @@ capture_vma_snapshot(struct intel_engine_capture_vma *next,
14591459
return next;
14601460
}
14611461

1462-
strcpy(c->name, name);
1462+
strscpy(c->name, name);
14631463
c->vma_res = i915_vma_resource_get(vma_res);
14641464

14651465
c->next = next;

0 commit comments

Comments
 (0)