nvsciipc KMD: Fix incorrect PID

The code was using task_pid_nr(current) to get the process ID, which
returns the Thread ID (TID) instead of the actual Process ID (PID) for
multi-threaded applications. This caused problems with endpoint
reservation tracking since different threads of the same process would
appear as different owners.

current->tgid (Thread Group ID) represents the actual Process ID in
Linux. task_pid_nr(current) returns the Thread ID which is unique for each
thread within a process. Using TGID ensures all threads from the same
process are properly identified as belonging to the same process.

This fix ensures proper endpoint reservation tracking across all threads
of a multi-threaded application.

Bug 5260259

Change-Id: If2f864dc4456de71b1df49e64320463a24203c68
Signed-off-by: Suneel Kumar Pemmineti <spemmineti@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3360307
Reviewed-by: Simon Je <sje@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Joshua Cha <joshuac@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Jungho Kim <junghok@nvidia.com>
This commit is contained in:
Suneel Kumar Pemmineti
2025-05-08 10:13:02 +00:00
committed by Jon Hunter
parent f717989baf
commit 2483ab734d

View File

@@ -243,7 +243,7 @@ static int nvsciipc_ioctl_validate_auth_token(struct nvsciipc *ctx,
if ((ctx->num_eps == 0) || (ctx->set_db_f != true)) {
ERR("%s[%d] need to set endpoint database first\n", __func__,
get_current()->pid);
get_current()->tgid);
ret = -EPERM;
goto exit;
}
@@ -281,7 +281,7 @@ static int nvsciipc_ioctl_map_vuid(struct nvsciipc *ctx, unsigned int cmd,
if ((ctx->num_eps == 0) || (ctx->set_db_f != true)) {
ERR("%s[%d] need to set endpoint database first\n", __func__,
get_current()->pid);
get_current()->tgid);
ret = -EPERM;
goto exit;
}
@@ -319,7 +319,7 @@ static int nvsciipc_ioctl_get_db_by_idx(struct nvsciipc *ctx, unsigned int cmd,
if ((ctx->num_eps == 0) || (ctx->set_db_f != true)) {
ERR("%s[%d] need to set endpoint database first\n", __func__,
get_current()->pid);
get_current()->tgid);
return -EPERM;
}
@@ -360,12 +360,12 @@ static int nvsciipc_ioctl_reserve_ep(struct nvsciipc *ctx, unsigned int cmd,
unsigned long arg)
{
struct nvsciipc_reserve_ep reserve_ep;
pid_t current_pid = task_pid_nr(current);
pid_t current_pid = current->tgid;
int i;
if ((ctx->num_eps == 0) || (ctx->set_db_f != true)) {
ERR("%s[%d] need to set endpoint database first\n", __func__,
get_current()->pid);
get_current()->tgid);
return -EPERM;
}
@@ -467,7 +467,7 @@ static int nvsciipc_ioctl_get_db_by_name(struct nvsciipc *ctx, unsigned int cmd,
if ((ctx->num_eps == 0) || (ctx->set_db_f != true)) {
ERR("%s[%d] need to set endpoint database first\n", __func__,
get_current()->pid);
get_current()->tgid);
return -EPERM;
}
@@ -521,7 +521,7 @@ static int nvsciipc_ioctl_get_db_by_vuid(struct nvsciipc *ctx, unsigned int cmd,
if ((ctx->num_eps == 0) || (ctx->set_db_f != true)) {
ERR("%s[%d] need to set endpoint database first\n", __func__,
get_current()->pid);
get_current()->tgid);
return -EPERM;
}
@@ -573,7 +573,7 @@ static int nvsciipc_ioctl_get_vuid(struct nvsciipc *ctx, unsigned int cmd,
if ((ctx->num_eps == 0) || (ctx->set_db_f != true)) {
ERR("%s[%d] need to set endpoint database first\n", __func__,
get_current()->pid);
get_current()->tgid);
return -EPERM;
}
@@ -810,7 +810,7 @@ static int nvsciipc_ioctl_get_dbsize(struct nvsciipc *ctx, unsigned int cmd,
if (ctx->set_db_f != true) {
ERR("%s[%d] need to set endpoint database first\n", __func__,
get_current()->pid);
get_current()->tgid);
ret = -EPERM;
goto exit;
}
@@ -911,7 +911,7 @@ static ssize_t nvsciipc_dbg_read(struct file *filp, char __user *buf,
if (ctx->set_db_f != true) {
ERR("%s[%d] need to set endpoint database first\n", __func__,
get_current()->pid);
get_current()->tgid);
return -EPERM;
}