Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp542970imu; Wed, 23 Jan 2019 01:00:36 -0800 (PST) X-Google-Smtp-Source: ALg8bN68cyMP/RPHN9uMicCeBSfxxQRvCIL5UgZER6Qbnso9LnFAt2tBVmkqnznEQgjJSBr9DSh6 X-Received: by 2002:a17:902:f01:: with SMTP id 1mr1362459ply.143.1548234036478; Wed, 23 Jan 2019 01:00:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548234036; cv=none; d=google.com; s=arc-20160816; b=dzvj/d+RFSRE5UkLwrqI4Eop3nIRWhw/lL1vgkFOn2fLmmsxA4CJI3f06ywQu5md69 36CM8865yzZAawUrcNpFDNkjqMmgvXuY5CHj1dNWNHGmBIjI5sKiZ48I1NqYx3bMdbrj M1l0XYYx2a52s9BsHELx9DhQnNcCYqjw8sQ1tjn0JrfTRNoKKVyFokw6U1tSqvMq8qtp P0i9ko/24VyfaA/Ye21N4PuS6eQsrIEGuvZZQk2VhjM2ABmA/IswDDl+lP2peZrXlg5s 72dD4seFCLpbnhFX9+Byg0m382iTzqIyi+uZq4LdXlMme0LcfH8rH9AJLjMsz3jxxfzq 056Q== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=ST3fY6V0wob67Ya3bhBgl2p7M6rzxctsbt4I59x4Hb4=; b=tng08v96LUcdcdnzKdWGdgEM71Ph+LbiZZes+FevCcPm4gwxWCQpUqLBTP5KhrOZfK jI7TP2JAZX6kT+Q6DWGcK3uKbj5H6w3HnYWOlw9+Xqw87xDIY7C3st+OBCe7sLdcVEB1 R8Sn6LsO98UXQRUFQ99o+PRTazVbL7mnuSPHnXxNOf5PLS89N8xjV7tmqbMxoFuNghPq 1QLBWdwrVu7NGhCbSSSNgFUS0eB1If3ZEKf+dqEdSZ54WV7W+7Lw3M/1NJLmDCrLb2SI h2nYQ6irnFgBPvCfKJMJuMnti8LGQjeyiwJKAojwfEFhuovJEZKrXq7SUlw/JUyx0iF8 Y0mQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 72si18007633pla.218.2019.01.23.01.00.20; Wed, 23 Jan 2019 01:00:36 -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; 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 S1727090AbfAWI60 (ORCPT + 99 others); Wed, 23 Jan 2019 03:58:26 -0500 Received: from www62.your-server.de ([213.133.104.62]:47970 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726317AbfAWI6Z (ORCPT ); Wed, 23 Jan 2019 03:58:25 -0500 Received: from [78.46.172.2] (helo=sslproxy05.your-server.de) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1gmEMY-0004vt-UB; Wed, 23 Jan 2019 09:58:23 +0100 Received: from [62.203.87.61] (helo=linux.home) by sslproxy05.your-server.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1gmEMY-000H3v-Np; Wed, 23 Jan 2019 09:58:22 +0100 Subject: Re: [PATCH] bpftool: Fix prog dump by tag To: Jiri Olsa , Alexei Starovoitov Cc: lkml , netdev@vger.kernel.org, Lance Digby References: <20190118125817.10763-1-jolsa@kernel.org> From: Daniel Borkmann Message-ID: <182563c3-8e11-d489-2e9e-68a391e63f3e@iogearbox.net> Date: Wed, 23 Jan 2019 09:58:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20190118125817.10763-1-jolsa@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.100.2/25323/Wed Jan 23 03:43:38 2019) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/18/2019 01:58 PM, Jiri Olsa wrote: > Lance reported an issue with bpftool not being able to > dump program if there are more programs loaded and you > want to dump any but the first program, like: > > # bpftool prog > 28: kprobe name trace_req_start tag 1dfc28ba8b3dd597 gpl > loaded_at 2019-01-18T17:02:40+1100 uid 0 > xlated 112B jited 109B memlock 4096B map_ids 13 > 29: kprobe name trace_req_compl tag 5b6a5ecc6030a683 gpl > loaded_at 2019-01-18T17:02:40+1100 uid 0 > xlated 928B jited 575B memlock 4096B map_ids 13,14 > # bpftool prog dum jited tag 1dfc28ba8b3dd597 > 0: push %rbp > 1: mov %rsp,%rbp > ... > > # bpftool prog dum jited tag 5b6a5ecc6030a683 > Error: can't get prog info (29): Bad address > > The problem is in the prog_fd_by_tag function not cleaning > the struct bpf_prog_info before another request, so the > previous program length is still in there and kernel assumes > it needs to dump the program, which fails because there's no > user pointer set. > > Moving the struct bpf_prog_info declaration into the loop, > so it gets cleaned before each query. > > Reported-by: Lance Digby > Signed-off-by: Jiri Olsa Applied to bpf and added Fixes tags, thanks!