diff options
author | Rob Clark <robdclark@chromium.org> | 2023-01-10 13:28:59 -0800 |
---|---|---|
committer | Rob Clark <robdclark@chromium.org> | 2023-01-11 09:00:14 -0800 |
commit | a66f1efcf748febea7758c4c3c8b5bc5294949ef (patch) | |
tree | 8cfa9a3f9d163b01f92cc2cc398f14e1d957e5ce /drivers/gpu/drm/msm/msm_gpu.c | |
parent | e752e5454e6417da3f40ec1306a041ea96c56423 (diff) | |
download | lwn-a66f1efcf748febea7758c4c3c8b5bc5294949ef.tar.gz lwn-a66f1efcf748febea7758c4c3c8b5bc5294949ef.zip |
drm/msm/gpu: Fix potential double-free
If userspace was calling the MSM_SET_PARAM ioctl on multiple threads to
set the COMM or CMDLINE param, it could trigger a race causing the
previous value to be kfree'd multiple times. Fix this by serializing on
the gpu lock.
Signed-off-by: Rob Clark <robdclark@chromium.org>
Fixes: d4726d770068 ("drm/msm: Add a way to override processes comm/cmdline")
Patchwork: https://patchwork.freedesktop.org/patch/517778/
Link: https://lore.kernel.org/r/20230110212903.1925878-1-robdclark@gmail.com
Diffstat (limited to 'drivers/gpu/drm/msm/msm_gpu.c')
-rw-r--r-- | drivers/gpu/drm/msm/msm_gpu.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c index 021f4e29b613..4f495eecc34b 100644 --- a/drivers/gpu/drm/msm/msm_gpu.c +++ b/drivers/gpu/drm/msm/msm_gpu.c @@ -335,6 +335,8 @@ static void get_comm_cmdline(struct msm_gem_submit *submit, char **comm, char ** struct msm_file_private *ctx = submit->queue->ctx; struct task_struct *task; + WARN_ON(!mutex_is_locked(&submit->gpu->lock)); + /* Note that kstrdup will return NULL if argument is NULL: */ *comm = kstrdup(ctx->comm, GFP_KERNEL); *cmd = kstrdup(ctx->cmdline, GFP_KERNEL); |