From patchwork Fri Jun 28 09:05:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13715786 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 7C082C2BBCA for ; Fri, 28 Jun 2024 09:06:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 116BD6B00AE; Fri, 28 Jun 2024 05:06:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C6FC6B00AF; Fri, 28 Jun 2024 05:06:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA9A56B00B0; Fri, 28 Jun 2024 05:06:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CCB316B00AE for ; Fri, 28 Jun 2024 05:06:40 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8D163C10DD for ; Fri, 28 Jun 2024 09:06:40 +0000 (UTC) X-FDA: 82279716960.10.7E177E2 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf19.hostedemail.com (Postfix) with ESMTP id B2EB61A0004 for ; Fri, 28 Jun 2024 09:06:37 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="NMv/nfRZ"; spf=pass (imf19.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.178 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=1719565579; 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=XMEnxwp1NwTLoCnwW+6eG8hAcM2IfrhUw9F+x6RJ2CdrxbpykHATTiKNHPBTmlUpu1yIwd F+zGitlOL8HCmBi008H1LH0VH1+BPXAH9xBBMA/6Qc9jdKTifSbzRH7XeeJvmqrXv926cY Bsqa5vrem3RBF+4zkxhdt+og/AjoRlI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719565579; a=rsa-sha256; cv=none; b=E5oLUEkgpjdiQgZ16qYXC4Ej5TlX0ayN6idP+eOXI1dr/8dy6ctXkqGS9PHJEp5NWd85JJ Avi0iMpKo9TTGQNVQEvO9PS0KMdY0htkB1bisZhlOBIKIDUHHbMvWgzzaulcflWgT+YJq0 Tn+V0twsh59Vu408EfUKLMuMMrP/GyI= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="NMv/nfRZ"; spf=pass (imf19.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1faad2f1967so11843895ad.0 for ; Fri, 28 Jun 2024 02:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719565596; x=1720170396; 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=NMv/nfRZ6aU7o+FeWr9svZnFWUHvL4b+W/rv1DX2Y5BjnbGabn6HMKV8na47R6Dsny FSm0ruTCw3cRq1lrubo7Sb8+mwSswK3PK7mTGaU9Sjdv2Aq3RzvH77fSSeKHSYrcHGCq C+I2vS3utY1i1Cv/uLr38ak+meBI5QzDrhHtq4O5siLlWJ/KUmFmPIZb+iYvTMdT5Eyh k5jpcHLjyxk99zGJAcy0puNkk0VS5yFIVEIHwgof/sEk9mcR1FEsc5SP5LLCLNmzn8S6 jfv4cjU+mGckjp7NQNfJaiQDm0L759F7IPqpWavGhPWH9TWW3AgL/v9yBIwpQ25O/8il jtaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719565596; x=1720170396; 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=JhXmSj3AnskEiKLBloFJvYgllkB9wGkMPCtGq//yEC1qm4s2z8ye0vEUsp8ifP87M5 bgGTq23Os5uIDEtmA+Ij4fxl7VvJ5gM76ybXIp6PrK84wmOcmlTqGXBJ1ytnc8n20p6e xp71LJFWuRk5wIjWg/y/xSEqLtpPlt8jYQAAGxNu31KpoqNzwgjtqLpVSibevddRfw+4 kgP+b6z/8Y1NRltb8CjE8R7xloqToCQ0NqHeLh5ZOATC2kAtZ5FKXTRpbqPEhdOxpOFc 4pS4YDbHc1qjRynD/wIWI2jLdDrPCosOWCzfi76G7jlpB70YzP+yfRXkA3j3OOGZBDl1 jcaQ== X-Forwarded-Encrypted: i=1; AJvYcCXmKWTLY9bfi/8VY8zefV4Dvg/IrnDvAFPxVo/Gb3CRShXQDFSchp4raadWmMd46QZNhBuoeLqRcWdFj1rE72F9St4= X-Gm-Message-State: AOJu0Yzg+S9uOh0J8PtOdQs+GhCMepjLqOFpeDm/KhksE9l1wHh65lx0 hQE/Qz0ZKjnSC+df3w5IqrYa9qD6pevhaYlU9YJ7FyJrME4lz5Ha X-Google-Smtp-Source: AGHT+IFavdIVLnysCQZL38ewD7/CaBekji3/EpakpMEZSkmUhyVQ9iiqTWsp/YgBhmvk5fMqdYz2hg== X-Received: by 2002:a17:903:244a:b0:1f9:e3fa:d932 with SMTP id d9443c01a7336-1fac7e975ffmr17035345ad.9.1719565596545; Fri, 28 Jun 2024 02:06:36 -0700 (PDT) Received: from localhost.localdomain ([39.144.106.153]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fac10e3a1dsm10473085ad.68.2024.06.28.02.06.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Jun 2024 02:06:36 -0700 (PDT) From: Yafang Shao To: torvalds@linux-foundation.org, laoar.shao@gmail.com Cc: akpm@linux-foundation.org, alexei.starovoitov@gmail.com, audit@vger.kernel.org, bpf@vger.kernel.org, catalin.marinas@arm.com, dri-devel@lists.freedesktop.org, ebiederm@xmission.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, linux-trace-kernel@vger.kernel.org, netdev@vger.kernel.org, penguin-kernel@i-love.sakura.ne.jp, rostedt@goodmis.org, selinux@vger.kernel.org, Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie Subject: [PATCH v4 11/11] drm: Replace strcpy() with __get_task_comm() Date: Fri, 28 Jun 2024 17:05:17 +0800 Message-Id: <20240628090517.17994-11-laoar.shao@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20240628090517.17994-1-laoar.shao@gmail.com> References: <20240628085750.17367-1-laoar.shao@gmail.com> <20240628090517.17994-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: B2EB61A0004 X-Stat-Signature: 14qeyxdfwdsyi6fgrn3cp5dw9mc1jd3q X-HE-Tag: 1719565597-399934 X-HE-Meta: U2FsdGVk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eSOBN7vs1Yw+RpA+A8BBL0rJwutVhfkqvqTMwGERf4FzS/JSBBBmR/P7Hv/7X3/Mql++Y0rVpU+5hIGBmKNlNxEANNaTJbke4wPbsDrXS8XoZBzQR86dGg8PIVmJClIQVLmnMexZvktO8aiwoy+PZFD341tDBirSIMsTlvZ2ykz0f1mtXRVG/+3YUZ2rkzNsJJJHSUvZNwDW1axw/ZJeYlMWh78V9viBEyYo5SNbnWnmAs+c9YU9NR07nsiXmtjaa1DmvGViZeoq9MTzRTZE9xRTYwAuJvhfWs6Zkki1GFhpQ0yE6c2QVwemP6MLWN/JndB7RfjTyfL3rKWjoEMylEEGLk+WZuR0hsmskeoUzknSnQq7YvlWSONSVnYXI67LOAeBlGYLbxtpRNEjV960JL9QQBdxmvmV0VvXODvH1bJe9haLIC02+XaucP0X9SY8UtqmQbBJUQEHUy/5Vrqe5Jva0Qda7j+Vs2vmDw= 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();