From patchwork Mon Apr 29 21:22: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: 13647754 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 7E1A51836DD for ; Mon, 29 Apr 2024 21:23: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=1714425835; cv=fail; b=uDyEWQnCPCOPbYpVASW5e2iRt5oDHBlIXWDZfNmFd4erwbNz4VYK/D9TaozqDsh3YV2oH1RlPSfNBV3CocPD5peG/xzKC9HDvtDKNBguMJqvS0A88PKXQVstmnKmn25okXMALQRq4O0QBXA1Kq9Ya9i0gv5RkpMILtXT/cs+EJc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714425835; c=relaxed/simple; bh=i1WEvAk5/l0Sx2OouKxQZPvr3Z3NVO/ibggQdsms8ZQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=kYV+4m5yA1AkIhqShTfEOMnvi3/FCCnPq6D3i+VWJSzaKHFlIgSw7Rqpttt5msl/QY5hv0k2kRul4Nx8WYKDtZtrqfGTw01xwOGP2qFAuYgsdjqfGJ6rfPRKDNnk8ArkGjYdFLEaDeCnazSWOnxWIGlHJ5vwGvT2HpopJKCspWs= 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=L1Yfk4Pg; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=IZMgFKDf; 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="L1Yfk4Pg"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="IZMgFKDf" 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 43TKFhcw015535; Mon, 29 Apr 2024 21:23: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=rUrrHaI67OFq2TQjWV/dILXIRUzE1IaaNzhCAY0THFM=; b=L1Yfk4PgFGgOncknf8gUqGYV2AE2A8xOMsDAKYTDMkKYdWWek8b9l1InoSKoXKNDT4qB nnBLWQQaAoui+TVZwVUCF3PKw1V7JkwMeuYR1DzQW7S1aFIiGAfhJwuoSUWNN1nu+62v FB5Xz6q2lkyvtfXBreL3+B9BtpbDeYHce0KmfDEf7kcbEFq447UC98lommE+eDp/GTM7 RxWvouudthOENIHObN5GekKiCK3lFcCQECHGEisW316xLzG+2NLZvC8I+gGbQJcHvTUo f6VunXeuvgOXRY0cXh3wgE2mvTpIczk8JMoWYervHLNSBVIQWltl5s5taxgh5+Lfvjql IA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrr9ckrhf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 21:23:50 +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 43TKs2wU005034; Mon, 29 Apr 2024 21:23:49 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3xrqt6g6wn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 21:23:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zsm+zZbV1eZoX0BGkrI6HWGZiJcaRT+cHwaa6yO26B9bNxg2Mo9dD2JrpQleAEiCeyWVSVdHmJpG4qS/x+LKZ7cHGHFlAbma8BRL8gsUMDR8BjkaLdkB+wtED6WqNPMqMtbLvobgkOGqkWnUImn44N5LDKAMt5bBePvAhxYO4z6MgzsUtAy8tDnLf1syzNuqzAe7i3RaUPbzx3+YWDNVOCl07U2GAJkzzblAMbhG2/wdiFhdgjRFmxWR6P75n02otnE5L9Gi9ZH86p4fUQ755KKtjS74zx7iwQXT2rJ0ca7brQG0ZKLLyf5yQgM4DVeqCrG+y/W9H2VQsjJl8l/Epg== 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=rUrrHaI67OFq2TQjWV/dILXIRUzE1IaaNzhCAY0THFM=; b=VRXJ0Cwy98HfrQcZyllVM79sJlCyl0283KI0/uPxDsT5aykQslGDoj9EfiNhQvlNIqXrJPXmdJ8H4ySljyPjbpTrHfp7knTO4Rc7NuHW5Inj2+5EwfSldRKukR15J2b8aga3N4jRLECjJB/6+mkBbd61WzEwU8DWRXzHv6EEjEYOlVRfKzs/q1PjfcOH47A1eX22oKDlMz2YtociSEf6VkBpkBPZTlZ4nrD9OTPU+WNMCKPv28TauR2jCVASLPZ0gvJYfQwBCuYwOuNJfkkCFeWRXtgiw3PhBQ2rFS0luRRIDHMha0T7id8n8BJXQaQrwHtni/HdhS8l3Bx3xT0Ehg== 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=rUrrHaI67OFq2TQjWV/dILXIRUzE1IaaNzhCAY0THFM=; b=IZMgFKDfUN1B9aWE2ayRZomei1gOfuh1FwssvDZ3nNF0uUggqT54h+XQo39l3xhh3TnKIjCdUGnP0XcmWCmEV2zmRH2rlgr6iboOxzGMH1bb8TBuJax9m3XxoROxaiOnrmzR7hz/Zw3zDPs6PFEiZI0bE5u2E7r1jA2H/y4LMEQ= Received: from MN2PR10MB4382.namprd10.prod.outlook.com (2603:10b6:208:1d7::13) by IA0PR10MB7232.namprd10.prod.outlook.com (2603:10b6:208:406::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.35; Mon, 29 Apr 2024 21:23:45 +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.7519.030; Mon, 29 Apr 2024 21:23:45 +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 v4 5/7] bpf/verifier: relax MUL range computation check Date: Mon, 29 Apr 2024 22:22:48 +0100 Message-Id: <20240429212250.78420-6-cupertino.miranda@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240429212250.78420-1-cupertino.miranda@oracle.com> References: <20240429212250.78420-1-cupertino.miranda@oracle.com> X-ClientProxiedBy: AM8P189CA0002.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:218::7) 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_|IA0PR10MB7232:EE_ X-MS-Office365-Filtering-Correlation-Id: fe1889de-921c-4230-a0bb-08dc6892a70f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|366007; X-Microsoft-Antispam-Message-Info: 5D2AEI7FLM++XC4RqYOFFsS0Ysc+MF/T8Z6okhZ9EKNKryg9Xyr1/BhGJBl0gPH8bB/VhEF5vTZIRNFRi3/Oh0HE0LFHug453ZHnwvcMql7zzgmQ1cLEwsFUoeQr7hvHvgtOIzrqZxY8XxHq9EEnzv/MQ1woxynDo/gc5No+7oxpFIXg9EJtJnR3J51NY+WjIo83zHIs2dq9/TMX2gRBRqY2RSaogParFByy5KURlBK0E6PM6oJEqS/ljjp/LEJWl6Gi9wwbZXJwnDtFSz5mBEI7LcwBVhuVrDF4rBMVxRK//PkojRUOyMZOnjjn1riRrXnHNeJnjWHWsid5ZW0oY19C3slXbjnD86S9YHkhY5WV0LNv7s+St70g6HkF7jcIMdvfBmLZOKJ5xPg8v+6eGazCl7di18EKnpp93Cok9L1MHa0PtgEtit0wYvTzGIgg8uAzRXHGi/ze2t2lNdCTikB7CUY7RRbWSRO5PqfXYrlYl0B+02J8vrY6fm7pbQXvIJ6OZ8gLSJefBRw0qc7ze+/jW/sZwoYposhFFNbnvGiEAMePlX0+hucXZnTXb2/ETZMObO6MFYa31Xro+dqIfSINpujRrmHtUbPhG9Tm36pUsCQNBKbYuVjfIN5cGe9WbntTnbwgX8GvHdUlklnBjk774mIP4PSFnLIsF3J6SZdJ7XbEc39BTB7Ep5wg03cQkiWe8ql/CWQ6roM7j73Jq44LEKjlLhGG9uU7uHyAUy9/MM4Gy2xPdFi/7WpYPGQ8r+xPW2FgzHjQGQWDc64DHNCeXHIHL2KvMzY65Xe9ZNp7oqNp4ipTEdHvKYG4aUF7HLO+HQjmqIrgRX56InxfSHd0j6+x8bT6dwbeXoJtoJ6NzqGMjpVk67NTQSvain2d+Tl73tmO07cZbm3N3WIiLusrI07qOcuM7vBLXhHgwomz1fSajGT/SeCnaREra+39wEQe4YSrn4Ko8b3A4i4MRcBbq88dv0k3SkIgCOQAM+czm5nTIjOkrkQDr2d2AKssolm7AOq6eJ8RXOfhQnekCwwPWM6FVdZuoeHKmqZMchjGLopjeq/gDhZimfRFhEHObg0UTQKUoT0foU0wV7D2en8hCvShy/yo508j2nZMEPpe099C0zS/KqF9UqCry6o4XRt2BeYys6j9wpdaRliaGzOp4YT3sSIrjLmqr0CJMufIK9kTcVCyq9sSMMGZxGvclrha9UDxdsYSCfgUEsA4CBzwyBmjHBUPCRkcMWo9rA6Abwh0V9KIJ2avRmWDPnbBb/i8dVv/8oNvB0mo3P7vNA== 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)(1800799015)(376005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-Anti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jtGA6+UD1FwxTo2MAmnZh32bVJ9mggr7Ck7+0rFHjTFauLdkRg7xjyff5aqHKqIItrOw4yRUKtp3YyZ1wgc1/dNHkytiihEk9dLFYYw0At2a9cu17D8GqJ3CkSzM3NGmQdBo46BUBxM5FPjFkJtqh/KiCSxEkEgBLUSFNr8vKyI2JP8bzai0wlvaW3ckpLP0HBlPalIvQfliZHH5IL0kv7kHOEfL8fLZjM1+rb03/A= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fe1889de-921c-4230-a0bb-08dc6892a70f X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB4382.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 21:23:45.8627 (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: htu759adxGYFsYgu/mfMueIKmW4h0d0S3py2V7dJgIr2kQhJw1SGhXHH7NMPmQhmS/Xoeb9Ti2wu02jFXpl3uLnDxWs667WdPM+rcl7QwpM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7232 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-04-29_18,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 adultscore=0 phishscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290141 X-Proofpoint-GUID: BMfyoPyDIipoleCBLdoyeuZsj5sNTQoR X-Proofpoint-ORIG-GUID: BMfyoPyDIipoleCBLdoyeuZsj5sNTQoR 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 Cc: Eduard Zingerman Cc: Andrii Nakryiko --- 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 54aca9b377a4..b6344cead2e2 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -13746,12 +13746,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