From patchwork Mon Jul 29 02:37: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: 13744305 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 A7FE7C3DA64 for ; Mon, 29 Jul 2024 02:48:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F4BA6B00A9; Sun, 28 Jul 2024 22:48:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A5C86B00AA; Sun, 28 Jul 2024 22:48:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 294926B00AB; Sun, 28 Jul 2024 22:48:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0AB596B00A9 for ; Sun, 28 Jul 2024 22:48:18 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B74381602A8 for ; Mon, 29 Jul 2024 02:48:17 +0000 (UTC) X-FDA: 82391256234.28.1C111F6 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf05.hostedemail.com (Postfix) with ESMTP id DAE9410000B for ; Mon, 29 Jul 2024 02:48:14 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="Avy/g0t9"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf05.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722221255; a=rsa-sha256; cv=none; b=NoT4Vo5iLpghMkg1ILmhxRVaqO3zOJEOEhLiXyjJXG7Uq1qy04z+El3ZxdIsRVSP1w8/SC i+no8TTHmO6/SNvnb3LZHMRuKZcQ31B/hrSxGkfyI01rDHpRD9j5T322IMSsHlGX7Eexzo HgwpM0wTJOiS2SFpCiubwgeW98hljn0= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="Avy/g0t9"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf05.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.177 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=1722221255; 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=uws88M38Us6mZwthahlWUK7fM6+CMa7f0lHdNpc5/ec=; b=4YtBmnwPlBwi7HcU3T/JOkdPhhWg44Bn9ZtHMi/E+83MexKnJbGzEsEiVz3ibQrOKDPeyL vOokAPKNzVZoVRdhwCjN0b+kQjDOlUrxuRnVAOv6VcrNL8/hizRKTL6ngTp0E/8sNSWZgx QmFs6Jfm70t5yAlpMfmALLzIIw6tC0s= Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1fda7fa60a9so23399915ad.3 for ; Sun, 28 Jul 2024 19:48:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722221294; x=1722826094; 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=uws88M38Us6mZwthahlWUK7fM6+CMa7f0lHdNpc5/ec=; b=Avy/g0t9cPqUu7eOYyJHosHqYXIOffLMNW0a5kFSdgizUhOhV7sfTafXVXNZsbU/sW TJa/+4PQaY/9O+MNuYvDRcXbrTMT3Zx2mxF9ChVsgC43mbeifH7wfqZb1My9RmirklZb cEbq7J7swvCxnuQK/C01wxopYJtvgm9TVCHZnvTu41rzktv5OethPAvOVwS92IlRxU6V +A8KfUhqZOWpBAeWA3ZsKMDQTTjn+AVv2loF778s7UGer2lSpB3QONNRmc7Cu0Cfpeks GAO9fAyCmoQO622XMJT9O7aoXKK5u2hBf2GYf2+aAKdV4oZWtV49VH9xB6JKITbmBhBd wPZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722221294; x=1722826094; 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=uws88M38Us6mZwthahlWUK7fM6+CMa7f0lHdNpc5/ec=; b=qmi/XuqrYotoqVvdhzSz9qb+s1ChTI5h3QRAm1lUJyyHWpYtvkzU32G5CnIU/TxqXq lbRwaB3xoHky29rYEOOBgiV2yKlP4bWJ3xBpw9nQncjWRnLbdlw306cfr155eVR106J7 QwDdXbgpRpIo10IIyi9eqxGAR7ZqW+nt4l6+sWHgqMMUQ2Nv9ZCz4SEJFQwqCE/41gro b4a+8Eh6XhYjVi9oDdX7hr927ZJuMptoZGDTg0dLV2bQ2ldJ9jhUw9gLNcrRNLtU/+n9 neRbgc+mYRcVSsmK3yUuyuFSjCSly6JD97oBiiUKXJJ67zbI6RWvPQ+CAa/hL5nMKtYO SmEg== X-Forwarded-Encrypted: i=1; AJvYcCUqDdEc2Kt6Eur0t3zAm8fFq3nNx4EagnHcsJZ9vhttS8e7/DbE807q/yD2NZXj/7K8+rngTsF9guE/vb9LMX3oY14= X-Gm-Message-State: AOJu0Ywv06gxwm0rClTRjRIaJtArlwkbu57wa5V90IjSiDjlx+DYYBKK k80CwjltC032psPhL5N2HaJgqegmElZrBxhJi9Rki82/lnI4/YKP X-Google-Smtp-Source: AGHT+IGofcCeds74VK5yzpBY91R2MnaRyI1ieEFwQ1nBe/Bs8+j0QLJHRaMLwHU9stQw4nuIemwGyw== X-Received: by 2002:a17:90a:888:b0:2cb:55f9:b7c5 with SMTP id 98e67ed59e1d1-2cf7e1df02dmr7584677a91.12.1722221293603; Sun, 28 Jul 2024 19:48:13 -0700 (PDT) Received: from localhost.localdomain ([223.104.210.31]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2cf28c55a38sm7332247a91.10.2024.07.28.19.47.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Jul 2024 19:48:13 -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 v4 11/11] drm: Replace strcpy() with __get_task_comm() Date: Mon, 29 Jul 2024 10:37:19 +0800 Message-Id: <20240729023719.1933-12-laoar.shao@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20240729023719.1933-1-laoar.shao@gmail.com> References: <20240729023719.1933-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: DAE9410000B X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: xhwizgye63i459hde5mwbgsckex5dxdu X-HE-Tag: 1722221294-279621 X-HE-Meta: U2FsdGVkX1/fto8oyfEZOFddc/Qz4olf3nqZfpCILOoMaJjUrFVgBIK4opDSNnfPOf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B/axzWsRDRJ/3kf9Zx6JHUImQhlAF53bSgmhiY+COKVyR11xtmc0gNxxB0Mfs3TDYAxfVKSHG8MpvQlDRVjeEf67GRE9xi6ZXFrdXJI2HqhBNzKZieAzrWW/16+/S2IVgMfbwOQIV/GbyTbW+vQVSbwFMLLIG2KkMtSzAT2mSMfxocYx5Mnd1o/qbsvYUG77SrfO8F+3Pu3qTaHpJKpYV4WTGMoRsXhXrHg2ft6aWOsK+RHqRpdBkNfhM3zYxR97RQuncUw1YDOxbIYTd/Ck5zbeS6ROnbySwQEES1Ny10chgPncYdJ45UW4dJBcx7qqDeq71ZxXMeBycOw+pYNlrLSY0wCzIR2K48ZXM9j9Xw466N9dgLgzyDPqYgyQ4WQ4wFUBzccXTaW5TjsqQeiV5ucLz4vIbg7aTWVSHWCy/KGG2R9MEtgMxC1YYvrtwAo= 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 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();