From patchwork Wed Apr 1 16:18:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 228383 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37295C43331 for ; Wed, 1 Apr 2020 16:47:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D047C20705 for ; Wed, 1 Apr 2020 16:47:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585759642; bh=2s1dfWokLE+QvZy6uWmoeW9BrczpJ9Zz5y4oHMEf5J8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=YTzTx+sRKP9i2ubbtQCn0CHEmldNvrpY1a8bs3p6hrLmMoo06kvTSxI1XWDzjSr9c gyLa03Dsml0hnSTVYeMr6TWTNPbDbQJhPcI6C96vpdmEe+6vMiEWITvaBO+qqdA1Hr LNp6RkA7EPprPbvK3K+Lifp4OeCgWVu7UDkQjIN0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390047AbgDAQrW (ORCPT ); Wed, 1 Apr 2020 12:47:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:49086 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389743AbgDAQrU (ORCPT ); Wed, 1 Apr 2020 12:47:20 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 98C32206E9; Wed, 1 Apr 2020 16:47:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585759640; bh=2s1dfWokLE+QvZy6uWmoeW9BrczpJ9Zz5y4oHMEf5J8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dOaYJCg0RtHi/hEqu8E6vlHKiPx1TgOls3egRhIYFuEoGOB5R2qrSMJFslUw8T/kK 6Nux189/nYhRT0HMShSu2Jcsc/0bWqnDaIeId+r+nSJh/wTKV4ihj4m4PvLYf0EDbe uktTsAdLzkoXp2uhE4jouBEWHCXXU2WlRdF1GoWo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, disconnect3d , Alexander Shishkin , Changbin Du , Jiri Olsa , John Keeping , Mark Rutland , Michael Lentine , Namhyung Kim , Peter Zijlstra , Song Liu , Stephane Eranian , Arnaldo Carvalho de Melo Subject: [PATCH 4.14 144/148] perf map: Fix off by one in strncpy() size argument Date: Wed, 1 Apr 2020 18:18:56 +0200 Message-Id: <20200401161605.909751564@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401161552.245876366@linuxfoundation.org> References: <20200401161552.245876366@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: disconnect3d commit db2c549407d4a76563c579e4768f7d6d32afefba upstream. This patch fixes an off-by-one error in strncpy size argument in tools/perf/util/map.c. The issue is that in: strncmp(filename, "/system/lib/", 11) the passed string literal: "/system/lib/" has 12 bytes (without the NULL byte) and the passed size argument is 11. As a result, the logic won't match the ending "/" byte and will pass filepaths that are stored in other directories e.g. "/system/libmalicious/bin" or just "/system/libmalicious". This functionality seems to be present only on Android. I assume the /system/ directory is only writable by the root user, so I don't think this bug has much (or any) security impact. Fixes: eca818369996 ("perf tools: Add automatic remapping of Android libraries") Signed-off-by: disconnect3d Cc: Alexander Shishkin Cc: Changbin Du Cc: Jiri Olsa Cc: John Keeping Cc: Mark Rutland Cc: Michael Lentine Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Song Liu Cc: Stephane Eranian Link: http://lore.kernel.org/lkml/20200309104855.3775-1-dominik.b.czarnota@gmail.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -90,7 +90,7 @@ static inline bool replace_android_lib(c return true; } - if (!strncmp(filename, "/system/lib/", 11)) { + if (!strncmp(filename, "/system/lib/", 12)) { char *ndk, *app; const char *arch; size_t ndk_length;