From patchwork Thu Jun 1 16:12:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 100945 Delivered-To: patch@linaro.org Received: by 10.182.202.35 with SMTP id kf3csp833694obc; Thu, 1 Jun 2017 09:13:39 -0700 (PDT) X-Received: by 10.98.214.14 with SMTP id r14mr1765402pfg.156.1496333619889; Thu, 01 Jun 2017 09:13:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496333619; cv=none; d=google.com; s=arc-20160816; b=GaX+acTjy58OJUvZIsEiOMCd8NgQqmEbq6kEOJ7LJYLRtHnHXrlva4HvywxDYKDnMa 6SukF3CVQnrqVymazfXPRlLmJMyGQ2qwEYvrE639D3clY2fkC1+wWH588Oz6d8rSbKxn GV6H4+ZConebWexBe/rmf/KLojHwVPDPkurSjEGULxbNJjV4dhT+3X2+PPFu4noEU8Uq A/wG96vw5iym4GIoiBZsbCjaz54+l+VSsnva59sXjZDJeEpoI08SJmc9Uhn9D+vMtyo1 fkKd0FhUszhUEGWJuTcTqIS5wHMzC3iM+RQ4c505Y2p3PpKFxnrbByPN93vv3wc1RCyF yRSQ== 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=edPhhR716eRSw+cqRr4mAPAPTtCFqxy3kJDR35rDvOWlJR8JcsIXlup5xhA/2Uyzqv vQklzVIcar0k6yTc5PQHtA08vG4TXRKMeyxQzr03bBe2L6O9/XsrCubzJIQ/f9l+naL5 KaYgNmiKochj363lBxrcHknZqcXIFFZttCDQ8UJgfH+cKicMO9PYogyN/v3ohncU7Upm K7+brKWAjes9OfZ3vKBciCX1dM6znPKjo9cMfuX7QbmCkjz9sjNZYecnjoxnhg0lYRW4 S5qJnw4FfXSPlSFSQFC50iukd9HKVo/Jq6EyhU5x3XHlKAXDEaIHrbnj/g4emlegXoGE 2O9Q== 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 m10si19229225pgs.81.2017.06.01.09.13.39; Thu, 01 Jun 2017 09:13:39 -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 S1751684AbdFAQN1 (ORCPT + 6 others); Thu, 1 Jun 2017 12:13:27 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:36372 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751659AbdFAQNX (ORCPT ); Thu, 1 Jun 2017 12:13:23 -0400 Received: by mail-pf0-f171.google.com with SMTP id m17so31256681pfg.3 for ; Thu, 01 Jun 2017 09:13:13 -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=XvG6WPwzWOk0bCszXeawAZT776sFbqJrP71+HqpU3FR9wskCfP8rgCr7r5DXui9W5r lIWNvto4k7yY65PQ4iLlBr71CjBRcgqW2kH0AjHvI4n/qUytc2O8FXX8HcSWFcK3TFit eCbugs+iRvd9bZLECA+k2jvQwQxY5QrKnrDZk= 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=oqbzUDpU1PjnR0a8pcP8cOykmE9GBRytDxhUQAs+uoCKkxhlT1nqxP/PbSugiHwPgz A+KXYDSAdv/yxQz2elA/HXdakXuXLLm1PKIWP+toUMK3QmpQ1Spj9P/2Eo8isbbMx2G8 EVv5qxdSf4CQPZ3aNALv0KO8CjuxhZxXUjk49B1OXBfOP3DTFd8RFmpQN7yApEOkmZVt 17Ye/pfyjLBc67d23piwhIAUr5Svn4AHa/B2Jrpn3ytHMzfRWuQW/NwijPRjYzC+rA6W WN2VXsLmESzlMifFzBUgR/Abr5+/hhSLsOF+dqLPdyb5BbFBSWXa5JGRhd+mQkNpr4Ho A9kg== X-Gm-Message-State: AODbwcC31ird7yypd9RD7mv/TRDzTNgK4zd6bCXcsa5xcoHfAt0bQF6K PFYNur/B6n14lFEg X-Received: by 10.98.236.150 with SMTP id e22mr1770216pfm.48.1496333582929; Thu, 01 Jun 2017 09:13:02 -0700 (PDT) Received: from localhost.localdomain ([106.51.140.154]) by smtp.gmail.com with ESMTPSA id h123sm31692345pgc.36.2017.06.01.09.13.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Jun 2017 09:13:01 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Amey Telawane , Steven Rostedt Subject: [PATCH for-4.4] tracing: Use strlcpy() instead of strcpy() in __trace_find_cmdline() Date: Thu, 1 Jun 2017 21:42:55 +0530 Message-Id: <1496333575-31472-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, "<...>"); }