Received: by 2002:ac0:a874:0:0:0:0:0 with SMTP id c49csp741336ima; Fri, 15 Mar 2019 13:05:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZ3/yjBbqkSFcA+NkaeQfKP8z47f9yczhqvr4ZeSfsVkhGf1j+/yGMDX66TIERfRC8Etco X-Received: by 2002:a17:902:28a7:: with SMTP id f36mr6123304plb.169.1552680326108; Fri, 15 Mar 2019 13:05:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552680326; cv=none; d=google.com; s=arc-20160816; b=m6l3OxrDCWtbpZSyRI49dU7yp5Sb1sgopW3NiE5pn7oxZsx6VqWQJCqVzv7NrtBV4t +EpcT1mIGqWyxDlyGQT3u1YPNX76Ua0zFgE91xtJrWWSGJSLNRy5f+gN4jvJauoQevPD Ypt4iP6e1LXGlxNEuBx3aqEAuAMOw5PhORMvfIqpmNbNcgv9zepGsOnKbTIt/A18j5as l/tkhtULjKzXTAbsBi7NZEN5oA9Fs604IHKGmy3xGfwgPHAX1D9cErhe4Va9BkH/7+cd 68hwavyVnxwaKgEPkuEyKXhmlnsQnUuKHEwU1qcIn0FjTYro09IlfnXm/wpBu9vvC3Fz yjEg== 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 :message-id:date:subject:cc:to:from; bh=JVRQ1mP3bPpzn8Hlf/9JFond4c75XZMPKvj+/dav0n0=; b=OTQBsIdao4AbvtdVv5HEcmnnoNIsGpdtZWq+OwQKyabPRGp7OhhF4vfJzDuPo+sMk/ vfhH+OFQEMLUafo+0oCZlvOBMZ4klzMRkYy2HGo22QHK4wjzhho/Ebot7payUT4XKLeq wqPesRvKEjqNz8bBvE5PQ4Ix8HXtgwUJEsXRjjRVjmPNQCLF7+xKr664CjIUyQB5aW9J ch22dcL9wLV3zmsEOy+9FkOTyCRmcIOFXeTm6mgStr7u/FGUHSMIsxUzoC+7cWwavfm8 l7ResAYFfpI7SI1weJYzNfSxQA+RUMGN+vovDF0otns29cB/nNx0VSHEsttSLeHCJq/W oPMQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g19si2576822pgg.235.2019.03.15.13.05.10; Fri, 15 Mar 2019 13:05:26 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726549AbfCOUET (ORCPT + 99 others); Fri, 15 Mar 2019 16:04:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45756 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725990AbfCOUES (ORCPT ); Fri, 15 Mar 2019 16:04:18 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5EE9DC04FFF2; Fri, 15 Mar 2019 20:04:18 +0000 (UTC) Received: from ceranb.redhat.com (ovpn-204-143.brq.redhat.com [10.40.204.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id BFE665D9C8; Fri, 15 Mar 2019 20:04:15 +0000 (UTC) From: Ivan Vecera To: netdev@vger.kernel.org Cc: Shuah Khan , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , linux-kselftest@vger.kernel.org (open list:KERNEL SELFTEST FRAMEWORK), bpf@vger.kernel.org (open list:BPF (Safe dynamic programs and tools)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next] selftests: bpf: modify urandom_read and link it non-statically Date: Fri, 15 Mar 2019 21:04:14 +0100 Message-Id: <20190315200414.32346-1-ivecera@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 15 Mar 2019 20:04:18 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After some experiences I found that urandom_read does not need to be linked statically. When the 'read' syscall call is moved to separate non-inlined function then bpf_get_stackid() is able to find the executable in stack trace and extract its build_id from it. Signed-off-by: Ivan Vecera --- tools/testing/selftests/bpf/Makefile | 2 +- tools/testing/selftests/bpf/urandom_read.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 2aed37ea61a4..c33900a8fec0 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -69,7 +69,7 @@ TEST_CUSTOM_PROGS = $(OUTPUT)/urandom_read all: $(TEST_CUSTOM_PROGS) $(OUTPUT)/urandom_read: $(OUTPUT)/%: %.c - $(CC) -o $@ -static $< -Wl,--build-id + $(CC) -o $@ $< -Wl,--build-id BPFOBJ := $(OUTPUT)/libbpf.a diff --git a/tools/testing/selftests/bpf/urandom_read.c b/tools/testing/selftests/bpf/urandom_read.c index 9de8b7cb4e6d..db781052758d 100644 --- a/tools/testing/selftests/bpf/urandom_read.c +++ b/tools/testing/selftests/bpf/urandom_read.c @@ -7,11 +7,19 @@ #define BUF_SIZE 256 +static __attribute__((noinline)) +void urandom_read(int fd, int count) +{ + char buf[BUF_SIZE]; + int i; + + for (i = 0; i < count; ++i) + read(fd, buf, BUF_SIZE); +} + int main(int argc, char *argv[]) { int fd = open("/dev/urandom", O_RDONLY); - int i; - char buf[BUF_SIZE]; int count = 4; if (fd < 0) @@ -20,8 +28,7 @@ int main(int argc, char *argv[]) if (argc == 2) count = atoi(argv[1]); - for (i = 0; i < count; ++i) - read(fd, buf, BUF_SIZE); + urandom_read(fd, count); close(fd); return 0; -- 2.19.2