From patchwork Sat Aug 17 02:56:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13766930 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 DB8E6C531DE for ; Sat, 17 Aug 2024 02:58:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 742FB6B03FC; Fri, 16 Aug 2024 22:58:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F2B16B03FD; Fri, 16 Aug 2024 22:58:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5941B6B03FE; Fri, 16 Aug 2024 22:58:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 3B96A6B03FC for ; Fri, 16 Aug 2024 22:58:04 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id EFEF3C044C for ; Sat, 17 Aug 2024 02:58:03 +0000 (UTC) X-FDA: 82460228046.07.8EAB9EF Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) by imf20.hostedemail.com (Postfix) with ESMTP id 2A0031C000B for ; Sat, 17 Aug 2024 02:58:01 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="nXfd/Odj"; spf=pass (imf20.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.128.181 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=1723863445; 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=PIeMfVPvNi2mFgQGi33u0WiVQIXgvCVnP/JNmg1PAVg=; b=ib0tAQJh4kIc/YIqJGiki648rURBDDYXw7QCc8zOoZ/8OeY6nA+zW18CJBl5BsSFgpPpvE TjzLIpqlExX3E/tcse8HbEW8Owm4s4hnW2ZIFvoN3756x6uz7LkBevRGaCyrs+aZRLn0qb tHt9VoNB0mvIFGVK+1b9A3KfhF7v+8g= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="nXfd/Odj"; spf=pass (imf20.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.128.181 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=1723863445; a=rsa-sha256; cv=none; b=DMCmXWGoCRUz5E+KWVuocEX5ET8KHAJ84WJ3wrWB6ZfyOIIC4pgMr8I4H5OiBp6O90NQTR nPbz5OlpfR1h5pJB0bDHQczOSC39ePRrCGuKRaMAZBuVnAZIxNnoyE+yVMbMclAaZOfbYA PtoL7iTwykGjngpxAx65m35uQASx3fo= Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-690404fd27eso25415687b3.2 for ; Fri, 16 Aug 2024 19:58:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723863481; x=1724468281; 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=PIeMfVPvNi2mFgQGi33u0WiVQIXgvCVnP/JNmg1PAVg=; b=nXfd/OdjAjpT8bw7wx3Phx4wZzuCtf9JwM+Of6bU4NOz9DezWhYSwwllF7aWKzr9gB v/vPcKRrC2qZIR3doiwUhK8quXH59OUORyZVtl7DWsBPDOg61Bl/Qtk3SodHhBNTwqpv OS3cNMWc1b2/nG8/6sC5VIUjdecn/v3lq2fpowxv63iTu5bMH6GQA6LsDTqR0pIAmbLn njbZipbk0ddzGyG5byT8Ktrt/t3kIq3p6XcV/zAsxhtDzzCBX/hJa7D2eTr0q5z0VxxK z7IwhPUBWccM/EM3tvWruI2h8LLjS6Y3jY6P+YaazFN8tzE8ln8Qub/e/U48X+d+cLfC 4DDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723863481; x=1724468281; 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=PIeMfVPvNi2mFgQGi33u0WiVQIXgvCVnP/JNmg1PAVg=; b=l3PCq2OnY0gwvp5+TrDsP9LmUOBslYXcpM1qPPcc+jDVUJCQ6M61jE4B2sQcPIQD26 dnP/kjU1zPr57b2sCWpK3j3W1lrPu9sUonf+EGTpRPj7S18FYUeeordKVdapC7Ii69TI jiKtZf7fQF4OJbLH5Y3cWgIQkaKGLteDmyRsZ+bIsGG+YpISMblCRk6mqPYEpFngLq7a V8tAAxsJ+BATKlJTOseuakcxsdM1dVBO7TiYWZCoU7oAniYKqrL3XjGjCZZDIN/rzWpz oZ9EEBOy4R5xA03afK8mcAwhzegqywgivylOpwXI5tzjgnAAcy1MT8p5fHhpmyw0SwTn bd1A== X-Forwarded-Encrypted: i=1; AJvYcCWYSuEI9u1nceTFVp1abbcbzxxKdSgJm1Tq5CewPrTvvmv1rVxrTw7LFmqF0dwgYqseCFaLQdEtKbtoLcfDih7xxYg= X-Gm-Message-State: AOJu0YxKNPMcv/UOXCrOwyROwitFz9eD1BWuyF9QGmuC21P958He+xn+ AR9s99dJcfN45ZZJAEbLGEgUZSUBN//tY8s3BWpUCF4JqT/nkb+m X-Google-Smtp-Source: AGHT+IHIEqe/Cmg7s9PimPuB+lj47WHhB9AJi/MthWBlVJ6PrU4Dd47Rx7cTZURpMhIAboN0X1uK+w== X-Received: by 2002:a05:690c:f01:b0:62f:f535:f38 with SMTP id 00721157ae682-6b1b9a64059mr67878767b3.8.1723863481074; Fri, 16 Aug 2024 19:58:01 -0700 (PDT) Received: from localhost.localdomain ([183.193.177.10]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-201f031c5e1sm31801785ad.94.2024.08.16.19.57.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Aug 2024 19:58:00 -0700 (PDT) From: Yafang Shao To: akpm@linux-foundation.org Cc: torvalds@linux-foundation.org, alx@kernel.org, justinstitt@google.com, 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 v7 8/8] drm: Replace strcpy() with strscpy() Date: Sat, 17 Aug 2024 10:56:24 +0800 Message-Id: <20240817025624.13157-9-laoar.shao@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20240817025624.13157-1-laoar.shao@gmail.com> References: <20240817025624.13157-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 2A0031C000B X-Stat-Signature: 1ohkcs8reor3ng85tnc3o5n1nmn8wxek X-HE-Tag: 1723863481-618121 X-HE-Meta: U2FsdGVkX18aAGrUHG07JDGkbfOTK/roRZOcn64fnUA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ZbY9kfS401hg7xVRzA9+qAH1eiwCj5nQV+gfnvPvVWelF2K+fWU3SfIAzI1NMm12nP9tmYtVbcmPl8k6OwwH5W7Hz12PbPB4iLsszqdAJERUrAxpZdctCh48u+6t1BioZ/r62JXD04vrQHP8kPhM6YP98mePfyN1sDwBa0iJUO0Z0ugb2gZTUYt608ooOluHcWEANxeOJtxDHZPK04F4wGeYeM4OZPGH6OAFchBATNI7lx74/Y45hWAMYPwG7Fq4sJX9LPR0w8fbChdSlETo0YVqmASr3fZeBPbU3fZU8+KzK7eboLaFFZ5th6S/E6dyUZQeulEfQUa7AodjMcT/9Kyy9iHr24ktTw9JyVcuie+tgzE4pn4InNNobGI29FtzXSlc62VA9/ZjUwko4XOQMO81Jp5x/ 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..2d6993539474 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); 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..374378ac7c85 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); e->pid = task->pid; } rcu_read_unlock();