Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp688175ybv; Thu, 13 Feb 2020 07:47:44 -0800 (PST) X-Google-Smtp-Source: APXvYqy7LkBJrZWZXldlU94RXP0eiCl9NPPIM85FEyZybMxzYhBDeQw+XpLvTzVCv0ythdfysMlv X-Received: by 2002:a9d:21c5:: with SMTP id s63mr13281345otb.142.1581608864701; Thu, 13 Feb 2020 07:47:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581608864; cv=none; d=google.com; s=arc-20160816; b=eb/2Kql+WO0hv660el1rlYFXUHXixGrufX91KiOkeFMKZZlwGzyruSGy3Iumorh6s1 E60Ik5mLSlRn/7b2yEoY430jOH0Qs/ZydQbXautWSnNk/4P3NBB5ARs4IuZIAuRcBF9A SCLKo8rwdayEBfUmWLg/LeuG12yEBrJyQlZxsc03nH7SCq9LP/7ixjj3CrbytWrT4ZqC khbvzuBms26ap0dPYcy2FJbnSrhztRXobJnpBCX100lqeWGuSOZjCmyNQmLg2O21FxJO +TqGkkq8VLUFf5w/81FrQfhaJiEJjd/jW5k+tR2W7EvZ0Yh0//BenfqkaZ4JtAkmjfgu W2ug== 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=jWgAEb3G3mUFOawoWh1a38b+dKAWwn84Vdf8MVHfILI=; b=xjuDDpg/Hjm1bXkauE3vx91mV4RCC8mx2lYZI9zp7JaInt19CASNQUQ4j025gvci2T 2NHsPfp7uogrfsWsK3tA0leGEJNpyCuZyZ0VGn8hbBj6AQoLlF6Z6uv1rYKFwWQKLrr1 qb2kuwpdiWHrc1lifRZIJv1jTQDnL2Rzf3UgxmffAlGmuRcCcYYzV9jL0W4pHoYRtaIE bNw3ulZ7Zl3JXeJDJ3mlHzN+cvAGB2ABcjbSTcv24kVH2ny4piid3Lp8AQQU0yD7gZhw McbOJGl8+o4jmM2Mrsg8FcZLTPhIFGdFW8ukoIajkxuVOpTfe9f1SdPgckoET07Fatjk 9Kig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nRTgVa2B; 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 r6si1248004otp.220.2020.02.13.07.47.32; Thu, 13 Feb 2020 07:47:44 -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=nRTgVa2B; 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 S1729226AbgBMPq3 (ORCPT + 99 others); Thu, 13 Feb 2020 10:46:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:49606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729338AbgBMP1Q (ORCPT ); Thu, 13 Feb 2020 10:27:16 -0500 Received: from localhost (unknown [104.132.1.104]) (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 5D5072465D; Thu, 13 Feb 2020 15:27:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607635; bh=WwMWopCX5Uq8MXSKhvMYkBKWyMFv8TndcuJiHSuffrU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nRTgVa2BWkxCjNj5AyJbX26my00Fn/3ZV4yWmOJICHp1/BEIjVhtVMX9aVn0QXprq rgIPIJTml5raVksR0/IMRBh0ch6z/vsBGNnej2UshOtC1OVxSJVt1kNoXc6AvzHyx2 bGwSq84FHRLquaOYIlLLVbvtbFFPUwXb1IeXMbKM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , Daniel Borkmann , Quentin Monnet Subject: [PATCH 5.4 21/96] bpftool: Dont crash on missing xlated program instructions Date: Thu, 13 Feb 2020 07:20:28 -0800 Message-Id: <20200213151847.358336722@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151839.156309910@linuxfoundation.org> References: <20200213151839.156309910@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: Toke Høiland-Jørgensen commit d95f1e8b462c4372ac409886070bb8719d8a4d3a upstream. Turns out the xlated program instructions can also be missing if kptr_restrict sysctl is set. This means that the previous fix to check the jited_prog_insns pointer was insufficient; add another check of the xlated_prog_insns pointer as well. Fixes: 5b79bcdf0362 ("bpftool: Don't crash on missing jited insns or ksyms") Fixes: cae73f233923 ("bpftool: use bpf_program__get_prog_info_linear() in prog.c:do_dump()") Signed-off-by: Toke Høiland-Jørgensen Signed-off-by: Daniel Borkmann Reviewed-by: Quentin Monnet Link: https://lore.kernel.org/bpf/20200206102906.112551-1-toke@redhat.com Signed-off-by: Greg Kroah-Hartman --- tools/bpf/bpftool/prog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c @@ -500,7 +500,7 @@ static int do_dump(int argc, char **argv buf = (unsigned char *)(info->jited_prog_insns); member_len = info->jited_prog_len; } else { /* DUMP_XLATED */ - if (info->xlated_prog_len == 0) { + if (info->xlated_prog_len == 0 || !info->xlated_prog_insns) { p_err("error retrieving insn dump: kernel.kptr_restrict set?"); goto err_free; }