From patchwork Sun Aug 4 07:56:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13752532 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 8B7D9C3DA64 for ; Sun, 4 Aug 2024 07:59:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2711F6B009D; Sun, 4 Aug 2024 03:59:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2201D6B009E; Sun, 4 Aug 2024 03:59:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E9636B009F; Sun, 4 Aug 2024 03:59:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E393A6B009D for ; Sun, 4 Aug 2024 03:59:11 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 95E86C17FC for ; Sun, 4 Aug 2024 07:59:11 +0000 (UTC) X-FDA: 82413812502.18.1A8C3CF Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) by imf16.hostedemail.com (Postfix) with ESMTP id C8293180007 for ; Sun, 4 Aug 2024 07:59:08 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=apYQnpGS; spf=pass (imf16.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.167.173 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=1722758269; 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=leoSzvc1irTIRY4t+RZAVg9wXL8E4KK0Ycetp1tzeI4=; b=Q2wGt7BPy8QhNRn2bVdSm+eUB8e+3w2b2umIGfXHH7Ki50uqGTw1d7Sg5X+PSCU9JhGfqN 2713RZFXqntgLpiClx8iRG2QwGA6Fq+CJ0ypvkjge1UQ5vKLDWJlqizZ33zclPmZqiCulc 0BHYUZtedp+2TaTXfLRQDq5v2r/59SE= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=apYQnpGS; spf=pass (imf16.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.167.173 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=1722758269; a=rsa-sha256; cv=none; b=wx0CKscJ50JLSeQZCRhTr7StsH1cbE6lodFelm4mG0Xf7dKzb0eEjIygbVUtl287qqkOYW uaslbsKpJtQTZZ4Lw9hztxyU0PM9t9b01ybBGhRcdLiAU6Q6N8hh4p5GjY4YK+NiPqnXPe CYBhJLLNUVmnTR+J3ZAj3dmiHH8ZyT0= Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-3db16a98d16so6096104b6e.0 for ; Sun, 04 Aug 2024 00:59:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722758348; x=1723363148; 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=leoSzvc1irTIRY4t+RZAVg9wXL8E4KK0Ycetp1tzeI4=; b=apYQnpGSA5jfg54raBitLnSpMP5DiLjO8KGfkpYSVUra5c0dQ3NVjT7hWtLQhWgiEO VkVjM3tebvAAzCcez1ZsYHBJOP4u3Du2Dmx4JpvZ3fAU0RQa5HI74XeW+wVmMcs4mzM0 0Sg0OK4ahdKtDBgz72ds7/X3tPstDqRMIJBgi+8j8w1me4WcWNLbIO4+sraJp4LChvr1 h9mAd10pnC85vE5SaXJ7YQigE8a5Dbthq/hI7XsR4/HBlU14dMrMeUiifgTZMLLwnfKV 3uPW0WHyKcJpnaQUKMAw3prflNG7EzfSflfblE17drtwU7mbLvao7OnP6v6jMn1LIRVD 42sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722758348; x=1723363148; 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=leoSzvc1irTIRY4t+RZAVg9wXL8E4KK0Ycetp1tzeI4=; b=OE5G0zl/7T/DwBLAgRdOxnAI817JlRwFP07232JQyKzYlJ+VfziNdht0fjligfFxEX JqlDDo012egs7/7oNbx0LfePyNlALLGeJZEwJUdDTR1NB1wLRYewjlt8vr9ZjNeh7lSi a9KNc9dhbI+uW9OJuYq5uaGkKBspDDJrluqEDefF/0lE1YleM/592e++uAvMd8n2vyTQ lVz56g/T1ikVPspAEG3XsXCBnW9VINrNcjeYQ9Cs780XfCvjkf3fokkjw7YDx1aCglrL 0gp2yUiFVMXHGXBD4Xb2TWEMWlmYB8pLGoJ7TNGSh6scf7PmWJQ+0OUySp71yBgocJO/ qwPA== X-Forwarded-Encrypted: i=1; AJvYcCX895FvkJwnRAl0aVe7FuRv0s6+m1tAPILX+iVKP43FALknbUirtDxolERAaGChSuHP830d4FYkrgSQOUv07CztPms= X-Gm-Message-State: AOJu0YzhVKmhTA5wNTvoLON5/Py0supnwcYvrt9V1hbiBLwkLvf57/b6 RqwuMEp8STfjY5LW/PhkPsJFkmiSfXFACY9m/Mu2k4spDrxdSAbe X-Google-Smtp-Source: AGHT+IFvxFD9i5t49STUUYBZ5sy63mPUTCqzaYfVU1LOK5V4jv+UubPbJD8tYCgFeYVMewc026EG+Q== X-Received: by 2002:a05:6808:10d5:b0:3db:25f6:a62f with SMTP id 5614622812f47-3db5580f909mr13121118b6e.28.1722758347849; Sun, 04 Aug 2024 00:59:07 -0700 (PDT) Received: from localhost.localdomain ([39.144.105.172]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ff59178248sm46387605ad.202.2024.08.04.00.58.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Aug 2024 00:59:07 -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 v5 9/9] drm: Replace strcpy() with __get_task_comm() Date: Sun, 4 Aug 2024 15:56:19 +0800 Message-Id: <20240804075619.20804-10-laoar.shao@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20240804075619.20804-1-laoar.shao@gmail.com> References: <20240804075619.20804-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: C8293180007 X-Stat-Signature: j99z44i8hx4sxa8gfygt64trch4gn1rr X-Rspam-User: X-HE-Tag: 1722758348-98511 X-HE-Meta: U2FsdGVkX1+rzHLXXaQQUpoEOzw0M3xAFSzUDTtmAxL7eNzRTOg5QFj2OUoaOX8Rl0AXZ6W9Z9o7GeOuUn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ikkpbtNNufELpl9AOYxjl1l2qUqkSfmkYwiGGBQdJiPRbysU3ABUDDP+GQZRmAUowvVuxLHX+Lp4UdP7G3v79rRlmvBgR4O3BNfCUDCS3PfPg0iZJ48jMxUIAE9dGu3IMikCjRXbtqoayP9OG41f2rHXlEpCgsiI3/dCnlFiCimRnKxPzMhXoZXn6XNEKf7e6F43eghtbzozChDSSNmmvTrvX/ECmKzLuyMqxsFuc2va6SmPLP+WGIv2CsgwINR5ivNqKZAytLDlT/dB0ILoN4AzCOfEMHwp5Dfckg7kSAnpEq1hTqegHJ74vmaMYrtG3dk3BgDJHC04XRwjmfCRAzJqVbJiYx4r8UURR+6oRfUeiI/3Czrt3owu0iw1Y6OklKDO1NTG6dRmDGsN4+k/rOTRdwa/xHeYe8OGdg= 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 __get_task_comm() 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..25262b07ffaf 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); + __get_task_comm(fb->comm, sizeof(fb->comm), current); 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 96c6cafd5b9e..163457a6e484 100644 --- a/drivers/gpu/drm/i915/i915_gpu_error.c +++ b/drivers/gpu/drm/i915/i915_gpu_error.c @@ -1412,7 +1412,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); + __get_task_comm(e->comm, sizeof(e->comm), task); e->pid = task->pid; } rcu_read_unlock();