From patchwork Thu Jun 1 16:12:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 100944 Delivered-To: patch@linaro.org Received: by 10.182.202.35 with SMTP id kf3csp833494obc; Thu, 1 Jun 2017 09:13:10 -0700 (PDT) X-Received: by 10.98.137.93 with SMTP id v90mr1699168pfd.69.1496333590800; Thu, 01 Jun 2017 09:13:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496333590; cv=none; d=google.com; s=arc-20160816; b=FsuY1EqMjiYY2UqCODPADy58Ff/4Pc65iB3FSB+KqTqUteUe2WbGdZv97bMC0Zo4Bz C/kLTE1ZJKqUGZ9wuqoBAP37Gw5FcVg8/YoJ1+uTLRxOIXzpYHt/g/FohI/AvXqflfYz NDRwGvIqiivqsAAU1XrS1ODXISwg49CUmYE5+YQXMF6q6i9OueG9Gb++H68ScmKN4Py1 SE020jwll8f8iceUvrIsWwLyTyhdVbtx4XFUnjmaWE9CLyLVJPiqPTC+hy30+4E3NpES 5SjzIp7H0XJiS2mq1B3ETARB+DqK1kJ+yu09Oq38NVZTFsT4AnfXuMptYb4VxhNkY7Nn uTGg== 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=Jy0+5iYHxeQMlRMPtXPxy9rB1F6Orzf/24h1o2LekzxoQOXMyGCS1n2fHNLDt+eahJ eKJtm+ncGvOoXMkcbUrO/96zKiIUv3FX/+ck5Fzms2LeAZzeUb6FuyES9cdhVA2L8A54 RkQguxyh7aiDqRHF90uxFOThC9bbVTKAnLhEU2zXyQbPzUMqZxjHMgdFgkgVvZzPStNk zyNtyYWk4NHfcCxCOc9J0JNDK3j7cVmYiypIXOPy6LNTtufvLC4bAUtCrHZ0xolcnfLx cBjuwNC5dqRXtbueocw98Vm06BPZ5cpdwFsC/hrIc04fZy7mmJSBKHYuxKpJh5ebOFDi WQkw== 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 a13si19581295pfh.193.2017.06.01.09.13.10; Thu, 01 Jun 2017 09:13:10 -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 S1751436AbdFAQMu (ORCPT + 6 others); Thu, 1 Jun 2017 12:12:50 -0400 Received: from mail-pf0-f177.google.com ([209.85.192.177]:33972 "EHLO mail-pf0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751556AbdFAQMs (ORCPT ); Thu, 1 Jun 2017 12:12:48 -0400 Received: by mail-pf0-f177.google.com with SMTP id 9so31255810pfj.1 for ; Thu, 01 Jun 2017 09:12:43 -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=Zu4GOC2oUq12ZMGWFDF2vD8gV3x8r59RokpJaml2Mp3muR9Hi6rKdtVZXcPqdj1vWo yvaETTBjoDgvK0WW4CMkUNQu0xMER1f4ePyDDEEk8BfFqCXpJ4dsuYN/a/FlZhEP6DBV 64vUADyp6bUkeNArvZWSlBK2d68fo5kss62fQ= 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=GbnvnUStqSh/pbTNV7NyrwNd5nxoPnpbxUVvTcr/hdOUXuQyNdC8gC+WBPrj6AVOS3 s/iS+awYvC+xRg41Ug05N5gWSn9bN9LAOqKtRvVJk4iROyzuKlAVmE+SJpGveMVDSM7b iY461A1kN2T3vleCrtzu/o04qXZeH51QUXE8OpDhypGrubTV2QnnaqsbLHCkOuIll4xu 9Hcbv7TtJFsRfMdbxePqXj4T7yS/4fXeJ1HIo87t4JCW3+yWWp25Iv3KUQ5RZpIYXHQQ joAhndeQELWFwijiCslS3Y991xpFg9Od5Z4Vu687qy4jL8GRdxtMvZDHuxI+aKTPagiH Lt4w== X-Gm-Message-State: AODbwcAF2/jFUYqKUDUGhTbeSR1u3VBg7yMWxfIqWfq4DCbpXIA1m+DA mg5If5HxOtSCmZTceEt2PQ== X-Received: by 10.98.66.76 with SMTP id p73mr1764805pfa.180.1496333558056; Thu, 01 Jun 2017 09:12:38 -0700 (PDT) Received: from localhost.localdomain ([106.51.140.154]) by smtp.gmail.com with ESMTPSA id q135sm46384796pgq.41.2017.06.01.09.12.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Jun 2017 09:12:37 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Amey Telawane , Steven Rostedt Subject: [PATCH for-3.18] tracing: Use strlcpy() instead of strcpy() in __trace_find_cmdline() Date: Thu, 1 Jun 2017 21:42:25 +0530 Message-Id: <1496333545-31356-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, "<...>"); }