Re: [PATCH v2 3/3] kthread: Use 'task_struct->full_name' to store kthread's full name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Kees,

On 4/3/25 9:54 PM, Kees Cook wrote:
On Mon, Mar 31, 2025 at 05:48:20PM +0530, Bhupesh wrote:
Commit 6986ce24fc00 ("kthread: dynamically allocate memory to store
kthread's full name"), added 'full_name' in parallel to 'comm' for
kthread names.

Now that we have added 'full_name' added to 'task_struct' itself,
drop the additional 'full_name' entry from 'struct kthread' and also
its usage.

Signed-off-by: Bhupesh <bhupesh@xxxxxxxxxx>
I'd like to see this patch be the first patch in the series. This show
the existing use for "full_name". (And as such it'll probably need bits
from patch 1.)

Sure, I will fix this in v3.

Thanks,
Bhupesh


---
  kernel/kthread.c | 9 +++------
  1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/kernel/kthread.c b/kernel/kthread.c
index 5dc5b0d7238e..46fe19b7ef76 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -66,8 +66,6 @@ struct kthread {
  #ifdef CONFIG_BLK_CGROUP
  	struct cgroup_subsys_state *blkcg_css;
  #endif
-	/* To store the full name if task comm is truncated. */
-	char *full_name;
  	struct task_struct *task;
  	struct list_head hotplug_node;
  	struct cpumask *preferred_affinity;
@@ -108,12 +106,12 @@ void get_kthread_comm(char *buf, size_t buf_size, struct task_struct *tsk)
  {
  	struct kthread *kthread = to_kthread(tsk);
- if (!kthread || !kthread->full_name) {
+	if (!kthread || !tsk->full_name) {
  		strscpy(buf, tsk->comm, buf_size);
  		return;
  	}
- strscpy_pad(buf, kthread->full_name, buf_size);
+	strscpy_pad(buf, tsk->full_name, buf_size);
  }
bool set_kthread_struct(struct task_struct *p)
@@ -153,7 +151,6 @@ void free_kthread_struct(struct task_struct *k)
  	WARN_ON_ONCE(kthread->blkcg_css);
  #endif
  	k->worker_private = NULL;
-	kfree(kthread->full_name);
  	kfree(kthread);
  }
@@ -430,7 +427,7 @@ static int kthread(void *_create)
  		kthread_exit(-EINTR);
  	}
- self->full_name = create->full_name;
+	self->task->full_name = create->full_name;
  	self->threadfn = threadfn;
  	self->data = data;
--
2.38.1






[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux