From patchwork Thu Jun 1 16:13:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 100947 Delivered-To: patch@linaro.org Received: by 10.182.202.35 with SMTP id kf3csp833789obc; Thu, 1 Jun 2017 09:13:52 -0700 (PDT) X-Received: by 10.98.106.199 with SMTP id f190mr1744910pfc.41.1496333632641; Thu, 01 Jun 2017 09:13:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496333632; cv=none; d=google.com; s=arc-20160816; b=wPtnq0eaDW16eXp0XaR5n99X6tnIDgLNj+/27H1wOQ4l880I9+/VuE4DjFNHJVbXTB rDIiIICaaeXXQyDnJ9Tdc15bWC4qVzOgNi5sGPhr92c9yNDLL3gOO77+9Oc6pvN5ttgL ME9B2Y2Z41oxTK6rHbGlShtEtjVlCXgWWjjgbeCAuJrxwotjb6B3+DtLlu6Ys8TmpmbU lEKZzne2gWl7iMNUOV2sw6RY+vm8R1VPiCI/MWaC/vsHzUOXqsNcXYn+E4TGqgL+ubi4 FccJ9GHae2aAQqwoE4I8sreyJ3onUjp3ZyvULyRad3DIOGy/z4XJakBxgg5AorQZyko8 ztiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=l4MHSwN/dYqMaHxvx+uCdxgXC5c+bechp/1lTTWEoz4=; b=j5reN22/Z1+mAkaNDZUeyUcXUVRtyI6QjK+awbfcVxxNg1ZXcX3cHkHqzYiwQvgX9Y g7fJOBh3c8AasWrF59T+GHbWDCPYDv1RbUusK2NAmapEFmSKZm0/TGO+7T/ei22a04Kh HjkfCov+yO0L/m+nGxGE3Wrpo2R+7fpcS2PmKGt3Lh3xu18EsUkuafqsUGiy8lyI0rIw YCk4fEGXwOZqFo01jxsRXf8m9yDyqTwll+HOHout/21eZl8fsPhmwf88g0EJxKFpBQQs crqSyVwWCDFAlC3L/5PByP5GxarWLfFqBVwlB3VdAVfuSj7qYSYu6tiVyjEqxQx/Vr+l W1tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h79si20603959pfh.1.2017.06.01.09.13.52; Thu, 01 Jun 2017 09:13:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751331AbdFAQNu (ORCPT + 6 others); Thu, 1 Jun 2017 12:13:50 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:35247 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751157AbdFAQNs (ORCPT ); Thu, 1 Jun 2017 12:13:48 -0400 Received: by mail-pf0-f170.google.com with SMTP id n23so31293187pfb.2 for ; Thu, 01 Jun 2017 09:13:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=l4MHSwN/dYqMaHxvx+uCdxgXC5c+bechp/1lTTWEoz4=; b=ChWdEsaS1/SXMcFoTW958wV3s05DKjVk2UxltKfY9RLjQFFhDaYrfJMVYfgb3dg2+c 2AcgcahrmrFdJ4JfgPDS95DUHjHb2V//0zSQC0j6b6aemBciV2aN1hg4hajN6g8IWH8s Ll659+SeKO2NCKa0dZxx9ZR8Hz7friWpMXACM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=l4MHSwN/dYqMaHxvx+uCdxgXC5c+bechp/1lTTWEoz4=; b=RTay7DB2bQ/X264Ocjy3YdUxbsq8A6F/sMWVG7ksnH8opsxmpYuGzVtYDzotZmkXai LxezFrEF3jl4MFWjxtjhVa3TJWaXqaEjQi1GWiggiVYF0iDnXk6FYUAAnzu44evBG9XO gN5BMakQCO0h5arfDm7PZ59/dMN6jbmuzFfaxpYhfWli5tmUC356Awst7fHw1hd30fnj gpq8el73p2w770xc3gvOj+tGyOPjwohw7sEXqdfDKvG3TmmGJhJ+8l7xkp3+Dn2ZM2vk Cev6LhgOt0oAdaeXCOK/ePCehxKRgcgV3gqER2lRQPJv0ZGA6NWbvGl8qQtV9rh/Eskl Am6A== X-Gm-Message-State: AODbwcDsRrvcZOzdDhramEG/QzS5FrygGJA7WMB+bUELJCuHvBoovjPH +TBW5w2JiftBaU/O X-Received: by 10.99.96.70 with SMTP id u67mr1808929pgb.101.1496333623205; Thu, 01 Jun 2017 09:13:43 -0700 (PDT) Received: from localhost.localdomain ([106.51.140.154]) by smtp.gmail.com with ESMTPSA id f1sm29255472pgc.8.2017.06.01.09.13.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Jun 2017 09:13:42 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Amey Telawane , Steven Rostedt Subject: [PATCH for-4.11] tracing: Use strlcpy() instead of strcpy() in __trace_find_cmdline() Date: Thu, 1 Jun 2017 21:43:35 +0530 Message-Id: <1496333615-31603-1-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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) --- kernel/trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 0ad75e9698f6..fe171695492c 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -1899,7 +1899,7 @@ static void __trace_find_cmdline(int pid, char comm[]) 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, "<...>"); }