From: Dan Carpenter <dan.carpenter@oracle.com>
To: Rob Clark <robdclark@gmail.com>
Cc: dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org,
linux-arm-msm@vger.kernel.org, Rob Clark <robdclark@chromium.org>,
Sean Paul <sean@poorly.run>,
Abhinav Kumar <quic_abhinavk@quicinc.com>,
David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
Akhil P Oommen <quic_akhilpo@quicinc.com>,
Jonathan Marek <jonathan@marek.ca>,
Jordan Crouse <jordan@cosmicpenguin.net>,
Emma Anholt <emma@anholt.net>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/3] drm/msm: Add a way to override processes comm/cmdline
Date: Thu, 17 Mar 2022 11:21:21 +0300 [thread overview]
Message-ID: <20220317082121.GH1841@kadam> (raw)
In-Reply-To: <20220317002950.193449-4-robdclark@gmail.com>
On Wed, Mar 16, 2022 at 05:29:45PM -0700, Rob Clark wrote:
> switch (param) {
> + case MSM_PARAM_COMM:
> + case MSM_PARAM_CMDLINE: {
> + char *str, **paramp;
> +
> + str = kmalloc(len + 1, GFP_KERNEL);
if (!str)
return -ENOMEM;
> + if (copy_from_user(str, u64_to_user_ptr(value), len)) {
> + kfree(str);
> + return -EFAULT;
> + }
> +
> + /* Ensure string is null terminated: */
> + str[len] = '\0';
> +
> + if (param == MSM_PARAM_COMM) {
> + paramp = &ctx->comm;
> + } else {
> + paramp = &ctx->cmdline;
> + }
> +
> + kfree(*paramp);
> + *paramp = str;
> +
> + return 0;
> + }
> case MSM_PARAM_SYSPROF:
> if (!capable(CAP_SYS_ADMIN))
> return -EPERM;
> diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
> index 4ec62b601adc..68f3f8ade76d 100644
> --- a/drivers/gpu/drm/msm/msm_gpu.c
> +++ b/drivers/gpu/drm/msm/msm_gpu.c
> @@ -364,14 +364,21 @@ static void retire_submits(struct msm_gpu *gpu);
>
> static void get_comm_cmdline(struct msm_gem_submit *submit, char **comm, char **cmd)
> {
> + struct msm_file_private *ctx = submit->queue->ctx;
> struct task_struct *task;
>
> + *comm = kstrdup(ctx->comm, GFP_KERNEL);
> + *cmd = kstrdup(ctx->cmdline, GFP_KERNEL);
> +
> task = get_pid_task(submit->pid, PIDTYPE_PID);
> if (!task)
> return;
>
> - *comm = kstrdup(task->comm, GFP_KERNEL);
> - *cmd = kstrdup_quotable_cmdline(task, GFP_KERNEL);
> + if (!*comm)
> + *comm = kstrdup(task->comm, GFP_KERNEL);
What?
If the first allocation failed, then this one is going to fail as well.
Just return -ENOMEM. Or maybe this is meant to be checking for an empty
string?
> +
> + if (!*cmd)
> + *cmd = kstrdup_quotable_cmdline(task, GFP_KERNEL);
Same.
>
> put_task_struct(task);
> }
regards,
dan carpenter
next prev parent reply other threads:[~2022-03-17 8:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-17 0:29 [PATCH 0/3] drm/msm: Add comm/cmdline override Rob Clark
2022-03-17 0:29 ` [PATCH 1/3] drm/msm: Add support for pointer params Rob Clark
2022-03-17 0:29 ` [PATCH 2/3] drm/msm: Split out helper to get comm/cmdline Rob Clark
2022-03-17 0:29 ` [PATCH 3/3] drm/msm: Add a way to override processes comm/cmdline Rob Clark
2022-03-17 8:21 ` Dan Carpenter [this message]
2022-03-17 15:03 ` Rob Clark
2022-03-18 7:18 ` Dan Carpenter
2022-03-18 15:06 ` Rob Clark
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220317082121.GH1841@kadam \
--to=dan.carpenter@oracle.com \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=emma@anholt.net \
--cc=freedreno@lists.freedesktop.org \
--cc=jonathan@marek.ca \
--cc=jordan@cosmicpenguin.net \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_abhinavk@quicinc.com \
--cc=quic_akhilpo@quicinc.com \
--cc=robdclark@chromium.org \
--cc=robdclark@gmail.com \
--cc=sean@poorly.run \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox