From patchwork Mon May 6 14:18:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cupertino Miranda X-Patchwork-Id: 13655523 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BFCF13D27A for ; Mon, 6 May 2024 14:19:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715005179; cv=fail; b=aO5DUsH+BQSiUyNm28wPp2EkwDcVyJREzM0q8/kn/g5ByQTng5yNoKJKmE2dYc8C2tODDMsVxEyZBZP2eB/PDcxAOpVfeyFFSACQrhy1qTljxj2uJ89DXlyDyHfmu+v9Xq6kImpQtCSckXysZtucv+nSt5VL286To4aqDYeqLFw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715005179; c=relaxed/simple; bh=7T+D9bqjxOXTOETxk6ysIqz5TeQBL9q3F/S+6B2+HMg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ExBmgSNixgxki9PBOl0J+bR3I0Bwat0ZL1H/dIlim+FplAtOdl7SBrJuXaxhXrIL/xQJMb3FBNVV6birbRUhVfxNLUtXDQV3BCu/ke0J97PXCfxKsVRLjOgY94M9HU7ZJBReSge8DLkpG/oSDz+K9dGjYTNPOptqSz2iDZeS+wI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=LO26I+ZB; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=e6HzEzoP; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="LO26I+ZB"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="e6HzEzoP" Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 446AmxSS018884; Mon, 6 May 2024 14:19:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=ldl8ijx+ZFAEE1ICG8DsIV3lqNvGyrJ/4SlWHtRnnts=; b=LO26I+ZBQ48RthWDfIlTHT+ElxN7evXLu9TaFMz3SFYuqrOA8PlJuhznBmiSOyYz1e7f oZi/QcB4sv6eGhsqLSfXA+Mfe6JuY1cBpL5AP0P/JaLTunMionFOvY3CDiKDX9tviTR6 c4CQr00ev/5Nmp2XE7tsbMylOjPG9Su/BZ4pXQAWQQiZwmgMhW1K7fNiUFrV6sAdvr8p XkdFC5IsiCxAlmzrAjuHKag+Lp0vWCSYq+Y3pYkucFGzqZJNQZbYEedG/GDjLBMAzTde 2AecD4sC4XWCFcYx5r0EqVVbrXNjWmdt+Qn+x+XEjKQbxyZCovj+9KjnYqP8AXw0/F4V TQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xwcmvapnm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 14:19:35 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 446CsDdg040813; Mon, 6 May 2024 14:19:34 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3xwbf5x36m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 14:19:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l2Wih+l5Z8SU7aLK6VGNwmCDddcNLeVloJGay5pMbNfeBM7eHHgZczJE1cBEho97qexp9WtaaO/dQ6xd/ikmVOr8vlZcP/Arc9l2J4svXwIlklumXUoq2xbIVKGQSco6WrwTyqxPoBgohGmBfLTjPjjkuJM12iiwH+ou1JTHCV+jbgEBsRXIqhMeb9O1Vlle27bFudZvBfmDjT/Mck3lErmzW7HqB6JXm3geHyyH7jMmMq0hCzI/2m/u05yFVWGtvWd3/ssv33kUrhO2aZXKPFcZljLIGxKupSqXvZPoD6Re4813W6aXcuJ8pWE1tDjyw54J19TfK5aCA+bZYP/JTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ldl8ijx+ZFAEE1ICG8DsIV3lqNvGyrJ/4SlWHtRnnts=; b=DgURiQzsW3MBSJX/NGbacy3WfVdtE0amBCqvheBClHVhlFpfTW1tHdLqY/o+UrNd7ZPHY83RGj5Z1aclsPfQVbWAj058ri+LbpVf0iHkWQOcRUXj/IoEylgxEVYRQtyIly+Fpy6VgIHT8IehSlud9kBhbhAWEluWc0xhjsDuNr83+Q1oOcKCr3+rHuNJ9FpJbJu5crltqCpQubJyVtyhDHZdWNWlML7i9c7GwpYD0HTPJGr2pV7L/jpwO8XEZq+aufH5iidK9N7LGujNJzwRknxaFcvZ02KUv9NPylv1qvR30Y+b4xr7O9sdJ05GZMh5DoveudDVMnveO9kmmxfhwg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ldl8ijx+ZFAEE1ICG8DsIV3lqNvGyrJ/4SlWHtRnnts=; b=e6HzEzoPpXQt2mz5uLHxqfr+jbbeTvA6s11ALAmVhWFmAEH7tFZACUzNM2y1lU4yP30RNGhISc6cWZF+SkpP4OLzs8nOdaTZCkxj7gPjE8/sWNeQJqBKiLczFJkoOA5aFYpaa0HbK8X+Ivs/iDHRLgKc6cv7cR/7PK22CBPIUBU= Received: from MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) by DS0PR10MB7173.namprd10.prod.outlook.com (2603:10b6:8:dc::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Mon, 6 May 2024 14:19:32 +0000 Received: from MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::1e11:7917:d2c:e44c]) by MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::1e11:7917:d2c:e44c%4]) with mapi id 15.20.7544.041; Mon, 6 May 2024 14:19:32 +0000 From: Cupertino Miranda To: bpf@vger.kernel.org Cc: Cupertino Miranda , Eduard Zingerman , Yonghong Song , Alexei Starovoitov , David Faust , Jose Marchesi , Elena Zannoni , Andrii Nakryiko Subject: [PATCH bpf-next v5 1/6] bpf/verifier: replace calls to mark_reg_unknown. Date: Mon, 6 May 2024 15:18:44 +0100 Message-Id: <20240506141849.185293-2-cupertino.miranda@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240506141849.185293-1-cupertino.miranda@oracle.com> References: <20240506141849.185293-1-cupertino.miranda@oracle.com> X-ClientProxiedBy: LO4P123CA0538.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:319::8) To MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR10MB4382:EE_|DS0PR10MB7173:EE_ X-MS-Office365-Filtering-Correlation-Id: 6245d265-de44-4849-aefd-08dc6dd78c61 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|376005|1800799015; X-Microsoft-Antispam-Message-Info: HtYWH6lqCvhd5ijjmF6CeM+s6cYgZLgydKxREs3zMOixlZYA6LnCiMHt/X462wkjGe21GtrlPXnfy0IZxD0QNo4aKdtEhmyj2bKmbwGCXTRTuHc9eCEOmZwhruI+NR0xg0Qj5gcqZUw2T64c37tD6hKs36ikJdIp+ArVWi4e8PsRDh4gUJ9Tzi2Efg9LrubSTrqyPu7FU1nWjc4nxkc01utRnXHV681+9757joSm16tIazih0xA6qHp9ZypFtnET2aeCul4WiR526l37ulSnzxnSzJvArf/RBEaQysR6OMIIxi88HDwF169C1YlEzmWgJDk0L3zeC0tLrc2MBuj/+mj9dUGTc3VGP5S+h5BpX8QspUnTT6SiZ6YhNLNLRKENoiCO3MTxaLNaT2rA3IXrDf1/zibRuXxO3jtwtsTA6v2r8w9ErU0DiqqEExN9AaK3Xf7pFZfU3UTmVk5J0l1peWJEw52nftqnXBmTLwxhcqQIS+wvZgFCMIffTwVWI+aYR4ANiEWtQmBQqSDdCnoq4rY/q5gLz5+XTUDieTVSgs1QZQRYpCuWB6rkRFvwn+PXRa6CQAY/fHHaJsQEOdov6klV7qnIsCB4TUQrGmaQd0VfP+RCaf1o6/DotubPCljw8r83Qm/ryowmCBe3tYO8Yh6TkeIWQ38+2Ld3Zw1MXdYFTnksIQvK30DgsOCqjMXK236yEtYNGCR7aYBPjNhwEZFVHEiFfsdl0Ptzp8IDZ/jnc/aNp7rAp4JlVhAmEOUQK84KIVCX+1UirJBdgUW3edMUM/7dBFd685xJRTfSTcn0lfwvEKWFrG6GInf8Y4R+aVIDbPuJsMbCMsdEuDu4GhuL7GguLbtmquiwGJY3dvY8Wd8kAVdr95q2tjOeh4+j4mcsU3uQrltQ2iDSphF2NmHhUDi4kG0xzXouC74kDEShtOtuz7ub2eOY+Hi0sMHAVW+45YPn0dpsaxAH/ot6T4X86PK4tksLhFmV0Yqwdx20ZBmRJ8URwUV1Ak8To0t2WuDFicbQ+dCuCjigXwD4/TneTY62ixs6TSnP+C2j5UWb7aR1qUQ85LnIgcYGmcNAyz8aOoriMV+3iMxP9a50O1OxC81HE7wMxvMGICwPwcCi5lPOUuz/qiLyp7XsRvLKzHVVE3XV5nE/41AbH2+NjgA46hfa6ai2uaXsqQLZVRwtnNNcDe3bdcBbwudjBIFbDxDX6SuaAEApScD7lsIpgvxnI8uR7E5+WZEFT8xHp2EITsnkPoL36z9OulAyPDMVGeczJ2Oa2+5LqoJ6Ds9fXw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR10MB4382.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(376005)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-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KPYvzZX4uDDb7OVR4erQ4Ess8Z5TtBPHB+5rx6fKvTYgpoCoBHyONIHDtxrAIuE0btGolt1A3uVyk444ntL2T5Fskg4FIeG0u9YeUl+kAndHjzlKOtKv/UXcKvrkkrBJw+y8/I/Zx6zPznZtjqyUziQbHi4pBb4+uA8LEtTgcd2+M87yz0eeQdEz+4Rq8dSPJHjoP2QULkY0DBFJfUaa1lPt0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6245d265-de44-4849-aefd-08dc6dd78c61 X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB4382.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2024 14:19:32.2184 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9Esds6wgxtxaeKllPsDbJ7meAta+MB9Ber95vvVEwzF7yBwUHSWDVzYlfPf310OPq7GMlb2a5hiL/8sGTM+1MJdiycut4vgeMx0cSnnz5kc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7173 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-06_08,2024-05-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 spamscore=0 suspectscore=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2405060099 X-Proofpoint-GUID: iYsOuCIz4vPKRAeODCd323bKoE3_5bh0 X-Proofpoint-ORIG-GUID: iYsOuCIz4vPKRAeODCd323bKoE3_5bh0 X-Patchwork-Delegate: bpf@iogearbox.net In order to further simplify the code in adjust_scalar_min_max_vals all the calls to mark_reg_unknown are replaced by __mark_reg_unknown. static void mark_reg_unknown(struct bpf_verifier_env *env, struct bpf_reg_state *regs, u32 regno) { if (WARN_ON(regno >= MAX_BPF_REG)) { ... mark all regs not init ... return; } __mark_reg_unknown(env, regs + regno); } The 'regno >= MAX_BPF_REG' does not apply to adjust_scalar_min_max_vals(), because it is only called from the following stack: - check_alu_op - adjust_reg_min_max_vals - adjust_scalar_min_max_vals The check_alu_op() does check_reg_arg() which verifies that both src and dst register numbers are within bounds. Signed-off-by: Cupertino Miranda Acked-by: Eduard Zingerman Cc: Yonghong Song Cc: Alexei Starovoitov Cc: David Faust Cc: Jose Marchesi Cc: Elena Zannoni Cc: Andrii Nakryiko --- kernel/bpf/verifier.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 7360f04f9ec7..41c66cc6db80 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -13887,7 +13887,6 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, struct bpf_reg_state *dst_reg, struct bpf_reg_state src_reg) { - struct bpf_reg_state *regs = cur_regs(env); u8 opcode = BPF_OP(insn->code); bool src_known; s64 smin_val, smax_val; @@ -13994,7 +13993,7 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, /* Shifts greater than 31 or 63 are undefined. * This includes shifts by a negative number. */ - mark_reg_unknown(env, regs, insn->dst_reg); + __mark_reg_unknown(env, dst_reg); break; } if (alu32) @@ -14007,7 +14006,7 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, /* Shifts greater than 31 or 63 are undefined. * This includes shifts by a negative number. */ - mark_reg_unknown(env, regs, insn->dst_reg); + __mark_reg_unknown(env, dst_reg); break; } if (alu32) @@ -14020,7 +14019,7 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, /* Shifts greater than 31 or 63 are undefined. * This includes shifts by a negative number. */ - mark_reg_unknown(env, regs, insn->dst_reg); + __mark_reg_unknown(env, dst_reg); break; } if (alu32) @@ -14029,7 +14028,7 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, scalar_min_max_arsh(dst_reg, &src_reg); break; default: - mark_reg_unknown(env, regs, insn->dst_reg); + __mark_reg_unknown(env, dst_reg); break; } From patchwork Mon May 6 14:18:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cupertino Miranda X-Patchwork-Id: 13655525 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89BDC13D27A for ; Mon, 6 May 2024 14:19:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715005197; cv=fail; b=uLE1qmAW8CiMASngwU4j4ikyGzO+kRQu/Nx7YKsvZdM/pm4YfJox2u7bfsZaDb5ZDtGSdiN7VKwZHufEW3yHzjJ0Xdu71Q4GGORwqEPr+Ckcoeei9r5p4LLT/GTA/3KAKUOH5sNMdLBDiSZoITvllx8mLG9suvA61qCXpHRcASU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715005197; c=relaxed/simple; bh=DmzynKk2F0OgXOpF7EV78lZUH/49paHxl1JzQK6ua6k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=fCBRDVQA6jlto2Jdm6itp8SiRaEVs+D8/0rO70xOirVeFDXIed1RNwPdyb457narrwf6Jk1Wmvq3JKoU0kO+r9QOuX/s0L7UY5aiuzLotSV1wnbEaQ6ktUL+hsuZfVGBULkkzCLmUAfMJN1S6v9OHU82gTcYj0TCf/DRXquxd1c= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=MTrJKFu3; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=J0Bl+fT+; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="MTrJKFu3"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="J0Bl+fT+" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 446ApMtD010297; Mon, 6 May 2024 14:19:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=QqjyogT8MYYUmhVSyaQvkXeZGoTbapDwI8LTq+OM3WI=; b=MTrJKFu3D4+UFBJSX2sb13qgEXczwbTrNSARPRttYKXuYbNNiTWallV/xW+IaOso5WZK oCUlvRPpigv1IxTQfTmNMl8mpreN9BZOXsAZt/BCC/hE0sCDj3I59upJRKpofuxfPXkF QElE6xjqIDVBvToQd5Xs7a2SVU671p7XUTqtqbrhrHpwwmzCB9pP8sXltJoIKJ+pwVrR qrpq/cFbqmorXUYaaQMiVmWoUMxarJjBPXprprdgbIa5Px/l0bn9i4IlsYyom7WJEN7e N4FxsH0AUzTmLY+aXl/LejL0lqZakl28wu1DzLHzFIlEP3B6OIREZyff+jhODbdp0DNO GQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xwbxctqrh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 14:19:50 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 446CeXff027671; Mon, 6 May 2024 14:19:48 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3xwbfcxa49-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 14:19:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=knaVoXbZgF4BSddmil+rNPI24ku/eNKhozl9fIiReHm7OuPmxhZ3x5Ardlk0idJ0mdr0kuYhtgIP6afTp3b996NJJuQS2r+xt7cib/kRUL0WFo/U7z6/4D28PgvDfuxrAt9RaGNS0vhsl3vTgEq6hFMzYmOBi4DFfhC8LZoBabMN5QUuRxtkSsR4tU9fkzl1LgBL5RCZ71mS++BJXwb6GrYsin1s8cHECKeovOjwQm5HWDvZv7aTFCw50DUY2Sy4A5sXQFDiT7w34DeIxTFTnCNRTwR8MHbbsO9I+yOMRPd9dV1STiDhxKLafTCzDMLgDsvVI8sHa9JT7G0FeB0Nqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QqjyogT8MYYUmhVSyaQvkXeZGoTbapDwI8LTq+OM3WI=; b=C72WWNAzbpltXZE8tq8CTI2c+zQ+RNRtTKqIOIYctUtWEaG/kNgXNXXniO2xLy3zN0wJ0tNNVPkzf3rlAjoP6kTZkJhtkqrh/h54RVptsB8OV66FlAR/KVh5vPDa8qI6+iwfu5gU0tEvFSCcrmTKNyG008q6h+JwIjg21bmsspINEA6LchoLGT8a4yDISC1XR/Fhz+GDOQ55lBsCmNQ9RKdrRSFSTd79QT6boHrl4eL7BILnPgjJljMjCLqQITiy6dkTgRdv5AOUtAHCaL+C6dBKgTuVa07e2/Wc4gXd1AU58+5D9Tj0CorH1iD8959yRB4ySj47n3BsLMa471YUUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QqjyogT8MYYUmhVSyaQvkXeZGoTbapDwI8LTq+OM3WI=; b=J0Bl+fT+YrkR9HULF5F/w5T5wcC0/fq3lN/KSuj2wHGYbNXHFqx573po0R8ExyYaL+ZpDE5WIkT5fstn6mG8soVw8pqY8r7DrbPdCiRCUv6k6cPAB2tA6I3LF3oqCCh/oBENlH9b9LUdn3Ph+f7etrHGMqLK+BIsoRmlltQFGd0= Received: from MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) by DS0PR10MB7173.namprd10.prod.outlook.com (2603:10b6:8:dc::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Mon, 6 May 2024 14:19:37 +0000 Received: from MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::1e11:7917:d2c:e44c]) by MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::1e11:7917:d2c:e44c%4]) with mapi id 15.20.7544.041; Mon, 6 May 2024 14:19:37 +0000 From: Cupertino Miranda To: bpf@vger.kernel.org Cc: Cupertino Miranda , Eduard Zingerman , Yonghong Song , Alexei Starovoitov , David Faust , Jose Marchesi , Elena Zannoni , Andrii Nakryiko Subject: [PATCH bpf-next v5 2/6] bpf/verifier: refactor checks for range computation Date: Mon, 6 May 2024 15:18:45 +0100 Message-Id: <20240506141849.185293-3-cupertino.miranda@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240506141849.185293-1-cupertino.miranda@oracle.com> References: <20240506141849.185293-1-cupertino.miranda@oracle.com> X-ClientProxiedBy: LO4P123CA0593.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:295::8) To MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR10MB4382:EE_|DS0PR10MB7173:EE_ X-MS-Office365-Filtering-Correlation-Id: 21ac3af9-bbe6-49ae-73df-08dc6dd78f56 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|376005|1800799015; X-Microsoft-Antispam-Message-Info: xLxac+/Pmc8XPMjCtu+Jz6RXhTRgUA16zb0jGDWsuhvVqQqHFLx8HG9Ak8HNf10EnAqblEQUMtwcBSSSYQEa70qJTtX5273uOjmys1usaJ+wpRfXtDiJCBSSImfhX81lNd/CBI1lPns++LW9oc1rr3LW1kaUitJckxi0vcFdwcj5sevdjWehKbg1BpwqgKENe6flWDPOqI3RnlBayOo/1NLv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5jl7LYmB4RjA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR10MB4382.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(376005)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zL766TwfLcr73ahaE1rCWF4cOcJaJl2xthoNm9YGPgOHxtaJ9E8NCkQjUKK+T+fK9KnzObeyy9ocQUwH15bct3++M//JKcl3PyA5OOl6eqVbT7zCi+CRuUNrcymDWjWkhYKaDk2AtY12B3fpLRUgT5wQz2sCzke3Va1oEWbtAT6GmSvlB5lBDobZGeWEp/9ivMt1ZhGBdFVGkJ/lUFDTyjBHio2/4pv/tydGAc+t70WoM0agdMUy0k6AEdWsX4jRXzS7uxHfK4yMPdyy139wS+MqiM6ZHLyJTxOzxsLULYfNGbQHKxoktwr+JMqdDoKJSeY2Hp4pWG1v0oDP2d9g14Q81BBohToBt8gqebuoCt4bKnjuFZzSAukyskwMcBFe61eRZ2P7rGvRhkRfnFytyMCJieCSjxXyv9lF3GSBXpNw/G8Z9ZQVbA1QaYkg5XcAJODFMIDA/Ndp9/XOO11lwZTlbOiELx5O7ZOKKg4REP5kdz8IzuC914YG+Rqqtn4RsK+gAkX7fjFIQIWnpOXC+PVn6OCGZYulHeXFK/DJM3dTeZCMOH2jMyK4YyFG9mjVd8W0i5TTYEAm6nrX7YjPTISe0m791YPdZyarKjWmGexw//gn70MIDjNkJxosx138cNHzElwPGDWpXnVH9Q+NS15KKUOVy//FdlppE4MoSOAa4KC/iCDlE/QGmcXbqu3HqXjEXLV//M5/1mxAWR/IPO8wPYjTcR4dAgP3a8ADRFT2f26JTa0vN8nPtdD7znaTe47gacm3fLl1Vs5ADqzqn+OieRexxLPxXGOhXJpO0WBtSFG5bDfBc3WYCbNffkBivJRCXG/FBXPuU0anvDcPMx4uX8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QVHmSDzCzwxL0N1Ri4UHZe2N/MkDX9aeIWIcbdUz1+bsgysoUv0xDr4i79kRrMnVRVJMXCT7+NBWohO/PJa7t0DYIG62ayD+9w2/CjQEX+kQoJ6+H2vgdZf0ZruqiSUbo8dUs6BBiJVkM5RmL/RXZbKllraLmPO7jgZpc1BRd/QASs7UHtWp7e5KF3Dav89B66DbP9aSiXlrwayBy6ucL7TdhriwmdGzA8ynsCz0aMhwCo0pHpkWj9pMDtXvSkAqtQwm+D/xbjgwI5kxPe4sRknhkpZL5fz6svCZDCfgisLoxt3mUsliuI7oNwtBtH/6iMLr9BxoxJX1mUIaN7tKlAkWxahVsiDgHHYJ08wu/3HRFlaSrlsUAjUD4+wj0aCbQiSPc4MSXhyHhRtI0vbp0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21ac3af9-bbe6-49ae-73df-08dc6dd78f56 X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB4382.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2024 14:19:37.3483 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Dbuq42Fhp2Oy3C0krZA6I9ug2fspn0pxwvYDxR/IsqNb4Vjb2cuaLu/HsMklfXYUK5eiD69aqsh9dtGP9uzRVZanTb+GT9KMCFuGWt9ueQw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7173 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-06_08,2024-05-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2405060099 X-Proofpoint-GUID: HBjfWRSgapsbdr1VA4N53GWrn07Oa1dT X-Proofpoint-ORIG-GUID: HBjfWRSgapsbdr1VA4N53GWrn07Oa1dT X-Patchwork-Delegate: bpf@iogearbox.net Split range computation checks in its own function, isolating pessimitic range set for dst_reg and failing return to a single point. Signed-off-by: Cupertino Miranda Acked-by: Eduard Zingerman Cc: Yonghong Song Cc: Alexei Starovoitov Cc: David Faust Cc: Jose Marchesi Cc: Elena Zannoni Cc: Andrii Nakryiko bpf/verifier: improve code after range computation recent changes. --- kernel/bpf/verifier.c | 109 +++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 64 deletions(-) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 41c66cc6db80..bdaf0413bf06 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -13878,6 +13878,50 @@ static void scalar_min_max_arsh(struct bpf_reg_state *dst_reg, __update_reg_bounds(dst_reg); } +static bool is_safe_to_compute_dst_reg_range(struct bpf_insn *insn, + const struct bpf_reg_state *src_reg) +{ + bool src_is_const = false; + u64 insn_bitness = (BPF_CLASS(insn->code) == BPF_ALU64) ? 64 : 32; + + if (insn_bitness == 32) { + if (tnum_subreg_is_const(src_reg->var_off) + && src_reg->s32_min_value == src_reg->s32_max_value + && src_reg->u32_min_value == src_reg->u32_max_value) + src_is_const = true; + } else { + if (tnum_is_const(src_reg->var_off) + && src_reg->smin_value == src_reg->smax_value + && src_reg->umin_value == src_reg->umax_value) + src_is_const = true; + } + + switch (BPF_OP(insn->code)) { + case BPF_ADD: + case BPF_SUB: + case BPF_AND: + return true; + + /* Compute range for the following only if the src_reg is const. + */ + case BPF_XOR: + case BPF_OR: + case BPF_MUL: + return src_is_const; + + /* Shift operators range is only computable if shift dimension operand + * is a constant. Shifts greater than 31 or 63 are undefined. This + * includes shifts by a negative number. + */ + case BPF_LSH: + case BPF_RSH: + case BPF_ARSH: + return (src_is_const && src_reg->umax_value < insn_bitness); + default: + return false; + } +} + /* WARNING: This function does calculations on 64-bit values, but the actual * execution may occur on 32-bit values. Therefore, things like bitshifts * need extra checks in the 32-bit case. @@ -13888,51 +13932,10 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, struct bpf_reg_state src_reg) { u8 opcode = BPF_OP(insn->code); - bool src_known; - s64 smin_val, smax_val; - u64 umin_val, umax_val; - s32 s32_min_val, s32_max_val; - u32 u32_min_val, u32_max_val; - u64 insn_bitness = (BPF_CLASS(insn->code) == BPF_ALU64) ? 64 : 32; bool alu32 = (BPF_CLASS(insn->code) != BPF_ALU64); int ret; - smin_val = src_reg.smin_value; - smax_val = src_reg.smax_value; - umin_val = src_reg.umin_value; - umax_val = src_reg.umax_value; - - s32_min_val = src_reg.s32_min_value; - s32_max_val = src_reg.s32_max_value; - u32_min_val = src_reg.u32_min_value; - u32_max_val = src_reg.u32_max_value; - - if (alu32) { - src_known = tnum_subreg_is_const(src_reg.var_off); - if ((src_known && - (s32_min_val != s32_max_val || u32_min_val != u32_max_val)) || - s32_min_val > s32_max_val || u32_min_val > u32_max_val) { - /* Taint dst register if offset had invalid bounds - * derived from e.g. dead branches. - */ - __mark_reg_unknown(env, dst_reg); - return 0; - } - } else { - src_known = tnum_is_const(src_reg.var_off); - if ((src_known && - (smin_val != smax_val || umin_val != umax_val)) || - smin_val > smax_val || umin_val > umax_val) { - /* Taint dst register if offset had invalid bounds - * derived from e.g. dead branches. - */ - __mark_reg_unknown(env, dst_reg); - return 0; - } - } - - if (!src_known && - opcode != BPF_ADD && opcode != BPF_SUB && opcode != BPF_AND) { + if (!is_safe_to_compute_dst_reg_range(insn, &src_reg)) { __mark_reg_unknown(env, dst_reg); return 0; } @@ -13989,46 +13992,24 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, scalar_min_max_xor(dst_reg, &src_reg); break; case BPF_LSH: - if (umax_val >= insn_bitness) { - /* Shifts greater than 31 or 63 are undefined. - * This includes shifts by a negative number. - */ - __mark_reg_unknown(env, dst_reg); - break; - } if (alu32) scalar32_min_max_lsh(dst_reg, &src_reg); else scalar_min_max_lsh(dst_reg, &src_reg); break; case BPF_RSH: - if (umax_val >= insn_bitness) { - /* Shifts greater than 31 or 63 are undefined. - * This includes shifts by a negative number. - */ - __mark_reg_unknown(env, dst_reg); - break; - } if (alu32) scalar32_min_max_rsh(dst_reg, &src_reg); else scalar_min_max_rsh(dst_reg, &src_reg); break; case BPF_ARSH: - if (umax_val >= insn_bitness) { - /* Shifts greater than 31 or 63 are undefined. - * This includes shifts by a negative number. - */ - __mark_reg_unknown(env, dst_reg); - break; - } if (alu32) scalar32_min_max_arsh(dst_reg, &src_reg); else scalar_min_max_arsh(dst_reg, &src_reg); break; default: - __mark_reg_unknown(env, dst_reg); break; } From patchwork Mon May 6 14:18:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cupertino Miranda X-Patchwork-Id: 13655526 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5423813D60B for ; Mon, 6 May 2024 14:19:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715005197; cv=fail; b=d0UU9dUTzfp8m7F8iWWBFro9dgs+CVRD7xH7SAD1pmOOJadxQBd851AZfeEQJLaQ6kPdnUk2jUQikcjZCpiSfFv8gl/OceDex2fOBdc2CoQxzPMi/tIEzNx+Qd+GHa9uRPYXVihZEE1q4TuxU4+KF9XrbV9qz2dlxMvybQLq/2E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715005197; c=relaxed/simple; bh=G4T0Tq1x82AedsTtU+M91VqIPFUUhR8AKtkPB8QDvOY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=HTztwPXxiz78R0ojTa5gXlZGY0Z827MBQKA+uuH/ZkbBrvnnoMI4Ixh/CAYW/iN87xXrLlIFYT51j3gDqlvfMYE0Zo8ynFSB6msTqukQmLxIOIE8bxVJXHrz8bkvFVoI5o+qUuSLZA3vCfiBWnmVN3T99h0RZNP7bDexbU6x8gw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=aW7sflxo; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=ygSMeET+; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="aW7sflxo"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="ygSMeET+" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 446ApKql003270; Mon, 6 May 2024 14:19:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=I4L5nhkZOTYqOB0+F6HrZHK6EkgCCKf1Yjm9r5Q/VWY=; b=aW7sflxouZTtOlvejmI/g/oVqmN8PyszHQW1eFLYVwDMenQsKG1g7OWKHyRGpyjpfrJa iObmrIGzDoAZpQ+5aNRx6uvn6fAznhNCYaou8o77hBh4D0ABxqtLZWsJwqpPCKJqxZq7 VvRXLUr4FC0Cxxi79FRTw2gmHNO1U2qVaA5+20VDbYPNc5Yjhxk/LQud+ShFqFXVPLGv FqI2217aEnV7Zz4XfgBtBKuite3EF3sjsCaIYCL0NUOhpibK2nXFcyGZ389rUjJ4jBS/ eIjfz5cYd60oClPQCqiFj1mIs8SCyGiFFcd4OYdTn8ECVOCstuF605mhOYGD8+255/4H gA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xwdjutngk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 14:19:51 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 446CeXfm027671; Mon, 6 May 2024 14:19:50 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3xwbfcxa49-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 14:19:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EXvssO3AX27wRbT8NsCBTFP7lM5uIAzZ9H/LAKc0jzLuvGX1jhoh3HPScGGzJcEespcqpagFpV/z4cV4ytCcdkKr70r6eZ+uxAM6lnBVnsPcM4bgHTMPY6tF+8VGVPoBi6VniBDTyzgAlhudKJRboyO2LLzALP2PJM3zZqAJ/grWiI6Cep4aVeKNM2odExb/01bKrMNJsJSH/5EMmJIQ3FzoG44M9gz5/FXBwJm/jfM5hzaEu2H3bFTVYhXC2aS3HZFFtR7A/2omQcdGLphCAjDMRDQdP6LCi3/bjBA8CRTr72Wxnc9j2zmrliUVHh+2K2znEWAvLpns7zbL6ypwSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=I4L5nhkZOTYqOB0+F6HrZHK6EkgCCKf1Yjm9r5Q/VWY=; b=DUmIznnDSyEK3KC4+HpIBlqYD/2ohBMM5sDxkQsYP1zvEawrf44tXb28dDru5qsg5oiHKPGmpwxRzDLAhmDuux3SHowoPyf3DY5JOZyMxmSxVUTG8KjqZXC8+NSbWp3xl4FLGfduqihETK1vbcx67bxF7WR2A1S2I/P8be/BTSfxYh1/89gnXP3Vc0KZrLzaidMaZyt9DTPsQ/kskUCG9AVXhun87zt2iw46gP8ifEJL7n0dnctcNU42fjdu4Urt0UCGP4/p5vY+Tjhe4e48KxRHYzxJE48Z10Pc0JagxJv5biq2kzYnuZ/Uo/X1EO+sUNSdifQNQy9r/zKnblaERw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I4L5nhkZOTYqOB0+F6HrZHK6EkgCCKf1Yjm9r5Q/VWY=; b=ygSMeET+1JzRSlz4SW3qMt15wOhVdoMKV3n41K7NqScBzSVuO4oWznWQ6GtESilZUvovJslfBzEaXLl3Eplg0EmDqgV3slUzZqlTSQ6Giu/5ywV5RCLH9YKS7jHPl9ImQN1lXoplUWNSb1XuJGM7dyif4Woiy8mwMN/T03j4os0= Received: from MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) by DS0PR10MB7173.namprd10.prod.outlook.com (2603:10b6:8:dc::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Mon, 6 May 2024 14:19:42 +0000 Received: from MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::1e11:7917:d2c:e44c]) by MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::1e11:7917:d2c:e44c%4]) with mapi id 15.20.7544.041; Mon, 6 May 2024 14:19:42 +0000 From: Cupertino Miranda To: bpf@vger.kernel.org Cc: Cupertino Miranda , Eduard Zingerman , Yonghong Song , Alexei Starovoitov , David Faust , Jose Marchesi , Elena Zannoni , Andrii Nakryiko Subject: [PATCH bpf-next v5 3/6] bpf/verifier: improve XOR and OR range computation Date: Mon, 6 May 2024 15:18:46 +0100 Message-Id: <20240506141849.185293-4-cupertino.miranda@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240506141849.185293-1-cupertino.miranda@oracle.com> References: <20240506141849.185293-1-cupertino.miranda@oracle.com> X-ClientProxiedBy: LO2P265CA0095.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8::35) To MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR10MB4382:EE_|DS0PR10MB7173:EE_ X-MS-Office365-Filtering-Correlation-Id: 1d97d6bc-cb7f-4b83-b8d0-08dc6dd7925a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|376005|1800799015; X-Microsoft-Antispam-Message-Info: +XinQioeRRXnJb3W3Shf3hAWSeRyByj3JqwL+UEtRZPaZYrLe4I1/4bwGzimIt3ddicLD5dZOpRWFMnKIOeFiu+lXENhRkiZH0Ea1x3Ol/0YsF3yJNPJHkDtRUhcH31bylOwCTOrvKDVQLLcsTN/YC5gtHuEX6ctaFVAaR24aRCtSVvywUfLL6/6wEGika3p5I+U0rMkle+0U+n5qt+LB3sFspSla6LmZFeMPEXqA2o47nGUTqlrkDcmTlBtlCQYn3KV9w1g76WpFnaSp//VxzZWt/VdIjCGVVGAysc7C4j1hGoPqZDYV8d47aHoswbmIRz3p8FSngNqGzsQehMlk+PrpIEAelpU+mNiA7ZqZK55a8Q42FoU4H+r6e0nvhHnirapUW9ZcoBZMpYnORFOoPvdrAh13fg9alDKr08yozNCiXIVLt4s03wr7t/HchspDKkOQUrG+iJtMTbwiNzMAofPGeP952WOlA/FTvjUzE76G1qLCxNob3pWMjObpSAspsaZ4c3m2yRHUUK6Ho4PjibBMJLeaoFYG33xrIzwGsvC55WCIevgFI+WquGjsLlStTz/hRZSuqn42vUg25fApM5Fwpust1pwfHvihIBU88CkXchj2RLiN6/5sAvTjUu+5/ABX2sEPSGXZMjVORBfF/W5v2hu3HiIMLr6PSAdBy41H1nx7EcJjib9IBsMsC9Cx80yKWG+gQxTGtTM40htYtVaeFHjFtIOE7tZIdVoukKPcR1FC2ig/DZq1XDaJMdCLEWDGSjF5FAaa6z2Op3O3Y2WQYpB+ImqcrPyUHigjRuNyeYBrreApxnB/F7g1yqfdDlM13974x6aLqjepDNxgNDe0x0dAugmiZ+pYE/QtfFYAaSst/iy6sCMWnqnKe6fvIC/oEQBUzYuW9TBwaCUY7M/sz5vtWLHukq+i+2VwQRPdAUVniUiqEKr0zMVF8RY5tpYkz/EPUboc533inXIJ1ezX9Ej7K8tcdcUwj9EdmtHxkmAtg5BA01GA9+slc7BIuEKFA35jRcQVfZbfXo4qHWoXUkFQjgpiotciHjDVFVYlXi7mtNDk7DldW24FcWLY5ALPdIJFvbU9kKM9ocNyt39R+8t4sZlfpo5JhYVa8qyo7/uEjtvok/5caSprTkjhjflFBhNMvArcj51+EsQmAZO235JB/MDQxHtVnz5aDwfLhnt+mitwRV6AOFXYyXS2z6zHRhcizm4JqO4WsKoga8eyyYnc1pw4RTzjg0KgSXYm9G5bsLzCLtw9aD/CmVj4aHC5TkncEBhQEe1CGNa8Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR10MB4382.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(376005)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ijXywxGa1oM+Sf2o3YtiMY9/xVDc4S8R1Hz4I2mn40a+ORo0y0tffFfhYlYUujhM9l9lANVrUVMhBf0fyQZRkC9sToSMku0l07wWXpZPK8pYMso2wfOz4AufvcWxPLLXazZ5fqn9ie2fIdk/w1cVHVeKTlSzLG8nP9v1OSs2GvwK3hdJlDWo2+Y3w2No1pRs9NzbK4yfmJJGdGtFWzTbJtQGfYMHbpNKNvN3NoTxgTk+w10lBtZSiCKeXpmJEn+1JP5aid7CJg08gXmIOxO7Y9yeLnajYvmUhCyyaYKrLSMpBfCQ8KiKsixy1UY1vgJ6C0qaycGDIFdXil5OU6EYjboo83jq4Uhjg8fA0KLY4cJOKK9rCbwsLrqysfJ2QNJ0nMxe/QG5uW8TcSnUXldmuQbf/y1CeIBfwfaadl2IZvfUqRHH0ciskL9uK6IuVO/JVBPzgHNDZRylvTJGG17vVNVs2T0PiCCwUWH81rKGHrbPc33v1oScPHFw5EHuZbAeNuemvlhA4W/Twri93yqw3aGM1uIzxLe0SN/NpeOBxoF+rmdRsa9xABDbNG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-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: pWg/QEzzhMAx/3wS+o4MGOs2c69F9TTgVyam2XRYuRWwj7bVJ9ho07fUoOXnAbj6JvKHqH0fc7sS7ISn69zbsse2SDXR12kP8SdU7oDWkft6ZlxQzdu0mRYnrPNnRe8yZxEdxTY7FzX0KM4yJQ1YmRku1smPvQQ3TxYQ6LS6Z9EYoRSKeb9Ag4y3SHAwjPDRdQrCExuv0Kp2GbSaUpO76pON++wTsoGE1mpI21g1Pd3j7u2o6HEGAS3Q1XZR2cjrVjn3S+K3faftfOCp2G+Hc9W8GzF8/jCsPYvkYjDJibIcj9DeVdtrc8Um5X+2Rb8dT+KyxBm1oz3/UTmpkMxE3p6lyKEu1Slgz353pgC1p2/ZdUdbitdOAjJcBQa+Zg0L5ckEy48sandyUkOME8m445SVrUM/ipV3FvotS4sFYHKZC21/hcvmsCP1iHhozJVc+ME8Zuhjkzg1XhsqvLqLENqaBjOxX86yVpt+3x/IT1gCAHfqSHANRNRub88ZdTu6kfnl9I1bzcp7D1MPJowp17QNyBVsNuAVbIAeWQnt4CdIZthUcKH0KCNsjhN7j+WcgkWSoH9TtvaWppqOjhBE+lTHvSJnIdw/I9yXPzyjLRg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d97d6bc-cb7f-4b83-b8d0-08dc6dd7925a X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB4382.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2024 14:19:42.2993 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZnMBxbTCf50mHZvND/8pGUNJqAqIMfeKq1eLmgXAKIqJ4JM/bCU5FRDYUVWeKNG/NZF+iAmg3zyd9j+ohFbmSMPR2WIvad8W8piyaM8OA68= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7173 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-06_08,2024-05-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2405060099 X-Proofpoint-ORIG-GUID: 7BNvRwMDN8AVvc2lAyXkxC-e-SJNhwA0 X-Proofpoint-GUID: 7BNvRwMDN8AVvc2lAyXkxC-e-SJNhwA0 X-Patchwork-Delegate: bpf@iogearbox.net Range for XOR and OR operators would not be attempted unless src_reg would resolve to a single value, i.e. a known constant value. This condition is unnecessary, and the following XOR/OR operator handling could compute a possible better range. Acked-by: Eduard Zingerman Signed-off-by: Cupertino Miranda Cc: Yonghong Song Cc: Alexei Starovoitov Cc: David Faust Cc: Jose Marchesi Cc: Elena Zannoni Cc: Andrii Nakryiko --- kernel/bpf/verifier.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index bdaf0413bf06..1f6deb3e44c5 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -13900,12 +13900,12 @@ static bool is_safe_to_compute_dst_reg_range(struct bpf_insn *insn, case BPF_ADD: case BPF_SUB: case BPF_AND: + case BPF_XOR: + case BPF_OR: return true; /* Compute range for the following only if the src_reg is const. */ - case BPF_XOR: - case BPF_OR: case BPF_MUL: return src_is_const; From patchwork Mon May 6 14:18:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cupertino Miranda X-Patchwork-Id: 13655524 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 859B913D264 for ; Mon, 6 May 2024 14:19:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715005196; cv=fail; b=eOXN448oaKWuJeFCK9yd6c4HWVjhxOIkU76fmGt4kcWxWIZ7Ftt7uXywqoi4eR1mfqf6qPx1FFuc3nBDXPoMKtD+8fHUalr2ASF8B0OOVymysbaJ9Oi2uCdywz9PI8IXnFNpg0TZDRnl85S3b3l/rv42nFek8Qt1HEWyXtJKSB8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715005196; c=relaxed/simple; bh=mULoiXPrd5uqIQWzHgwRdZTMRgB9XVz1dHMj0XBlUsc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=n2nGVpCeeNmlUMAl71ECWSlB1FLUX6VoWbdk4H4vRKQZTIr8LKtxp9nNCQ7pnBHXZZwkM9C3zBcoEu1BezrNCVkYzTJIYBcpC1eexVhVjupDrmcsmd+UVyWPj1QEKnu9tpPUoVpyvh5H4iBOeknVG7gNV+RRoiGBL/3ks8TI8JA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=WIiyxJ9U; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=qVbU/WRh; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="WIiyxJ9U"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="qVbU/WRh" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 446An41I009277; Mon, 6 May 2024 14:19:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=uWPAzeAJ5UJQJrhIs3Tg6LiCfVc10E5WWADrJQRgstI=; b=WIiyxJ9ULKM5t2YBRO5GWkNXLOK+8/kl6DlxVVkeT8G85GeN3ciJJsgQH3yQmBv708GZ wsWheDqYmEuFcRxI+IxPDpWHL9fmf9flCbES7C1ndgKr9lJGnPC5E2IDHDf2OQduVrcY hZrnLj6gDImN/g7Y2vW+zf4csM4tj19xxF9O5Vo4cpYAXTSun8E+f7wEqDTX0OI8+U1M PirP+eZzW9VI7bSeWjfcxVprglIbe98ISnfq+bELUGCe27S9NqFu+mBbELnSKF8Di7oE KWf0EH4MVzSh2ulV+fPPs3+KsX+LJXwNkzOngTkalsN46cYARhA1CdJpYMHQfMZI2hbA DQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xwbeetq4d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 14:19:51 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 446CeXfn027671; Mon, 6 May 2024 14:19:50 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3xwbfcxa49-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 14:19:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K/wwsM5sFAlZ4wnkMnYooxxGN97SFFb8oGTFYBWUBBvvXgm588/Aa5Q4Qz8N/UILFRmwQauF2AJ2csqhP6fH9mNrjC1zYzl9mlMs9ocnVcXqJkHi74SAxYAeCu/fz+tTNdL5Ej4W1swubVg1BAEtqTQicwQJ/iEXcVoyvgzQup2A52iWQr6D6z/bEwniyY0TI//3UcVhsZgA6JI16XK85I2DGoqDfSn7pfS8BEA2bw2KQIX3mxkbIpSD9oAwBxWe/1GGHl0DVCdBlOys7lvn8B19ljhi8yJsY2axmfm1+2R+7wvtaFd2kUfvXIlsP1c5lNajwsfP9tUEF5npuDh2Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uWPAzeAJ5UJQJrhIs3Tg6LiCfVc10E5WWADrJQRgstI=; b=HPuOP6V+jM7J+LQeMpBwl5E4pEOSqwpp4UbOpr03TDgbla0z4C3UHi6kYExLTsSX6FbTPfD3WsvHd2RDUlQb/7OFk2KF4nByar7qb1SKGJMYI0nEVgu0v0BVh4qKFSrTep0UJJVoAQC69VWakbiw/Hiiq4Rwhbj2ol30pSB8uqUXwM+y9zf3q5+tqVlKDj2xCQg5gSz5xoHWn+N/iIOA4RNOwQSYvK/p6uryO0DJIYc43Sw0HwPU27oFKosj5stacQ9Fah/vpbmL1iggbOO0rnJtdGQd487EdOPS6ARINN9Frmbp1dBSC8PBNLHPeJGglbQ0VZ+MCqr2sjznHEMTWw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uWPAzeAJ5UJQJrhIs3Tg6LiCfVc10E5WWADrJQRgstI=; b=qVbU/WRhOIms+peCphlfjVnj/9YZqkBBRtjRUc6uEqoFU1uLTpG8HdS/O/DnCjCdP411nNMsk8+RoPoZKDUD5dbXHoy7wzmzcfacuZcJ1GGg89B3Lnn9qADDTpYKUiyVASfgzejtp9X/t9rxatepaDviLfaDrdpyGpIUczyelKc= Received: from MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) by DS0PR10MB7173.namprd10.prod.outlook.com (2603:10b6:8:dc::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Mon, 6 May 2024 14:19:46 +0000 Received: from MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::1e11:7917:d2c:e44c]) by MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::1e11:7917:d2c:e44c%4]) with mapi id 15.20.7544.041; Mon, 6 May 2024 14:19:46 +0000 From: Cupertino Miranda To: bpf@vger.kernel.org Cc: Cupertino Miranda , Eduard Zingerman , Yonghong Song , Alexei Starovoitov , David Faust , Jose Marchesi , Elena Zannoni , Andrii Nakryiko Subject: [PATCH bpf-next v5 4/6] selftests/bpf: XOR and OR range computation tests. Date: Mon, 6 May 2024 15:18:47 +0100 Message-Id: <20240506141849.185293-5-cupertino.miranda@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240506141849.185293-1-cupertino.miranda@oracle.com> References: <20240506141849.185293-1-cupertino.miranda@oracle.com> X-ClientProxiedBy: LO6P123CA0023.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:313::9) To MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR10MB4382:EE_|DS0PR10MB7173:EE_ X-MS-Office365-Filtering-Correlation-Id: a0f1be7f-1934-4e07-cd21-08dc6dd794d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|376005|1800799015; X-Microsoft-Antispam-Message-Info: +1zOAyttKteqQsZcesGXams/xFajnGTUUiQ9kQ5jgllGAJ+hP6rZ0II2K5sCRUryqXjq1YHmWWN4pKUvCGcqO+iK/cfb20CbTdTHAFzcz5t6RwaQPEw1wruE5QysnYgi/rS2gvk29+NQeAD/yRn5ax4j5Zs82W4FTfp/uOMWt1eievNakRqs/qWOQ00GQmWXL/b6B028vFkWhFvpYsc8pSt9rzzeNzUV1hiA4sOkNJuYCd5diWfvWcDpskvG6T9KEx57+eaCSX88bQkbllYVI4a4IZgpQsmqRAwxYKPZEKVcmToFCudz0THSXIfEYmbYvOTv8/iepsy1duvz+5r7yTtgllY5CtPndv767wEtSpwnRKhGGuTr5IGczWrflnpR62OfshYqEI2dKDrUHNwshn/b+m3ZYvH+6QQ66IhJInrUOTVm5jf8TIsDzaxgytbYbTzLXiVxTytzNZ02aKHuC0Jsnhe3dvFmKrBJYD0J33dwfaRbRBX52Zd8uAnzuxEAvbLdKmcnO5CNXu2tZOkat7ijmcyYnBeumyHlRGkkFK1JUEGbeGRtSgPIjvV+jRJH/TBIQ/HPk+PXYS784ySkCpDJEtkbzppjGawlL1ZXzxxSYC39PmS8VdeuUj5q3rpnqWLvVkI87/vuuI/VeDPRK2ZQmFvG8QxPSmQ6ikerDUkzDXoYJomeC9P13M2e4l8Gtf44kt/9AvXlSuX5C4mlv4ZVoPv7NjCLdfD2fZHXbLK0t2tt598/X5YyXk2nqMd0PBgrOTEXYn8BPTvT96SG7pBaOeT+Uz6sFep0HuRH3O1FPokNWPtMLk8kcQZImdqPhJ03jkRIEsa+orvA2LjrLhssW6e4xy6pKlSCFBDidLdWIGGXKIt/9NCX1SPoUyngul6B4kSvKKFe+BKvQZFez6Uyzkrvw4wDFwRa0YMSQRdn80Hn1I/Dxiqx+rtssz1ij91g5H4hVwR7oRSSPmkRthmHr3oMc8M181iBbcTWHOY+raIZSxziY4GDVfHie7onDgmkxGIz90a3hHESmBlyTW4/EwF5sW6/0yn8+Wf0mj2GMclOqNgOWqEJfU7MhbYBq9gby9LnLiZ7PyxtnqH8pVlvlRvSy0qaSe8HrWG3yuvlsmoeyhXm77zIAMX/wJlc83P3gTdl05oJx2AjAGwoJkAyMIIGKda6F0gOOAcanxF0WaG3Bm3d88Z+DRP1FPIx5pCS6cGOpqmx1I0nYGncoS1JdeX7eFSjU/7ab4aSquepe2HVGszdMxNjlcs/F6SjVnKR+Q+cSdOr/b+g/tA5QQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR10MB4382.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(376005)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WGfW0bxyreQU3qrd0PMTRgjnJwzitpYZA3nm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BbLGiXOWnxhQYB3InmZmev31T8sIW/bI07mpgCD2RqlVtqxF7brK4SIc994ZXCfK9kQqogw0xv45m+yK+PjoNTnz68ukZDJk0a2CBta5Lik4V2UaPfld7S1IqI9UohSV4rOJPUNQtVc3YACPj5WhZxi2snitCi4V4pfP3zQPq0HYESXeTZxBjMmfyp10FUh3GeJ6jVFdED/UOoWKvFHp0gm3l2jHYFxrVpdqVOnRFepXVmbsGNkri/IcMRkRBWrq4wM20covCOXv9zXmCPxRq5pg3MNuL/8trRU6lY/S6XFiMQ14g2qHrWFHy1ZDNmQhyLJXpdMpxmPNW3dIsCGvVcpFWPp4udntCr1RFABkMkfXgYKZELfUAq/Bet1OTlpCnMAN3Pw2RKumXXpPy76BPP31z8V30XPI4RSZm8rxi2ojvZyILvX+mzcALnzjjBI4ALPmsjedVbNpafj2nc1KVE1rXhTwuIBdIXSWSKxtCCBTsilRYsxurFgy1S1rqbbY= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: xdKAShJfMpDTmQvtOeryKjDaQZJaPktFiXizcJTMauzbIQLikQTScwe5ZRh3y588Nz1UDjwZiWCVOe135c1lHG3/jYNhHCwFrte7N3Nzl+SxvUGcyaDEabmDY66AW0Ld5RkPW7vNiyCepaoifdaX3EEb0SmVC+qx6o4rdDYMG6y+4Gr8IxjWDC+soaq7uy3ViP2+CtP8CAbd0TtO9qW1p97rA7ovi24OqE5r2m6ixv+s4ik/hgFLVps4uYJwt4xdfrJrWqSwDIQ3IKx+lYsg/FfFraMjNOxoCFzpssMBUTeG4KXigfsmOtOVoDwtKW/mBUPCBHZvGJJaQmgdWrXLHe0YfoX1kcJbGFFqKBXfJst8jn33gP3KSl2luutHzP6DuzDGOaAJcIY5YkEiv116IN3TZukI72Y+SPcuJzscytALYdl7sRKafrOEuFXwQnNz2sIRtWyaDwOXfYfYVcv8MMhWEG6vS8K4EUiI4ZjoofC/5PvBrBXMcmQKCIbQn2YgHgAH7vAC+xQdBNc0wOAh2BI3RoNJuemZNme6R7n9NjAcS/cPzbIbTKukJQfbmmKRsuqWfTyYZJiGqs2FWsGfHofK8g7jIlfCTTMLW5FHV28= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0f1be7f-1934-4e07-cd21-08dc6dd794d4 X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB4382.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2024 14:19:46.4275 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NG4FbeU73visg9bCbW8BTQNgh2iGAYPR1LKqpRXU7dQqGN098lL99Uc/vd05CFVCi3+T6yg+917QyVS8oIDBHAovLAWqbktUXrNaQbLrD0w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7173 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-06_08,2024-05-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2405060099 X-Proofpoint-GUID: hrejfeno_OihQjurK2Ib4E7_gpGouUTM X-Proofpoint-ORIG-GUID: hrejfeno_OihQjurK2Ib4E7_gpGouUTM X-Patchwork-Delegate: bpf@iogearbox.net Added a test for bound computation in XOR and OR when non constant values are used and both registers have bounded ranges. Signed-off-by: Cupertino Miranda Acked-by: Eduard Zingerman Cc: Yonghong Song Cc: Alexei Starovoitov Cc: David Faust Cc: Jose Marchesi Cc: Elena Zannoni Cc: Andrii Nakryiko --- .../selftests/bpf/progs/verifier_bounds.c | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tools/testing/selftests/bpf/progs/verifier_bounds.c b/tools/testing/selftests/bpf/progs/verifier_bounds.c index 960998f16306..7d570acf23ee 100644 --- a/tools/testing/selftests/bpf/progs/verifier_bounds.c +++ b/tools/testing/selftests/bpf/progs/verifier_bounds.c @@ -885,6 +885,48 @@ l1_%=: r0 = 0; \ : __clobber_all); } +SEC("socket") +__description("bounds check for non const xor src dst") +__success __log_level(2) +__msg("5: (af) r0 ^= r6 ; R0_w=scalar(smin=smin32=0,smax=umax=smax32=umax32=431,var_off=(0x0; 0x1af))") +__naked void non_const_xor_src_dst(void) +{ + asm volatile (" \ + call %[bpf_get_prandom_u32]; \ + r6 = r0; \ + call %[bpf_get_prandom_u32]; \ + r6 &= 0xaf; \ + r0 &= 0x1a0; \ + r0 ^= r6; \ + exit; \ +" : + : __imm(bpf_map_lookup_elem), + __imm_addr(map_hash_8b), + __imm(bpf_get_prandom_u32) + : __clobber_all); +} + +SEC("socket") +__description("bounds check for non const or src dst") +__success __log_level(2) +__msg("5: (4f) r0 |= r6 ; R0_w=scalar(smin=smin32=0,smax=umax=smax32=umax32=431,var_off=(0x0; 0x1af))") +__naked void non_const_or_src_dst(void) +{ + asm volatile (" \ + call %[bpf_get_prandom_u32]; \ + r6 = r0; \ + call %[bpf_get_prandom_u32]; \ + r6 &= 0xaf; \ + r0 &= 0x1a0; \ + r0 |= r6; \ + exit; \ +" : + : __imm(bpf_map_lookup_elem), + __imm_addr(map_hash_8b), + __imm(bpf_get_prandom_u32) + : __clobber_all); +} + SEC("socket") __description("bounds checks after 32-bit truncation. test 1") __success __failure_unpriv __msg_unpriv("R0 leaks addr") From patchwork Mon May 6 14:18:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cupertino Miranda X-Patchwork-Id: 13655527 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C047B13D62F for ; Mon, 6 May 2024 14:19:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715005201; cv=fail; b=XIBL4pLqJdnpF/+q0SjLMn4IUIrRv0KbEo7hsl2f7hi6g+t1JALMcQHhDhbGKUzacFyIpDCzoauv8PKpRvS7CacTVD6BSvghVEegJqgQLWd5RWQcAriSiWN0NTIlp25292LhAfGTO+Ec3dzmm5/7MQ2iM3HjnO7u+yzOInrgZ/0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715005201; c=relaxed/simple; bh=Z+GTNCEUFUoLKGxWAuSx3nUofbCJFb0HqjLC/2OyuYA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=NRgAefOcdX/bUDzuHQcMVysqguLZcvKuvuN0NsTOxSYu03Bi98+GaC4Jpdra5o1Y6vD/c6L1P0Pdr48K6ONQFf//SBz6iaknNO3UzWeIilibiYLGdBzD4kzbyGFkHkkbXDVEGhK7xpUkkvLBFXL3nBFGTecmkGv8usdPaIwHnRk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=DRU0nk8p; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=jWK3SxYl; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="DRU0nk8p"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="jWK3SxYl" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 446ApPnu007369; Mon, 6 May 2024 14:19:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=zaCv3Qxnao2ixnnQX6IWakIgSmmtcys23kIqwMW1PNM=; b=DRU0nk8pxCLdWvooR3Jvjqh4gu3STkTeg2E8QSPtjxpFQABOaTPtqJPKoX+bICzFgwHI 49Lqd1/d8s6prbkjWsRicycOgC5jITPkq0QH+aEu49nx2PnTeMXIJ+BVhfMJ0WrJDSIU +m0uJ3+BsWaq4OhkVGKVF3kYLKiy7Fj+bOR39ZABeyL3oDO5lnqNVd0VOsf19U8uLRSy zranzFHFmLNZDLVeOIxnm5fv50TaI9xNzCpAFYcd/treQSYjZY9yxZqgj1cKaF5nBiV+ JfVrh+VrK7AAnYiZd2nB1LcXYu2GDJmz54iZSnG8ofhHFH7keC2nQkR9278UMXal+89W Bw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xwcwbtp8q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 14:19:55 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 446ECorE039417; Mon, 6 May 2024 14:19:54 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3xwbf5ph6m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 14:19:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZWd0OZVqAL+jHfjFSmFkE/cUPn9hUbIG4bWq9DwqCdKjZDEuq0Mdb2SHD+DC6dwbx5gqu8TWdwHMvcv2RMKhZ7xzgID6rMB8qmKp3lKSriX2awagyTl6OA2V1xDO4qNWEbh3MtLmuzpCWGipf4jruCdkq4+TONIEsZLl9MkJWWOJFAOwLhTk2aAB3TkHBvS6vI+L1VpiSqvvQBiMVB9YjTsE1hTIePXf9s88X2P3i4NC4kHQhu1nz/DV7yi7udmB1oev+21tAWXNI7jdH3e1v89KfHRrtqif0Muk9TAucVdVfphzymXlO7qVW93vaclpzFZKAmy+mReW+Ht8TIKcug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zaCv3Qxnao2ixnnQX6IWakIgSmmtcys23kIqwMW1PNM=; b=jmZyfMusXg/M/SyXHjbW69FuXRAX5o07oCdZuGylcttmPrdlMLytlUqFpSY9S+x25t5G/ieU8yIE5j0QAhQSBtlJ+9UILG4lktZjViiJdi41exoqh9eSl5Gtvi3p6QZ41jr9XTPqCKJ8EcASvxw5BXCH0y0IEMRXnAjDipXeWxK020ZbP5wwaUo3nZcCaIseFSObJ9imAtwu/QjXjAQnUxn51FTGVPmxh/7IqV1TZwGxR0huVrBy6/YwV2D7hQCzNcLu34lc0LgSd2/KTHmtMYxRHsZsl7+3n1KO6z6p7OZA+Ckvu1DUi1ypbyZvkdYbj+ubyIc6b8LllK4dmlKl8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zaCv3Qxnao2ixnnQX6IWakIgSmmtcys23kIqwMW1PNM=; b=jWK3SxYl4ZBr25AQIj4dnUlld6vWGgNuJMFIuaOmWXE4WFb8gnzIPhihctZM+acW8ady5TtALKPjfLQVMBKNt0L8D6gx0PDF5eI4J5Sn4v120BuuB691lpua1JM7aEsC7gOA+OJkmD/SiOVHI/7ikqQkbOUUqCIOP44DWBKLiek= Received: from MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) by DS0PR10MB7173.namprd10.prod.outlook.com (2603:10b6:8:dc::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Mon, 6 May 2024 14:19:51 +0000 Received: from MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::1e11:7917:d2c:e44c]) by MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::1e11:7917:d2c:e44c%4]) with mapi id 15.20.7544.041; Mon, 6 May 2024 14:19:51 +0000 From: Cupertino Miranda To: bpf@vger.kernel.org Cc: Cupertino Miranda , Eduard Zingerman , Andrii Nakryiko , Yonghong Song , Alexei Starovoitov , David Faust , Jose Marchesi , Elena Zannoni Subject: [PATCH bpf-next v5 5/6] bpf/verifier: relax MUL range computation check Date: Mon, 6 May 2024 15:18:48 +0100 Message-Id: <20240506141849.185293-6-cupertino.miranda@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240506141849.185293-1-cupertino.miranda@oracle.com> References: <20240506141849.185293-1-cupertino.miranda@oracle.com> X-ClientProxiedBy: LNXP265CA0010.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5e::22) To MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR10MB4382:EE_|DS0PR10MB7173:EE_ X-MS-Office365-Filtering-Correlation-Id: d172c9cd-e438-4bd9-407a-08dc6dd797fc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|376005|1800799015; X-Microsoft-Antispam-Message-Info: OcXMzaV/pAsIkkd+Fqd7vQe3Nl/lrRq20do3Fp3QaH0eqKkvsVUCM1URfuzwpHg1vM0NrKbszryiM/AlIvOgSvW2im8OchA8OwY74GAGJzCpdYHa8W5rk/upouwgVKNRqivAp+FFM0gv7TPZ1nQLGI3sH9IkUBP2e5Nue8ZG+tn0Jn+0QHcMmIPw6GzOk6k9ImVIuTv4Ic7V6RCA5+MJScr+6fmLUow3iBnMD2LBCA2qijNX87cXstJ0j86saA1z8IKKT5nFlqqhvRg3+YD/3N5+JkpRJuLO/GU6HvAuRvOAZD9Y5Gazx0vflBg/rvw86FYl+/mqjYQIAJyYHWV5XRIpm5ErQ32inYKsGB/7+xO+yfdjjaX98uVTSNmHASD8I/SZXt8PVYPsU/JiL5Qo2TYkXaPihg247JtKAYu5bFMEpeO2vYAKsRW8apyC2V6gYCF9ZYqOY8np9Vmtko2z8zRurwr50S/5uU5QXXwimeNMjrb4UZ4409KtXiOQ7h1OVlnzIxLhNuoF97HwugHIsGX2OmWHR7Eq6cjLfkiEV4/Giv8femLPTmFi4rSK6sQqSy1cMvecFhE6wqzsOtx7TP3dbPK3JPoTWV7foCHax39FQ+HN+HApXaYPhJsWefcJCpIpMSIJWJW2Dgbbp6rO5K4Egvot8vWegcvrwxVW2re0Gh/48wnVBMxHK9xK1rVElSEEG4olAtJ84nj4z5mBkPf4OvQ8D3h9hROIQCJnT656Veu22vt5M5agagguHLGjrbZwxznLy7kX41NOR4LJ+jvHvS0BoA+BOcNfEI5uaKWnoPJ11m/w416J52DAM7zLBVncOKbnToH6ZU4DOl0+iAevwl6NXQQZvhaHp4Z6JjsrwOOCuE31dzOj4fPCaiwLw+B1HOBIfTJAy4JYb8sSO1tXAVVNl+cXWzs6NJniW5Obwk4DzloSv4J8oU4kQAE1LdFA330vwtvILGk214NC+/vgylNaLgfLBwjdUmeF78KETv5kJrK/p4Tv2u8n10kCbXNk00NC+F04OFJ22Oup221E2T3ana10KJdxuCu5x8GMZdJ5mPnBZ0baxrKJIUCK9hEfyyP0MWr4CG+Lw0I/wtCsbiDSqoAXPAiCpWeBdcs5ZDVpWJiqnTMHSbGhN8dNsWb1khvnToNuf00ORr14PDKfXilA+zFCTsrn8twLKe6F884WBHotdTFJFBpGiqJqjJZdc31wXdjterQN339n0vFlKOyZp9U9zkyzLrm+FODCZhX87/uQuKWBbIKHlFOMAyF6lnP4HSMQ7vTaU6YgVQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR10MB4382.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(376005)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cVkPyzx7FDG5hSLvktNhIbgVFKEy5MEs1PMjcHqXXTRIE80iejjoGN1NrcIR4LygmO3TXIv2YmL3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BZFFLvXaZ0/6OaGcHOH89YhN8roaTaTL5IfKqliyM9VA/QNkVjU/w7iWe7+IZHpk2beQ6l8HFUswpv0fBsb/YOFtggobxj6qv2oF0tyYclsDhZZXkOTO4bu6jsydaWnohm7khqwbczAhx9LGmxAqcWwJDnSnn492R7f7x/6GA5k5yTgm9mAoaHzsyKWfXCu8dW1a3vM+9U+xbO+YZTwUDH6AMFialwUEUGvHjf71krZ/uNlREekJ+f7txfi+SRvTvYRIPeSGk4u/3RBV1lA0oIgt5UNaNZz+huQm1YYCE5S3oUbQCA9ayv+x5PML6JDFhzqXmuZQTa1MAS01p8Nrfb3/+MAVJ1d4nf1U3RX13o/sKjxhUB0YLqGIoa3ye/Ghno4uUh4EscUGvJW+VQjR3VHfbfrv8SyHFfQKXQ92UC40oCwMN8Zh02nQ5VN5AfkGmIoIOMDkZdbAC9/i/Daz7FCHMR4sfM= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: hlTqM0McW2TbFR0dVvH0bMsxqyOl5X84uuDksLo0yKZp08qsbV6wsqEWkrsjYD4u0S+4AECjkDni+k0T/hOqYvdn13hab/fVinKIOSzJPISYsgEfSAWXxNVOEtRWsySEgniy98/J/XuCqt8EPINzHEGOEDVQXby5rswbz21eUWrx7wyce9KYEV9eJ4jIbwo8nXdy3C90QcIzgfka1syB9XNpSz03JBJtjU8nT7OhYa4oAWkZCnxOrIuA1CgJidTkXTCCAn+UVTOp8uB3S0YDxQw635SUX8UqYPJaqauabDFxH7omT38IhIYPloiHGcOnWytCTVKtEhDgOorKf7GT37AheE6hTV2w1/E/iAsgiTFQZKQiPCx/h/EfmkPS6rIynAb+/U+6OQCKYVr/G6613Fyi23u9QrsdVqx1X5ZbOncJ9QoyXfudOb89pE1wHxiTwB6u5TV39FHebtV5qo5I/KmdB38+aE7zjCfQr1/J7Z7O2gkzxs2Q53wxCNBblrxc05JLUukis+HyWQuNRElhOjfYtxOGtgRTRIfCFPdCOiT7P5HJ4Sii38rvPQnTdEZXcxNkarqFRX9E1gOa7GZhB5lp2j0csW1nGuprX+6cgQk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d172c9cd-e438-4bd9-407a-08dc6dd797fc X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB4382.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2024 14:19:51.6389 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /3Y5QAkmYYyRSQkgTyHkNvVvcYOhVy7kKXvwLoVkHG7rwp6FAWRLMGBBD8buw+RSWvgWMnwPaxKKdx4VNleSfRUvio2AI9vVImCHVmESQi8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7173 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-06_08,2024-05-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 spamscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2405060099 X-Proofpoint-GUID: HtgLdOMkZCCOHAS6kIWJMg8xdC5cENxU X-Proofpoint-ORIG-GUID: HtgLdOMkZCCOHAS6kIWJMg8xdC5cENxU X-Patchwork-Delegate: bpf@iogearbox.net MUL instruction required that src_reg would be a known value (i.e. src_reg would be a const value). The condition in this case can be relaxed, since the range computation algorithm used in current code already supports a proper range computation for any valid range value on its operands. Signed-off-by: Cupertino Miranda Acked-by: Eduard Zingerman Acked-by: Andrii Nakryiko Cc: Yonghong Song Cc: Alexei Starovoitov Cc: David Faust Cc: Jose Marchesi Cc: Elena Zannoni --- kernel/bpf/verifier.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 1f6deb3e44c5..9e3aba08984e 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -13902,12 +13902,8 @@ static bool is_safe_to_compute_dst_reg_range(struct bpf_insn *insn, case BPF_AND: case BPF_XOR: case BPF_OR: - return true; - - /* Compute range for the following only if the src_reg is const. - */ case BPF_MUL: - return src_is_const; + return true; /* Shift operators range is only computable if shift dimension operand * is a constant. Shifts greater than 31 or 63 are undefined. This From patchwork Mon May 6 14:18:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cupertino Miranda X-Patchwork-Id: 13655528 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D91D613D638 for ; Mon, 6 May 2024 14:20:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715005207; cv=fail; b=QS2D+ym+6xm+h7R2CXhnOTQqo1PXclAX1H0RgwFcREg1wIxpL7bvtgGk0BkxXlsEcWIp7vcX6TZTUIADdWXBF0k1qUt2Tp/MfKswVWZU5nqkHKdJSTdRRhdV1HP7yA8XodUgmEjb4TgJcbu0fifoV9iWi4b1XteVsx7qzv7Qv7E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715005207; c=relaxed/simple; bh=e9GZfrVZ9TWTBM3I9LNLdhOy6o5Ec44SW+IiH9NYMoY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=lHJUkQru6opa/nat2GkcYvBJJfs3VYv0IeMLmuHNlAcK04RnTTmWXuRIqfXNYcsxXS1pxgzQSHtgvrn+CCEbCPqDQZcxObjhFkGKJpNlxJKRXXtOdWQtpQhYmeIJkJXSdsfYB7Tu+Tc3YfD07kGVF4BD4blluDfHi+z0wNgkT3g= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=SUcUGw6S; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=h9oCPKI/; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="SUcUGw6S"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="h9oCPKI/" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 446ApPnw007369; Mon, 6 May 2024 14:20:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=hYwwz27Zbukx3WAk8qtWHtwpOeq9/1oGhCzFI9Q94w8=; b=SUcUGw6SWQeylbZJUXmb9a42rKLI1nPC6Qo4PdQgwYjpJOTB1a7dqMnuhCwSJa1d7Bt6 T3JzSyK1E7yuWJvjmc/1pO1fLAhkILtc8EUJk0iqrsCbmZ6zeVfFZYoIkAt1ZMTXtXLn kGqux07FMLnpq44ZGojSUhYFkVddRXs2pCPwH3uC8PpibaiEr3YuWxbYvuxs5yuUKOZ5 dpYVoNiVD2R2SWZmK8v0odWSjdapHNKGVinTPAIye6iw9BL/1sWuOde/z/VEcWjpyIfI I7f37dhvK93tZF26R//pwcPGEqED6WjdRYirMpQJ9Uuli/8Q+e12RtqQZz9r+JkJhkNr 8A== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xwcwbtp95-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 14:20:00 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 446DWrdG006940; Mon, 6 May 2024 14:19:59 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3xwbf6q5hp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 14:19:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E052Qo6aHwpNZRPqMVDgso0qOGwhDjhdNQnFmEdpL8XX/lhYVW6O0H8epshKN9M+dihL4Hc9SRl2/BX+BPoOmjrsrvwcgPu9W0K95mtk8GPZ7bwjTMqjsAowjKRzLWjzbnRu5JdoMzXEepxc6sOpoAfGWO71CmkoM9QcON1891PUfhFz6KvC5D/a52Ye4iAzCf/NX9IQXokMblRi1HPfz7eOfEnJj7DemhvnZXS7WQVUd7AQdCJ1hanCLCRKmB4eZQuLHbMG0X0+M8KgJFdbwnx1MFICK0aXwB0z4dFOGurXLfcwk2FfSt4UnnfIa+BLzfRKPym2EJGeq4qjnc8jww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hYwwz27Zbukx3WAk8qtWHtwpOeq9/1oGhCzFI9Q94w8=; b=gDH0EbnDR3xty0kSayf/AMUbAcXxayFxUL683/1DesasOkVLVgSRYIDZ8GSvjmu8urBOpPDtJJSQWTQwNpsPLUILtsOGvfDe2TeN//HYENUFfGUKlx+d4tbzUlfP7o3H4t9jYDroYW31mIM7nqYHFGzIuAv3C99hfz4KZmkWa5P92ZCVllE4NODbqvOPt0eKooxijyYvbXsb5u0CnKjgYv9ONMuhRcUTUU9jGqbg4cSjviTsar+Zh0F2jKnRJW1UG8jqX1Qua/N1oalYAsHwAQ8FfUYIMV1dss89Fg5ZQ4jJpkMgkGi3CILcyMRvmLG3zvqx7Jyv+qnzzhyZr0q5Og== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hYwwz27Zbukx3WAk8qtWHtwpOeq9/1oGhCzFI9Q94w8=; b=h9oCPKI/72nV8DKvHeRmTmk08ojgkwP9mgKSQ8pkfrg/ET33joUtTJ7yigXxDaXX15xm4ry7w3obD72EG9izy+3MP9s6Mcyf8iVm5CHBL4Pjt784H+II6p/7Ytds3URH8jy2wHAS128gA79YzWOP40NtEYzYSH3g5cyXkCXTIjM= Received: from MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) by DS0PR10MB7173.namprd10.prod.outlook.com (2603:10b6:8:dc::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Mon, 6 May 2024 14:19:57 +0000 Received: from MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::1e11:7917:d2c:e44c]) by MN2PR10MB4382.namprd10.prod.outlook.com ([fe80::1e11:7917:d2c:e44c%4]) with mapi id 15.20.7544.041; Mon, 6 May 2024 14:19:56 +0000 From: Cupertino Miranda To: bpf@vger.kernel.org Cc: Cupertino Miranda , Eduard Zingerman , Andrii Nakryiko , Yonghong Song , Alexei Starovoitov , David Faust , Jose Marchesi , Elena Zannoni Subject: [PATCH bpf-next v5 6/6] selftests/bpf: MUL range computation tests. Date: Mon, 6 May 2024 15:18:49 +0100 Message-Id: <20240506141849.185293-7-cupertino.miranda@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240506141849.185293-1-cupertino.miranda@oracle.com> References: <20240506141849.185293-1-cupertino.miranda@oracle.com> X-ClientProxiedBy: LO4P265CA0169.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:312::6) To MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR10MB4382:EE_|DS0PR10MB7173:EE_ X-MS-Office365-Filtering-Correlation-Id: 65f964b6-c8d8-4deb-c4b4-08dc6dd79b16 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|376005|1800799015; X-Microsoft-Antispam-Message-Info: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h4sS1wKJ7wq1zW+Tw1lDU6qgiacU8ZzXunAsCiG88/jkG5SXbSFV90SDMi4ttsYA7ixE5gmiQTWm/2vezbj5lxkN/nRLNCZY12lA/PvtJ2xObrdH5LluQGCCZ/hW1P8au2Szqi1QVfM89XI6QmHeImTj2yntf3S1vRbTXzXUV1rqppmXmA7KnsTvjddXiIi1ukWVdWSOTOlCq3NJBO9YW37iX41+pt/l90w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR10MB4382.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(376005)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fNxrNNYctSgRlMeYhtGdPsn9oE5UWXH1cmag/CkDkBAI4WZBv+AyXt0ZjlUbyPY2HYyRywLfn3hNpj0zu0yDYy44OOo7g1ujKNyjoyKH2cfSzQemNbaZgqtbg+/Q4yhnSxi+Hf2U2Ql3NdcCD+ymIRH+2D/9smDHqWmPdXnCMQRzkwbW31aoM038ImscwTVAt7ZuIBbnCgTCuQEtvL8i35I2uWeI2979eVYAtK92AAmccQ8dZpQrbNR3TVO+p/tmE8tdYMgHK7T5jFD0qHIFmy1q68sWExg577Tow+iB34A0h+NCEsHkP6cTM4aBwfvrTJ2aUM+EsUsuGsq8MY19nnAZNSU+68idS4zfaJbc7czrjZop9C9Nh0jdu+6kkzA362mf+XDnu5oEd894GIIqwRwlDqJV9YBex4QD3/nf3p9/UQ8bHIubPYQVhmwcVH4pcNgr5jd4JgGdDPCOIV+D6ljenPyKaO3YA79QDz9GHYpHh/Llxa8JN7wwsPgncb5Fhlsx02rKSt7eLo+Pkm00J1oFvbcp31Hue9bbF+Fbn3iQGIBBpDiwLHDsorV0KFtLdA7hSWLmCRusnHzY2h1mQRHDRHtvh4ac8xO7/hVOumkV4sYmi7pU4oMBF2P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-ExternalHop-MessageData-0: 756uo4HaYpZht6ZYUpSetKhBRVxiLa5onPqwk7Pfe9Ti3YK8th8RDfuU6eSgsfN10UBOX7BiBm1rI5O568tD3iJIglmmYsaLMo+HIkVRbEEgcGrP8WGu7priwr2TiPTO5T3HkCBklS76yWyar0iAsdspCGAhxwTcl5GYui9PfkuiW9i1iXmwfLWzmgSZay+koXgLOf2Lt9qQIv57mGWaCFiHILh2RYC+LbiX4TIK0HEonYr9tDvS9BM1r2Va9qeGXgrTygVTTbZMz4NzCP8mp1xCnkwLRpQ/5Tp2fqfNO8mou9MzoGIdWq2TzlEahuCwbc/Kz/0q+EYUSjiqV1F5U6KbJbhyq9SPx0hop09W9u4QSjuGIBG+RFPpmRlydSitYJyjphOEdG0+icKha2/Wrgq6I/dNws4toN7hVmobVWNWVvFAV32yGhtoIp3OsYGLqSkFbGx+QUzeXo8Dh6iwjvtBMKJNVR4aB2oTybIA+4yvykKGkQUqSaOlKJwcUm32zV/KhNSSRY/uMjrlVclZbkDsqgNBlDHfyESdL6bNp1HNSTcjR5B/RggGHvHy1hGC+1PCmL8bsSkNLCySq7APH7076OumAl3F+w7wyrUzNFw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65f964b6-c8d8-4deb-c4b4-08dc6dd79b16 X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB4382.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2024 14:19:56.9303 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YdgBD0AVCi/vNnxKl5cvrBrjNgpMiFeeU74Vah406QLhd6h1jwOLvCRFKwLRYL93kWfjJXiL0vDLT4pme2ihFtSKfq5NyRXJRwaxgqpb3so= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7173 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-06_08,2024-05-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 mlxscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2405060099 X-Proofpoint-GUID: wya8-YmrBmFiIukCuzYO5S0kflule0hN X-Proofpoint-ORIG-GUID: wya8-YmrBmFiIukCuzYO5S0kflule0hN X-Patchwork-Delegate: bpf@iogearbox.net Added a test for bound computation in MUL when non constant values are used and both registers have bounded ranges. Signed-off-by: Cupertino Miranda Acked-by: Eduard Zingerman Acked-by: Andrii Nakryiko Cc: Yonghong Song Cc: Alexei Starovoitov Cc: David Faust Cc: Jose Marchesi Cc: Elena Zannoni --- .../selftests/bpf/progs/verifier_bounds.c | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/testing/selftests/bpf/progs/verifier_bounds.c b/tools/testing/selftests/bpf/progs/verifier_bounds.c index 7d570acf23ee..a0bb7fb40ea5 100644 --- a/tools/testing/selftests/bpf/progs/verifier_bounds.c +++ b/tools/testing/selftests/bpf/progs/verifier_bounds.c @@ -927,6 +927,27 @@ __naked void non_const_or_src_dst(void) : __clobber_all); } +SEC("socket") +__description("bounds check for non const mul regs") +__success __log_level(2) +__msg("5: (2f) r0 *= r6 ; R0_w=scalar(smin=smin32=0,smax=umax=smax32=umax32=3825,var_off=(0x0; 0xfff))") +__naked void non_const_mul_regs(void) +{ + asm volatile (" \ + call %[bpf_get_prandom_u32]; \ + r6 = r0; \ + call %[bpf_get_prandom_u32]; \ + r6 &= 0xff; \ + r0 &= 0x0f; \ + r0 *= r6; \ + exit; \ +" : + : __imm(bpf_map_lookup_elem), + __imm_addr(map_hash_8b), + __imm(bpf_get_prandom_u32) + : __clobber_all); +} + SEC("socket") __description("bounds checks after 32-bit truncation. test 1") __success __failure_unpriv __msg_unpriv("R0 leaks addr")