Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp61160pxj; Thu, 20 May 2021 04:35:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSqMJ3lGN3YsN031DZP0SgxjAsUUHBYp592qM2BsMshIPsJwnGzjtT0ugnbWT9h7oeHjSh X-Received: by 2002:a17:906:2f91:: with SMTP id w17mr4260790eji.443.1621510550492; Thu, 20 May 2021 04:35:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621510550; cv=none; d=google.com; s=arc-20160816; b=t415210Qn6dCkjAv+UFHi7aL/+hytMdkHiE7Da+683TmPAJn+WnBQmT70WtTLB2nIN QC971vtsG06lU0KguXw7S6espbVTdikyQF4FkYnrfPefm4tMKPSEO0bf4jlwIjuLqadN gh5180sAvsnAPbcW2bnFYESjF9pQzRZWJNbOdI9OKYcZQleaAjWkGorT88NXLAobCKw2 EJ9ycXya/0RHrMQspIIMgy0SeOV7rnsqGsh6CwWb3J7/W/8M/TpsGWy0Q/YYvOCGVc1U ErF1H1lv1PeOne68GIOx7f7QtH+GWenXcp5aN2nuZJxNufq/Z9+Ca7UjBdTbhPxk49rh a/jA== 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=qA0iolyqI7DWGa66RqEPSkd/cZIlt6nvb1PIIk9XRDQ=; b=ZK4H5ji/fNDS312qf/Ys4aY/WEBxsQP6R/uYt/kfPmgdq1yUc2ZBUSXDIGEvByv8z3 bu07Y3ApZrAJgzZAXXgU1A312Yb3uWuDZY7RTzBBWFVre4eThMOfmM0lMoqDpTXEMbU+ 9VPLRYuzSpaSATiatvE8WzW++L7vSD1K+llECVBlmVFpYyj2PhYXnqLfZivBR4+XHpTL EZKZ31ntifNwBuRV+jUGLlTpVEboURtJewTWMtNIJ0Wf6vQYce8EYWVN6ht8PV9QqMyo ZjwZiEmTuugB+hOgJzBJXNEOFVqoV5BNFowygXaIPcT5+gYKq8zN35hyYipIPdQz71lh yrxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FLuOk3UG; 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 jj22si2347774ejc.162.2021.05.20.04.35.26; Thu, 20 May 2021 04:35:50 -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=FLuOk3UG; 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 S240837AbhETLdX (ORCPT + 99 others); Thu, 20 May 2021 07:33:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:37104 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239310AbhETLM7 (ORCPT ); Thu, 20 May 2021 07:12:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8D38461D54; Thu, 20 May 2021 10:07:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505276; bh=NWWSEeeuIpgMz+Y8gRP6DsMV+1QBDrRdjqXUeFocN84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FLuOk3UG6Pv1h8GSUf8hcNcUJfkypeDoCcg1w18UsgI+ve+96fdnnQOaLChccBbCV Xgu0o8KmVpwqvh/+P3QZBlOiqpwKomYezc0YyiffdDXY5xiU7Vp5hbbmus7rGpXFeG zaAIcAg9rJG7q9MB5plbKSj2emNmnbvaqOdb6cis= 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.4 061/190] tracing: Use strlcpy() instead of strcpy() in __trace_find_cmdline() Date: Thu, 20 May 2021 11:22:05 +0200 Message-Id: <20210520092104.180142592@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@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 @@ -1624,7 +1624,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, "<...>"); }