From patchwork Fri Jun 21 02:29:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13706758 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 DC7C5C2BA18 for ; Fri, 21 Jun 2024 02:32:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 66A8E8D0122; Thu, 20 Jun 2024 22:32:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 619738D0111; Thu, 20 Jun 2024 22:32:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 491AC8D0122; Thu, 20 Jun 2024 22:32:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 29EA48D0111 for ; Thu, 20 Jun 2024 22:32:54 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id ED153A2432 for ; Fri, 21 Jun 2024 02:32:53 +0000 (UTC) X-FDA: 82253323026.29.125747C Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf29.hostedemail.com (Postfix) with ESMTP id 1717D12000F for ; Fri, 21 Jun 2024 02:32:50 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="G42c/aBc"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718937163; a=rsa-sha256; cv=none; b=Y/RcK5o5B/sVnOrSk87l5MWMQnet9EBblcSuOFGV8JmVxNP0Z4dZEo7FhTtiqvQ/5vlOC4 xlRNvsJzzP/ri6wtDEG/ajgG0ZyM9BrRh+OQQC4ZQmj9NtAxnD2zUIGTwCYINt4H+o9DlB xpVvwZwPBZxMaXjOnzFJhwHiDo0AyAU= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="G42c/aBc"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718937163; 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=ByPZqEdQZBBtzQ6Ut5Ro8SR1Vw4SYts83oZvgSR+UR8=; b=wehLAVuRLVV4Lfli5I7g5BgSRFgB8ZOGmpEeEqOsPzjlfI0ziT8zz67jull1zwfspO0n41 bI3liddH3rvkWH4xNvGKtI3/fXRId7YDLxlFanv3znN3A6y6FFqoJvFkSbPaMUefkFaMRd BOTLUM7pCZ4mHZy1yAHFR+3GNTRDp1o= Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-7062bf6d9a1so1241643b3a.1 for ; Thu, 20 Jun 2024 19:32:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718937170; x=1719541970; 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=ByPZqEdQZBBtzQ6Ut5Ro8SR1Vw4SYts83oZvgSR+UR8=; b=G42c/aBcs2hbclrRGv++ozCjSFv4PnL795F2CD/h1SZirIzsn8VeH3j1ur7/xdTYq3 P5sfi6Su4ytiqpb6vzgXXZjBvq43sXSER37L4NKmnsuqfBWFXw7BiQIoeBtB9nj2MPTr jQgW6rUcTDf4oaPGt8XiOQeAfByicSa0KxFOwMX5ZmL1blhd46lTIwiUVeS1JF5Z86GI bH8d/vHWX6JQDBoCGfHtkvierY8Fo+2exGdomBzbE5RzZKm1Q1F4qlJcV2iSJjJB5/ex xPhTFFcol2aZ/AUOAOkneB+dPmu/L+ddBlTzSN7x4aZYFAbxq/aI2T3dzvrd5XAmH0QM jw5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718937170; x=1719541970; 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=ByPZqEdQZBBtzQ6Ut5Ro8SR1Vw4SYts83oZvgSR+UR8=; b=gxcQvyvHBumOkGDzr/WaQWhilH5MEV5l3/WlxRFEtexukp72NzmR4T27are4hfheTe 0clsG6yic2KVng87oqiSENRNDxvtfuAWVLnKgqfwEwInYv5OxUby1EgwThRhhFi8vxN5 T0Apa1q29yGWHQyLD5nSnMrZ6rxLpuwJFQ9VwVDRoQHVxJzcNm7Lf+GG07jeyGzkgkd6 WV1WLyM1NLwUJIgsxDFZWcViJ3HR8N+N26NAxrIRKPNGdb3hZKENHOjcqogFQEE7st3f vsgwH6luicyUFHOsjPTuZ0V6cwAerkyEznlJO0kblQSVJ6qoiWfNLwzGl+eHfQJ3PeQK CCCg== X-Forwarded-Encrypted: i=1; AJvYcCUoH/1Qa0bwBKOkqv2GzRrR1nsR73FjtxQTIuaQphVryfTzTG9Sx0mwHnt+M6K9b/XBqe6I8u8BqukIDRVw5qYJ8Bg= X-Gm-Message-State: AOJu0YxNnu3pBNGYjgwnda4h75MGrWuV9znXHAhDw42hNT/jVQkLiMll 02to2vkKUqIAw5jBUqR1XYvpSTcb+DiCkk6hcyiWtkLOVTa7tG2e X-Google-Smtp-Source: AGHT+IHwLzKazOZk9J+TnuaENF2GrO7T5JApXVTdzZDurk6fW60Sg+sw/brS6M3qBlKISuVvI9yc+A== X-Received: by 2002:a05:6a00:4d91:b0:6e7:20a7:9fc0 with SMTP id d2e1a72fcca58-70629d0d58cmr6849890b3a.34.1718937169948; Thu, 20 Jun 2024 19:32:49 -0700 (PDT) Received: from localhost.localdomain ([39.144.105.24]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706511944d2sm332488b3a.70.2024.06.20.19.32.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2024 19:32:49 -0700 (PDT) From: Yafang Shao To: torvalds@linux-foundation.org Cc: ebiederm@xmission.com, alexei.starovoitov@gmail.com, rostedt@goodmis.org, catalin.marinas@arm.com, akpm@linux-foundation.org, 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 , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Subject: [PATCH v3 11/11] drm: Replace strcpy() with __get_task_comm() Date: Fri, 21 Jun 2024 10:29:59 +0800 Message-Id: <20240621022959.9124-12-laoar.shao@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20240621022959.9124-1-laoar.shao@gmail.com> References: <20240621022959.9124-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 1717D12000F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: wr7tjj3dequ8izoa7b6s1mksos6zwxjp X-HE-Tag: 1718937170-740880 X-HE-Meta: U2FsdGVkX182HLhOajkzJ9zVy+yFB9vlphPXXqL2/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0Epa69k/gE7oKS6Zeo7kWEQJy2qtiSmHT32bAB5Wyeq64yfh49ERGfPQu3vMvfYG4Rs537KG6lbaEtOqB5i8l6Ch4sm9BdXdqT/7I4SvQhCwzPQAjEv8kZy+eCXOq0JOayt5bmCHHsPRHhdBsnvTYIUqZ2KlQpS5j3Z+1zYpETeGTImwY2P+DL/q5bbaRha3Vfk8ZJyC+7wl//IIZllAf1UC+IfJ/idXhoEQqjhqRxXH1kwjMXCUm/gjxEUJoSTxnyq+69SJYHJyw0LCQWM1cqz2VkyR+BW7LXovgH6YRaxqFwb2Dlsc6A1qyABThTa/0ocddzkd6fh+kckTZHWSdeeEL+UghPC/SglVhUV0qyFRgsKoeqlPDCbQ724liQGJf6rH+fuFcHZjTVtWvj2RyrTlbhBVGXSGOlesNe53ixN6dEJt5Qvp9jdETaYZc+1qXPwIG/f3i/WSmuwxI4= 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 Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: David Airlie Cc: Daniel Vetter Acked-by: Daniel Vetter --- 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 625b3c024540..b2c16a53bd24 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); + __get_task_comm(e->comm, sizeof(e->comm), task); e->pid = task->pid; } rcu_read_unlock();