Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1377502ybh; Mon, 13 Jul 2020 17:43:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiTaSq+7sfzqWFUdWjSs2cIvEKZ7Ub7SXlsnZN96HjKVYazQIrq++pAGUmr/gJCAHn5cpn X-Received: by 2002:a17:907:20b0:: with SMTP id pw16mr2059975ejb.551.1594687382418; Mon, 13 Jul 2020 17:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594687382; cv=none; d=google.com; s=arc-20160816; b=s1LCYcdN3IHCr88c4jqBthBPYUruxh/90AyLj7oqufclrW0jYT5EBlRtB+kxPDP5hr ZtlQb1ieLtDmLyVVs4ZbWI+wjQXyCdSfUX7aqJTmK5D82p9V2hSR+p80bNFUiqIT5xuk exfyEwAaorbiO/lMP+/j8FyUtwwAef/AeSdpXCOADWiYiZMR7AcD7zor4ZYvpnB9Z4KZ lVyQjhe1YqWBa++WgSk3h3G1WDxInk7KATnfZXFFjL6m4o+ySsTnI1YvX9XGey0YOwuD zLyYhlnwV6GFzOAjewqlmg/SCCulF771KLP9oTC8MZL8oCP/JveDdJn6IqzRIeMvjW38 jCOA== 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:dkim-signature; bh=KdIW5He8ZiiCiJCefvMCxWAQ162LKqrQoM487o/uJO8=; b=eV/8Co9AMefSSsuQMKikg8RDsOSbsJFnCPHtZAiiHsP73leO6BipdtlgsqxTu+UQH0 /YsIjTUfEQw/XQfPDZHBOjJlU/UReD3mGJ9UknMY84C8GbBHz6Usb4kBMFr6L0sFiimj W1zqBGk1by+PyDyG1SxbQo4KD6LS0fGN89fleB8d17BNkNbRZhPynmUPGB6mKFKLjF7r l250w7NAmaucxVdkduIdIqv3hPrmiauLzcsy2rp1V8qIjPCv9prlirSG4nJoDflOwXKm kBYlPviBLc1Cv91HABF/RE9zRc4WPVPk991EmFecyssoe+tvBIyuQ88pntYUUOKnyU8X 1H1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kXA12gfh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i13si9861760ejp.659.2020.07.13.17.42.38; Mon, 13 Jul 2020 17:43:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kXA12gfh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726742AbgGNAmb (ORCPT + 99 others); Mon, 13 Jul 2020 20:42:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726257AbgGNAm3 (ORCPT ); Mon, 13 Jul 2020 20:42:29 -0400 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7836C061755; Mon, 13 Jul 2020 17:42:29 -0700 (PDT) Received: by mail-qv1-xf43.google.com with SMTP id h18so6734726qvl.3; Mon, 13 Jul 2020 17:42:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KdIW5He8ZiiCiJCefvMCxWAQ162LKqrQoM487o/uJO8=; b=kXA12gfh+GeMEU0kaSoQ15nqyvzVsppDR7KTdVpxyShQ4ztvA5r9mmzlEhnBgw6JM0 M00ZaD5scYu/PTcWMxJ3kv0hZ/2XO78OrGxpYpb3jhWXgfQbUTnqRwqFOIsDr+j2pAqZ VG8Q0fRmq8eJULv43+qfCdY9Ktf/a/hY4BI5P71MaaS572T0+rvdfB0qNBtmNLuYm/Ps fuCIymU+DnYkvMCpTVRVPkiC8b+NoUSPslqs22xgK65g6NPfK6UT4PlPNzCmCNNIhJnr Dsdm00orgJnSJy5lAamHKdi/YTHjKQI2HhK+As546ROmFhNnfbcMSCixrsSHP5yttjHH ibmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KdIW5He8ZiiCiJCefvMCxWAQ162LKqrQoM487o/uJO8=; b=bRiLL9P9PFWTnEP07ZSpy/3be42C+/glXZP6vbUvwhf976JQEVo1VW6AH8alr9Z0oX F2r/jOKb9+w6CPG3j1Ll7gbCRTbiTtnPkKu64oFPXD6tOb+blLxIh0LoiE52dIY9kBaA Ws3CT7WVlx8RaNIwWTGZVvG6dertr/BDDQxqk0Fcu6550Ja3CGcR5bil4gZ7ZQOTq7RK yPooX9l87/P60uJjnDR3rqrGIBT/EDiCPQ+7l/WcL59OR0quceYs+ssn0xNWfPVESNCY Hus/9eutG/2f6O5RstxqLFtZWbA+BWrwzxMvRwPZ8SiFdVcAH239hgxerq2YMsl/tpc8 rsNQ== X-Gm-Message-State: AOAM532C1SQEOCE5BFaxUNPSeXM9wl4vkHYZK3g9NNjjMNLlvokjJPX9 hNMwkuJQ3mErmdZdvJbyzQ== X-Received: by 2002:a0c:8583:: with SMTP id o3mr2124679qva.108.1594687348930; Mon, 13 Jul 2020 17:42:28 -0700 (PDT) Received: from localhost.localdomain ([209.94.141.207]) by smtp.gmail.com with ESMTPSA id p36sm2849287qte.90.2020.07.13.17.42.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 17:42:28 -0700 (PDT) From: Peilin Ye To: Alexei Starovoitov , Daniel Borkmann Cc: Peilin Ye , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , Greg Kroah-Hartman , netdev@vger.kernel.org, bpf@vger.kernel.org, syzkaller-bugs@googlegroups.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [Linux-kernel-mentees] [PATCH] bpf: Fix NULL pointer dereference in __btf_resolve_helper_id() Date: Mon, 13 Jul 2020 20:38:56 -0400 Message-Id: <20200714003856.194768-1-yepeilin.cs@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Prevent __btf_resolve_helper_id() from dereferencing `btf_vmlinux` as NULL. This patch fixes the following syzbot bug: https://syzkaller.appspot.com/bug?id=5edd146856fd513747c1992442732e5a0e9ba355 Reported-by: syzbot+ee09bda7017345f1fbe6@syzkaller.appspotmail.com Signed-off-by: Peilin Ye --- kernel/bpf/btf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 30721f2c2d10..3e981b183fa4 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -4088,7 +4088,7 @@ static int __btf_resolve_helper_id(struct bpf_verifier_log *log, void *fn, const char *tname, *sym; u32 btf_id, i; - if (IS_ERR(btf_vmlinux)) { + if (IS_ERR_OR_NULL(btf_vmlinux)) { bpf_log(log, "btf_vmlinux is malformed\n"); return -EINVAL; } -- 2.25.1