Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3707163ybv; Mon, 10 Feb 2020 05:04:50 -0800 (PST) X-Google-Smtp-Source: APXvYqyT7k7mjjIc/q1CNZBZe8f3zs6Bgw7NptYZShSX45vdDHuVvjwgNVK8GHEF37DyhKhahaPp X-Received: by 2002:aca:c256:: with SMTP id s83mr772352oif.57.1581339890542; Mon, 10 Feb 2020 05:04:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581339890; cv=none; d=google.com; s=arc-20160816; b=r6H/UnTn86+wk4BFoba5UagYO/V9ZjuOYUDzd/uHnlMY+SQwjy6igSZcuk2/sNJsTJ rQqh6ZempmoiBly57TuVUusQWEuhgD/9qNsnRcueY8V2+uc1mBwSMcLB3LsEyDemUB2o qPbI5AqviPOV92MGsaa9oNHy6oKoWwRFNWwKplO5BkcDE8aEDxD4KCDGRiL51j8QTLY4 GhGSTexUrVWtKRd2P5yD/kmHdbU3F37CY8SbFYr6vPlg9dF8IQ1gU4mR1I6L3UqInZys 2Yd5r57FWsMa7nzO2flmxEgT8plRwzvm7rDUzrNe9Q3rRoYagI6On14W4IvzkmFxYbAp q/cw== 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=by/qdV9jfHPDf2AQKqIPrAR4q+4MfNUIusYIkn0EiMI=; b=aPubgwviwD90ZOKSRTmqQNsD+PGeyRNoGyoJC0/K/muvZK6M5MBrmUdhX9su3FXReR ArUG40ql4Efu32TlGR7rVxDGyEJO11e3NaZpUzgWHFbJT5cFOCrzL4S9wllcO8NALABi eiTM43HptOo0u+3F7ga3tr+1aHEmsXG4DYG+J8a/2P1AcvRGrAz4cNFFVAygww228IC9 DgUVhu2zSvNb87B2iA0+MCYUdtnLXzgLd1AuPpw1zdQ1wMEdKplEcNiAwLmeN2emqwlM jSAcoHV5c8rC6J+y0Lbm4enVDAfG6kdFpX8Gv+om9lzQJ9YzWCwfu/WptxRbIZqXjOmo jrPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PnbJy+8P; 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 s77si143408oih.51.2020.02.10.05.04.36; Mon, 10 Feb 2020 05:04:50 -0800 (PST) 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=PnbJy+8P; 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 S1730359AbgBJNCW (ORCPT + 99 others); Mon, 10 Feb 2020 08:02:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:40920 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729096AbgBJMkg (ORCPT ); Mon, 10 Feb 2020 07:40:36 -0500 Received: from localhost (unknown [209.37.97.194]) (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 5144620873; Mon, 10 Feb 2020 12:40:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338436; bh=3s5tlKd8Snhp+dVdyUVfC6ozogRCiz+RFyrMWOQVRdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PnbJy+8PCTgJYyLfY8oM1dht3a8HwzA3W0+ExbHXscrJ793nhKePMVgWKA/6Uh8Eb lL8Bx1+uxZC+0frGrP9FH3rGD6M0k9LGlDVy1WfNntZrrkW+ky7bdz8kW2gXbzB1s0 +RN4yjWZ1JB0wTLEL9yeCRU4BIXeh8BU1TXo5BRQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Yonghong Song , Andrii Nakryiko Subject: [PATCH 5.5 170/367] selftests/bpf: Fix test_attach_probe Date: Mon, 10 Feb 2020 04:31:23 -0800 Message-Id: <20200210122440.573633852@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122423.695146547@linuxfoundation.org> References: <20200210122423.695146547@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: Alexei Starovoitov commit 580205dd4fe800b1e95be8b6df9e2991f975a8ad upstream. Fix two issues in test_attach_probe: 1. it was not able to parse /proc/self/maps beyond the first line, since %s means parse string until white space. 2. offset has to be accounted for otherwise uprobed address is incorrect. Fixes: 1e8611bbdfc9 ("selftests/bpf: add kprobe/uprobe selftests") Signed-off-by: Alexei Starovoitov Signed-off-by: Daniel Borkmann Acked-by: Yonghong Song Acked-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20191219020442.1922617-1-ast@kernel.org Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/bpf/prog_tests/attach_probe.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/tools/testing/selftests/bpf/prog_tests/attach_probe.c +++ b/tools/testing/selftests/bpf/prog_tests/attach_probe.c @@ -20,7 +20,7 @@ extern char NAME##_data[]; \ extern int NAME##_size; ssize_t get_base_addr() { - size_t start; + size_t start, offset; char buf[256]; FILE *f; @@ -28,10 +28,11 @@ ssize_t get_base_addr() { if (!f) return -errno; - while (fscanf(f, "%zx-%*x %s %*s\n", &start, buf) == 2) { + while (fscanf(f, "%zx-%*x %s %zx %*[^\n]\n", + &start, buf, &offset) == 3) { if (strcmp(buf, "r-xp") == 0) { fclose(f); - return start; + return start - offset; } }