From patchwork Fri Feb 24 15:10:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rong Tao X-Patchwork-Id: 61371 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp971644wrd; Fri, 24 Feb 2023 07:23:52 -0800 (PST) X-Google-Smtp-Source: AK7set+XlSZys2RZB2jjMBx3S4Eg2pbghDswRuSLV5UiKxzqw89ulUOKarFX4rCJezR4v0vOWVBd X-Received: by 2002:a05:6a20:6f46:b0:cb:98e5:de2c with SMTP id gu6-20020a056a206f4600b000cb98e5de2cmr9639566pzb.8.1677252232188; Fri, 24 Feb 2023 07:23:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677252232; cv=none; d=google.com; s=arc-20160816; b=CtsrVJJzbVSSoqq+5o0APbZMnZJ0fXAXRodCUkR2O8M6BJaOpoYHpvXFtgxMn2nd/7 9EYCxmdQGf8JLcstCseUBIg9uWpVqPSwjFDNxqrW18vHdqwO6b0U+TduiQxxXqiiUPoY 1nE/xE/gBkU6ywnjcvOED9JosDEyFms23G4y2qPGL04PFhOTy7XHuOrFaM2ZQd1mmXRM oHu8/i5yqJkJl4QG/RfaYNI6JGIPUz8UZS7bbxxJqfCOKugPAI3tKvS97nm7gRO2uXJK fNXA8T30dtS8bm2zl5Ok9isCsoom6Solp3tMDDOJiZ7hDCwn/Fnrf9BzHYEZ9zX1EztL IVow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:date :subject:cc:to:from:message-id:dkim-signature; bh=2DxjrJyKKTqbJ2x4ZMA0QnmzjpPwL2ed1Fn0QoMGueQ=; b=HJ5YyNzOEgjARcwrgmMheQ8bCpNnISVsGbOULNoCu+V9Xr09ex5LkblLR7FCJWYDzk B5tuvJ37zwioTbFqj8x3TN5Ngy57JqMZHU7Ik5byycGDnPDDRRUA2/sb3CKmyr40hCM1 Q2LO6xc4ivR31N3grbJf7FukVHA5Nl1835WrAvtzJzGG17Jy3TnPuP2CmdnRX5ooqXnB oQhT2vlSbSLFun1AGFx9YN7gnqalGe6FP3y91SYx6dgqUZP9+nJWZpffMtW9EM7O9bnB QN+SSImX4mK/YI4iceosW8yvtoR45JlzByzSx14MJikG58xm26ghD61/Keu4HyVFvU7p 2zVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=w23xj9Hz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k2-20020a633d02000000b004faf6b6e98csi6299750pga.440.2023.02.24.07.23.38; Fri, 24 Feb 2023 07:23:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=w23xj9Hz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229686AbjBXPS7 (ORCPT + 99 others); Fri, 24 Feb 2023 10:18:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229736AbjBXPSy (ORCPT ); Fri, 24 Feb 2023 10:18:54 -0500 Received: from out162-62-58-211.mail.qq.com (out162-62-58-211.mail.qq.com [162.62.58.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B61EA682BF; Fri, 24 Feb 2023 07:18:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1677251925; bh=2DxjrJyKKTqbJ2x4ZMA0QnmzjpPwL2ed1Fn0QoMGueQ=; h=From:To:Cc:Subject:Date; b=w23xj9HzMuNVIKIvBoWVHYhq2h2pvg+N7/TxZBN1lihdjFWLx/UPmj7KpuUizXLuM ciUnxU3WgKrrcdkjE1EvlL+IVlSkzKe2QrYQsYEvbuPlL+2yzgI14mjU85NZWEYbyX 2vuS1lCBby/upGErpEnVNJ461Mr7hW9Nelzey9oY= Received: from rtoax.. ([111.199.188.149]) by newxmesmtplogicsvrszb9-0.qq.com (NewEsmtp) with SMTP id 28421E7C; Fri, 24 Feb 2023 23:10:04 +0800 X-QQ-mid: xmsmtpt1677251404tc788u33m Message-ID: X-QQ-XMAILINFO: MaJhvnnz6ISsTeBvp4SdkfRgmLru8HT4dYD59XQa9InsFMrFkQCik7T6o584SR HrxnPWpBq7Q4iIIr6E+ZL3rBbfKFwE2UQu6L/bC+A1IQa4nFwqlwuHLS25Dto0/BycZ0upk449pR j9GB8EbSD1y/+T1VQceIjHmoPYBQgg3xK96JnaGLHErglPV2/uSD5Mhw5VmUJQlHsp3pfl9NNQ6X zAtzONR7dKRExHozzjUYfcAAOxetFZ0wxrAqzxVFmOZAxetpsNuPmQAv6N2R7zsHIOpz/BJo+heK w2+xrA9088q9tg63I8eYAHObwonvgWNNax6RlWKjcDHsLXrjY03gY32y29+auQpP0YWhYR6JDZ0K 84rNRW/AhPleRO4uW/xrIdGOcHFpbZnd8BZmQEtkES/cjY24KhAwvS9T8zSxV2e6IhOkju4Mh8Ia iNDyz2VlE37TOjD0VdbU9U52HJbxNux6oA4YHY8cxjfRTtJoH5r2msar7L+W4fAy0HHYwGT+b9fO V8GKnjlhIxJmJwdE4nyQJRnVJGERijCSTedQWIX31EnCxG1VTBtoACMSjH5Xgzj5Ctt2zfpdqiTK NpWbj7in1ChjsHKdwmB1L5kwKp9t0n+USxbRPN78rfLTqs8bqKN8qSgwYsSPHPHYCo7PXwB1nhs4 IP4hm04ujclsHRDTeVmVbj+CvLiOYtWJLVm7CtuHp8/tI0YX0AcM3RqkrjKeDbaZvDM/x6RnWxLK T5Qz95OvNAr0Hsn4XL/gN1sLPJwkzZzKQ9NFcxa0lmmjBhypZN4/FOOwLE6kVfionaD899bMX4Cs e7psJpvwIFVcFRLixdh5u/gmcw5Kb96+U7Gr0foDW/wC68X2DdMkKes616m5qAQzwmz6DwIwgdks lhF8/LimktzrJbWUsMX3DxqaTfyGH71uhghgX+Ofl3eNMtpkuq/VkLpZByVyr1y2lYYNHhLEELDP JSAZWWuEENoa9HTY175BDWnH9NHSueUvggdhVxjhWHdoppjAA3ZgC5tUlgnZkUjHOyPr3vG07BSn UUXrTTIVMm1FS3Yf3w From: Rong Tao To: ast@kernel.org Cc: Rong Tao , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , bpf@vger.kernel.org (open list:BPF [GENERAL] (Safe Dynamic Programs and Tools)), linux-kselftest@vger.kernel.org (open list:KERNEL SELFTEST FRAMEWORK), linux-kernel@vger.kernel.org (open list) Subject: [PATCH bpf-next v2] selftests/bpf: Fix compilation errors: assign a value to a constant Date: Fri, 24 Feb 2023 23:10:02 +0800 X-OQ-MSGID: <20230224151002.579037-1-rtoax@foxmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, HELO_DYNAMIC_IPADDR,RCVD_IN_DNSWL_NONE,RDNS_DYNAMIC,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758725628837339453?= X-GMAIL-MSGID: =?utf-8?q?1758726436551265768?= From: Rong Tao commit bc292ab00f6c("mm: introduce vma->vm_flags wrapper functions") turns the vm_flags into a const variable. Added bpf_find_vma test in commit f108662b27c9("selftests/bpf: Add tests for bpf_find_vma") to assign values to variables that declare const in find_vma_fail1.c programs, which is an error to the compiler and does not test BPF verifiers. It is better to replace 'const vm_flags_t vm_flags' with 'unsigned long vm_start' for testing. $ make -C tools/testing/selftests/bpf/ -j8 ... progs/find_vma_fail1.c:16:16: error: cannot assign to non-static data member 'vm_flags' with const-qualified type 'const vm_flags_t' (aka 'const unsigned long') vma->vm_flags |= 0x55; ~~~~~~~~~~~~~ ^ ../tools/testing/selftests/bpf/tools/include/vmlinux.h:1898:20: note: non-static data member 'vm_flags' declared const here const vm_flags_t vm_flags; ~~~~~~~~~~~`~~~~~~^~~~~~~~ Signed-off-by: Rong Tao --- v2: Add more useful commit information v1: https://lore.kernel.org/lkml/tencent_FC8827062142CF5936974B2A30AF6CA3C408@qq.com/ --- tools/testing/selftests/bpf/progs/find_vma_fail1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/progs/find_vma_fail1.c b/tools/testing/selftests/bpf/progs/find_vma_fail1.c index b3b326b8e2d1..47d5dedff554 100644 --- a/tools/testing/selftests/bpf/progs/find_vma_fail1.c +++ b/tools/testing/selftests/bpf/progs/find_vma_fail1.c @@ -13,7 +13,7 @@ static long write_vma(struct task_struct *task, struct vm_area_struct *vma, struct callback_ctx *data) { /* writing to vma, which is illegal */ - vma->vm_flags |= 0x55; + vma->vm_start = 0xffffffffff600000; return 0; }