From patchwork Mon Aug 12 02:29:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13760073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C675C3DA4A for ; Mon, 12 Aug 2024 02:31:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2ABE96B00AB; Sun, 11 Aug 2024 22:31:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 25B416B00AC; Sun, 11 Aug 2024 22:31:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D6356B00AD; Sun, 11 Aug 2024 22:31:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id DDC0E6B00AB for ; Sun, 11 Aug 2024 22:31:37 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A5B00A73A6 for ; Mon, 12 Aug 2024 02:31:37 +0000 (UTC) X-FDA: 82442017434.09.A62FA49 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by imf01.hostedemail.com (Postfix) with ESMTP id D40C240009 for ; Mon, 12 Aug 2024 02:31:35 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="KjcBx/34"; spf=pass (imf01.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.215.176 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723429841; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zZu3KZG3iOINXwUvnWcZKbey2aLH0BWohtl6uQ29mP4=; b=6dgpg57vkTqdfZcP7g6Z7w+6ba/NB2eNELP2YTIqEDlixmLz2niKKnW3MxqcnqwT4Bi+GX P+ujqx6TZIOEHrcWCkB73JkP/Vn9nTw7pO9zXvhCfbgpOKSWEjAfMrg2T4EphWpuy44lvB 0Nx55pcF2WIAKYCi+3QQYEl+I1M/r5M= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="KjcBx/34"; spf=pass (imf01.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.215.176 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723429841; a=rsa-sha256; cv=none; b=tY6xRx9Q4uuuJQ2ld8YU6OUe9+fWXzSa93nDMz+kq5DeyjNjIuqdhgUt0GHrDZddAS3Qb7 Bu6xGH+ftmaeNeQXsdUaTKxh4d61T2N7I4sHJDa2eagkhVKg2PaotSEr5HFBewvyavJPY1 wPGDhUFo7KYHei3o1bmVKbJJVknURJ8= Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-7a115c427f1so2437243a12.0 for ; Sun, 11 Aug 2024 19:31:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723429895; x=1724034695; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zZu3KZG3iOINXwUvnWcZKbey2aLH0BWohtl6uQ29mP4=; b=KjcBx/34zbGQAtPz9V8GBVk3OgIOl4yMoXCaJDBaz5AWXuPybqMJO9RunUmltwZmah 8ZIHvcz4Bl1D0//mLUBT+KSgwf6hg6SGnElAGVgqSkWlYSGfDwXikQZfQAJjIlXEZqz5 lx/o2hDCkkxbx1vRsBNYLFJEorq5L96Vb3iRL/TgNlEmeDtnmKYrpYGWUXxrFrcGTleM l64rC56Gd4baimGVmoE5tEMhdurn3O3hlHSOory4PFYBHfkNm0YzguRyG5Ue434Y8Gci 9yeUTICT5FdB2Bqp7RdhxJJD5LXpDJB/w1DomO5Um2JNEbh7sjFNvrT6J44vC43KZKis 0q6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723429895; x=1724034695; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zZu3KZG3iOINXwUvnWcZKbey2aLH0BWohtl6uQ29mP4=; b=OnqkH0ZcxVe7xMd8/XKPFfYHVFjKg2uMGMJNPZ9UcYZPy+Zy4y8gaiS9xfinRjgpWb z44C9Qj1zDzXrgUZZDHZOU5O4XxsP/v3VIpzXKDURuZddDfL5X8dhWcxlh4c8D4IP6VJ 0c+Sp/VY2RMEZGObiF3iBi2uI6iFYP4g015ZiKc6c8XMA42MzyIxqF0RkptRXTyFAtkG 4HHaBXaUGQ3NJ3MQYO2ov0tTSIXvj+igyJg8jxqaGHkvF4DVpRsnR8SM1GvS+/Zt7Ubs u0kRrwb5CCj/Ows+dT9YeZS09QQQIrikbIZtASOAsl3tAWCWl/+6xnEYRGyCAHxvcrXM dgKA== X-Forwarded-Encrypted: i=1; AJvYcCXv43S5BkOOO+JvszVUIURnsXAL7nyYISQqk9VYAdcdsABTlsRioGbxk9K9BbBR5zpIdnGbIN4WZwWR3BKoAmYil3o= X-Gm-Message-State: AOJu0Yz4RQvDdzxj4osobXuf0AyNYl0ekroBx6A5rJ9RhJAjTmC/3qvp rqjTVb/KRkBPMJKRRrDUH3F+xPFBtBMSUH7T9LG1yaY6Qblwx6ojNmYqxd6FDYdxsw== X-Google-Smtp-Source: AGHT+IHdX1dJ6B1gxMt4DoIS5gsxO+K0m5bSRRhjzARSl7z6wL1zfkA/bgMgo4cA342XfY8E/QA2Rw== X-Received: by 2002:a05:6a21:b85:b0:1c6:fc56:744 with SMTP id adf61e73a8af0-1c89fd26229mr6526380637.31.1723429894568; Sun, 11 Aug 2024 19:31:34 -0700 (PDT) Received: from localhost.localdomain ([39.144.39.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-200bb9fed69sm27884765ad.188.2024.08.11.19.31.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Aug 2024 19:31:34 -0700 (PDT) From: Yafang Shao To: akpm@linux-foundation.org Cc: torvalds@linux-foundation.org, ebiederm@xmission.com, alexei.starovoitov@gmail.com, rostedt@goodmis.org, catalin.marinas@arm.com, penguin-kernel@i-love.sakura.ne.jp, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, audit@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Yafang Shao , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Subject: [PATCH v6 9/9] drm: Replace strcpy() with strscpy() Date: Mon, 12 Aug 2024 10:29:33 +0800 Message-Id: <20240812022933.69850-10-laoar.shao@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20240812022933.69850-1-laoar.shao@gmail.com> References: <20240812022933.69850-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Stat-Signature: 9yq6bp9zgw7k3ts8in1cdfq69ebmuwzf X-Rspam-User: X-Rspamd-Queue-Id: D40C240009 X-Rspamd-Server: rspam02 X-HE-Tag: 1723429895-513726 X-HE-Meta: U2FsdGVkX1+rOaJzjzQ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FNJpv6ix6sNdyt4MMYs7qWF3xZbeUpbE+PxbAzazJ22YeVlvF/jIjA9RS84KPHG2I4mItcwjmjymQR1e4uqMPhaqWkQG2sHXj+WfjtjNtp5+dR0xRlXygTB+KcaQq180wQ9bKwroP39Iyk+FFpg3+eC/l5FAv5K0KE3nf7cp85GQ54Qry2+g4CTlQj9W4X4VGhGlHTvFlclNjHJSuX/n72T65EQo2QIBJy2IXXgZhBRBz7Q9j8f5fg2HbvojKFg9csh1VPyfH1/4ugfyxAHLxQ2b1qpKzKT8Fc0kXhfOr9e0uu35WVYTnAue0D7aREfqUEpr1q9KZJXkFkLxSmWF67VVL4/7z2WnfgpuN5xBR+Fljdi96f2m+66JJPlVmHXTcO7roBPnd+KBFc3M8o8RKJmeyKP6cKcasKVSj3n5SjdGa9wkyjEfM X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: To prevent erros 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. Signed-off-by: Yafang Shao Acked-by: Daniel Vetter Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: David Airlie --- drivers/gpu/drm/drm_framebuffer.c | 2 +- drivers/gpu/drm/i915/i915_gpu_error.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c index 888aadb6a4ac..71bf8997eddf 100644 --- a/drivers/gpu/drm/drm_framebuffer.c +++ b/drivers/gpu/drm/drm_framebuffer.c @@ -868,7 +868,7 @@ int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb, INIT_LIST_HEAD(&fb->filp_head); fb->funcs = funcs; - strcpy(fb->comm, current->comm); + strscpy(fb->comm, current->comm, sizeof(fb->comm)); ret = __drm_mode_object_add(dev, &fb->base, DRM_MODE_OBJECT_FB, false, drm_framebuffer_free); diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c index 625b3c024540..97424a53bf9e 100644 --- a/drivers/gpu/drm/i915/i915_gpu_error.c +++ b/drivers/gpu/drm/i915/i915_gpu_error.c @@ -1411,7 +1411,7 @@ static bool record_context(struct i915_gem_context_coredump *e, rcu_read_lock(); task = pid_task(ctx->pid, PIDTYPE_PID); if (task) { - strcpy(e->comm, task->comm); + strscpy(e->comm, task->comm, sizeof(e->comm)); e->pid = task->pid; } rcu_read_unlock();