From patchwork Mon Oct 19 19:42:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin KaFai Lau X-Patchwork-Id: 298794 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79BBDC43457 for ; Mon, 19 Oct 2020 19:42:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13E87222EA for ; Mon, 19 Oct 2020 19:42:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="TcHFpPqi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731084AbgJSTmM (ORCPT ); Mon, 19 Oct 2020 15:42:12 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:47186 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730021AbgJSTmL (ORCPT ); Mon, 19 Oct 2020 15:42:11 -0400 Received: from pps.filterd (m0109332.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 09JJeeYl006360 for ; Mon, 19 Oct 2020 12:42:10 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=facebook; bh=8zjm7XAzaxYCuw5Fkzj1GkY0vWI4f8xJu08mBtuJ6s4=; b=TcHFpPqi0D2hxb7bVs/kRA7RTAWqxLmdjTWDdaJxjtTT9ko2McIl0lFU4sUqqBRgrd8L FjuAZUSNi363FvL1fJ0s9RYt11KhmkgpOlhI6NYULCwt2rXp+Am/WBGq1aYMxwrr0yxm zxbzyB1VCIFp/A0ODWRiHYTCB/WoQ6y1FGM= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 348gsbppb6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 19 Oct 2020 12:42:10 -0700 Received: from intmgw003.08.frc2.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 19 Oct 2020 12:42:09 -0700 Received: by devbig005.ftw2.facebook.com (Postfix, from userid 6611) id A87DC2946269; Mon, 19 Oct 2020 12:42:06 -0700 (PDT) From: Martin KaFai Lau To: CC: Alexei Starovoitov , Daniel Borkmann , Hao Luo , , , Yonghong Song Subject: [PATCH bpf 0/3] bpf: Enforce NULL check on new _OR_NULL return types Date: Mon, 19 Oct 2020 12:42:06 -0700 Message-ID: <20201019194206.1050591-1-kafai@fb.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-10-19_10:2020-10-16,2020-10-19 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 lowpriorityscore=0 malwarescore=0 phishscore=0 priorityscore=1501 impostorscore=0 suspectscore=13 mlxlogscore=521 adultscore=0 bulkscore=0 mlxscore=0 spamscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010190132 X-FB-Internal: deliver Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This set enforces NULL check on the new helper return types, RET_PTR_TO_BTF_ID_OR_NULL and RET_PTR_TO_MEM_OR_BTF_ID_OR_NULL. Martin KaFai Lau (3): bpf: Enforce id generation for all may-be-null register type bpf: selftest: Ensure the return value of bpf_skc_to helpers must be checked bpf: selftest: Ensure the return value of the bpf_per_cpu_ptr() must be checked kernel/bpf/verifier.c | 11 ++-- .../selftests/bpf/prog_tests/ksyms_btf.c | 57 +++++++++++++------ .../bpf/progs/test_ksyms_btf_null_check.c | 31 ++++++++++ tools/testing/selftests/bpf/verifier/sock.c | 25 ++++++++ 4 files changed, 100 insertions(+), 24 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/test_ksyms_btf_null_check.c