Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp545412pxj; Thu, 20 May 2021 15:52:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZ4BSD57RSwaYrM3cB20o4FrizOjkQUq773uo+WrCWpj+Juu2yN/ouEzGsLfLSbKIDsl4S X-Received: by 2002:a02:6d13:: with SMTP id m19mr9072617jac.65.1621551120194; Thu, 20 May 2021 15:52:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621551120; cv=none; d=google.com; s=arc-20160816; b=v0spNEUeK51CQzc6zM1xQPyLA40qcJbI5+y4BLB+a6fehCVtlHfTU1eLDJt5ZuCaWN mFS1JDMjLFHr1qNTqzEARBUb7/992Sg0BnFCAWwNlkQpBMxx2JeYVLOCKbJ7Imb/GfHF VNfUzXUi5JeDme5i7+zHDKYVXXKRojIfNsitdu6rPBbrj3qKyltzWK/ncpaSnuOYmODF 62ouezbNZcoOyYivwJlJWZPbRS25mSmZwGJcB6JTafKvMH8jfOc1fPD9EAvMmue2Le3L DPUF0bH1Hy39LDRs75SH/aHXZ+qCVqd5GDVQ+Gi4jC2tn1+nTBPfj2IgUbZ0ERN53/M2 tnmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0hT4BiwFZ10fNleIoJsCAfRQOPNpZK6DYP0aR++Xh6A=; b=gmxQ+wxANeRGzgjagDq5qwA0Ap8gmrJTxrffecmb1/W3Gc1d/RTvzKBlAW7jML4hK2 py2UIeGAUpe/FOqeYVFAJTn2gC9G0Rs+qhGpD8EfjcBAbFOllHAClZRbr8ORmg90qqbR 4HFhQEHd2pzW3Kjt4yoadHmP46VJ5dqx62ii7a3qPCSKsT8XZFC1DFmXfwSc+5YP8fNT OdNwFiNZ5+4MjaOysO3N6zdx7qWEiXDNTPaUTauByYglaXOFrp9Du8HZBwdW2moRVADR xW/yuiK2FRpMR+HjuKuABBzZkK8xZ2+W/xXpKeDxoLjN+Z0xHTdKGoH/kr2ktOdRstI7 0fSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=beGOulgw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o1si3895752jat.48.2021.05.20.15.51.47; Thu, 20 May 2021 15:52:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=beGOulgw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240553AbhETLOm (ORCPT + 99 others); Thu, 20 May 2021 07:14:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:52614 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238958AbhETKyW (ORCPT ); Thu, 20 May 2021 06:54:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3D41A61CDC; Thu, 20 May 2021 10:00:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504857; bh=xkd1Q8CSeWpBA7drdtVw5G4L7ki6h1sqEX7D2Ik1PMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=beGOulgwFQvBsja9zL1/CzIRukZC150FV0Ws4fi4/6QYpCqfVsxVopEWBUiQIUm3t vKhuKpoMCloLhBZ8otD9EkbgOQQjamM8tObM26m6RF8uYG4Q1PTAJs5cprUx+xZ05a z2t6PIDNleCi40nVfIU7hKtHiQlA+Xbo2sAa95lA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amey Telawane , Amit Pundir , "Steven Rostedt (VMware)" Subject: [PATCH 4.9 077/240] tracing: Use strlcpy() instead of strcpy() in __trace_find_cmdline() Date: Thu, 20 May 2021 11:21:09 +0200 Message-Id: <20210520092111.263634972@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092108.587553970@linuxfoundation.org> References: <20210520092108.587553970@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Amey Telawane commit e09e28671cda63e6308b31798b997639120e2a21 upstream. Strcpy is inherently not safe, and strlcpy() should be used instead. __trace_find_cmdline() uses strcpy() because the comms saved must have a terminating nul character, but it doesn't hurt to add the extra protection of using strlcpy() instead of strcpy(). Link: http://lkml.kernel.org/r/1493806274-13936-1-git-send-email-amit.pundir@linaro.org Signed-off-by: Amey Telawane [AmitP: Cherry-picked this commit from CodeAurora kernel/msm-3.10 https://source.codeaurora.org/quic/la/kernel/msm-3.10/commit/?id=2161ae9a70b12cf18ac8e5952a20161ffbccb477] Signed-off-by: Amit Pundir [ Updated change log and removed the "- 1" from len parameter ] Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -1875,7 +1875,7 @@ static void __trace_find_cmdline(int pid map = savedcmd->map_pid_to_cmdline[pid]; if (map != NO_CMDLINE_MAP) - strcpy(comm, get_saved_cmdlines(map)); + strlcpy(comm, get_saved_cmdlines(map), TASK_COMM_LEN); else strcpy(comm, "<...>"); }