Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp830703pja; Wed, 1 Apr 2020 09:29:29 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsaD4msdEG/z/8dWo+cc8SToRyBjyShcqln49cMwtEsXgTZPmhxT7zsWmAzBHv7+ZVcjC7h X-Received: by 2002:a4a:3150:: with SMTP id v16mr17604162oog.71.1585758569304; Wed, 01 Apr 2020 09:29:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585758569; cv=none; d=google.com; s=arc-20160816; b=BLEwIAYHCFe/BoQHB/PZ5NSHraATptli/3V4twbDGHRV+QacFGKa5FD/b/q/6t54jA O8D32f4Bc2g3lmdStfJZ7Uno9V6kBM+hvZ/NBJJ0EVZT1diklLuTfaldkcldfpwJ0PZT TIMRo1AI4FfaTznoJukLguOZMFQZfFt/qYK6SkBxkhuoharWjoqnlS7eUfIVFdnsAwXZ un48ssSu67xWdZlgRMHx5QheaeeUwCI9zcuyb9i/VjXVQwZ0PAnSgTGJSNkWpw6g0LWa K19ZLMcFo51yPGEkHtEn+pSY7ZjlxIh4jS42R5qE3EfLte+oSCjp/Dv2xtjky1pY2YfW Q9Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mI6SpSw+OAZiQkNyjW/Fx6ui3rZQhEvH4hsQHdeL8oA=; b=YGnTLr7vh358oMTRU5U38Q8xFAyd+KUg/a3FXq8L9tIKnGY2LwnVb6LSYSCAxDzbBV C4QnDnDd/tw16tqUj0aogP2BTOQ/nWktco4qfrKJlLBKqfv4DfQHsHY8PvucRuiwG2pq FDA8Y9HjMa50R3JPNWOscRUA3BWtTDnGICLP9wYaGaVQuD/zhSt8RAP03vBUcNYKWJsY GSnomZFLxBDSDRgWnAnt8L5EBi25R59bBCM66OzzezgkhotNqiFZjzRB9AQ7ruFcpt12 lqilG6Qf0TWQ9Sr41kgmpXRqrTubZuSL7dsqAGx+mKvGhjm3OSffWAUdd60PzXMBREvW WRBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hkxaCa95; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d75si1072150oib.22.2020.04.01.09.29.16; Wed, 01 Apr 2020 09:29:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=hkxaCa95; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388120AbgDAQ22 (ORCPT + 99 others); Wed, 1 Apr 2020 12:28:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:53808 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388104AbgDAQ21 (ORCPT ); Wed, 1 Apr 2020 12:28:27 -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 32BA120857; Wed, 1 Apr 2020 16:28:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585758506; bh=Tmn5oleCgqpuxbdTFU9DQWUHW4JqZTaDz7bSMafc/Eo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hkxaCa95Bse6LViwdzY/piHRkk13DTYzbEOabeFvTKja4AWlYL5XYfdF6YUnloU3y 1snFcgQUi+KTb789D6zs85FM9rDNuaH9YmsWi4DMez3o1/sE04pErvWn1UyWt2Xt4u M5VRFM4nhLYIQvcrxPJHsHyASqhG79pWEsl8h0rI= 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.19 110/116] perf map: Fix off by one in strncpy() size argument Date: Wed, 1 Apr 2020 18:18:06 +0200 Message-Id: <20200401161556.222657643@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401161542.669484650@linuxfoundation.org> References: <20200401161542.669484650@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 @@ -85,7 +85,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;