From patchwork Wed May 17 07:37:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Po-Hsu Lin X-Patchwork-Id: 763356 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3wSR4j5HPtz9s0g; Wed, 17 May 2017 17:38:13 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical-com.20150623.gappssmtp.com header.i=@canonical-com.20150623.gappssmtp.com header.b="m/0m+hZD"; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1dAtX3-0005oS-Dc; Wed, 17 May 2017 07:38:05 +0000 Received: from mail-pf0-f182.google.com ([209.85.192.182]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1dAtWy-0005nu-VD for kernel-team@lists.ubuntu.com; Wed, 17 May 2017 07:38:01 +0000 Received: by mail-pf0-f182.google.com with SMTP id n23so3193790pfb.2 for ; Wed, 17 May 2017 00:38:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id; bh=4N8Bbw/L+21chLk5fb/BCICAyAlTluXiJm5epklUibM=; b=m/0m+hZDUM7R7Tgx262obijxL0LbGOC2bCUFgXPpa1oVOWwzAZReQF0xycKWNeUocX Byr4/SZiwCNvxHQp1s+hkQinw/DwR+mJIVvMsyOD9O+iammj66YL8bG+a/vJeKnSqLva O7cWL/ipf1Tsgv3csdVw4sU+Ll0A8Put5ZnWtM3236dnH+Skx7NOSJtDA9yUDL5ax4F0 BJ+j2p1+UBTkRs8CFyg2U0QO6oX9LXsSUXbhUpAZoMjyEPet3KEpiFo38Clz8tQeSbGo 7bp92uGHBSBPMBT3JHFzW6v7T6tLktl3t9XuqjispgETbFnQnADabgwPcDhsO1cONXzt cT7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=4N8Bbw/L+21chLk5fb/BCICAyAlTluXiJm5epklUibM=; b=jZBDbBlHVworFpM+nnDKaN6BjqOGBWNR1rCpCsmnV0vxF9wVwa8EPIm41uG6yTel5b 367xeu5qBeNZk5XpIf9UAcGkvi1q8NG7Zrhvg5u/EODJxVncyAnp4UHGidPj/3PQtWJb +wJpTBChQ2kDlSR4VbM18CT8f61CI4hhc6OIn0P9+q2Y4C7SdqRCti1DqAmtJ2O7m6c7 x53DVgimKu+iE5rirqagqNykVM42KQdJ+92ZTiJr+yZkMSXaJCBxzxRADkXqD826UJse hal3r4Dy81N2EqtbLFy9jqj67uvkmaNwh5eAYKcJ6rJX4RsThFC5w4Q0bCGyqr0ynaGx LKpA== X-Gm-Message-State: AODbwcDSAZyfvGoqH/V01c+YIJXM3LpuDJz78zcmFSe0HZRPSAPQf/IE KzlpV4TIkgeFGpmvKu0= X-Received: by 10.98.89.201 with SMTP id k70mr2264365pfj.196.1495006679420; Wed, 17 May 2017 00:37:59 -0700 (PDT) Received: from localhost.localdomain ([175.41.48.77]) by smtp.gmail.com with ESMTPSA id r73sm2346151pfk.114.2017.05.17.00.37.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 May 2017 00:37:58 -0700 (PDT) From: Po-Hsu Lin To: kernel-team@lists.ubuntu.com Subject: [CVE-2017-0605][Trusty] tracing: Use strlcpy() instead of strcpy() in __trace_find_cmdline() Date: Wed, 17 May 2017 15:37:35 +0800 Message-Id: <1495006656-898-1-git-send-email-po-hsu.lin@canonical.com> X-Mailer: git-send-email 1.7.9.5 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com Cherry-picked and adapted from e09e28671cda63e6308b31798b997639120e2a21, as the commit(939c7a4) for get_saved_cmdlines() is not there for Precise and Trusty, apply the fix with the same logic. From: Amey Telawane 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) (cherry picked from commit e09e28671cda63e6308b31798b997639120e2a21) CVE-2017-0605 Signed-off-by: Po-Hsu Lin --- kernel/trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 4ac996f..8c92acd 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -1498,7 +1498,7 @@ void trace_find_cmdline(int pid, char comm[]) arch_spin_lock(&trace_cmdline_lock); map = map_pid_to_cmdline[pid]; if (map != NO_CMDLINE_MAP) - strcpy(comm, saved_cmdlines[map]); + strlcpy(comm, saved_cmdlines[map], TASK_COMM_LEN); else strcpy(comm, "<...>");