Message ID | edac34c9-190c-0d80-8d95-2f42971cc870@alu.unizg.hr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1548029vqo; Mon, 22 May 2023 08:53:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4fZRuVwnhqh2Y6Eur3vRfEZ8LL98OEAs8LduwnVLsBwWhjnu1zkU2skgA4zkqsEdy372Bh X-Received: by 2002:a17:90a:f68a:b0:24d:ea7f:9ea2 with SMTP id cl10-20020a17090af68a00b0024dea7f9ea2mr10930461pjb.15.1684770806656; Mon, 22 May 2023 08:53:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684770806; cv=none; d=google.com; s=arc-20160816; b=qwXZ55NRWnRZfosifQvGdqk0s3PQWXHGTE9CCgE0SjWFz3blMYjT7TKRk0ObKDbQJP eHTU8xYswudASTOA1WuYp6i+IeDpR5iZ/PD9yWJY8rlVlVqeNx26gbiWiiGfcfkcjnVS gDS2Q38MYRmppnf6BCyfuTlESpWouiGsOA2WMuq8x/u21eCZ6pp/eby2Q846KcvpBS+O pD0ti6h2fOFnqrWlNoaMslgZrOKvD4g0aZpbi+/DNZpg6LlA2qBaWUi29rT7J4pPKNWs 72GYd9tJYHTGAaGnm95iAXp0ITraVeaTGIiqa7rZHiOMBoazfggsLwXY0mypjjPwo1kD 1RPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject:from :content-language:user-agent:mime-version:date:message-id :dkim-signature:dkim-signature; bh=2679TV+JUyZ+fAItjpP4WQhJySQQqMxl4k0z8zhjO3c=; b=RVGcQSgxKMRdkNA6pGiKkPRViRiQazq1VFPUqOMoEjPO6rP3XfIAL2mJxhgGgRUCfO 3JrpbwFTAtGfzXo/mPpTENUCvsRwiasWAC2ZXNdOFrjA+03i3uOKY634avfW7KlWG7RB OpxQUtLdRxDOqbCxZ0sS2vpUn3znvZIR8oQvVceVOt8i1WCqaPNyW7akKPoEb/iILjLA aXjbi79HkxHYzddXSF02aE95R1UirJOmlzFTyhmD5OqafpLZyuU9YYf0vQaN1u+zk0RH MtgiwVLfY+F2nRzo5RQL/tqjpmK3xmoFElLupQjzsbFHmtE3UpuyvKbLMHRQxDC4vqVl 7tVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=LT5j5SjA; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=b2MBIAjo; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alu.unizg.hr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i21-20020a17090adc1500b0025026c97f40si6874443pjv.145.2023.05.22.08.53.13; Mon, 22 May 2023 08:53:26 -0700 (PDT) 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=fail header.i=@alu.unizg.hr header.s=mail header.b=LT5j5SjA; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=b2MBIAjo; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alu.unizg.hr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229988AbjEVPcU (ORCPT <rfc822;wlfightup@gmail.com> + 99 others); Mon, 22 May 2023 11:32:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229692AbjEVPcS (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 22 May 2023 11:32:18 -0400 Received: from domac.alu.hr (domac.alu.unizg.hr [161.53.235.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D054E0; Mon, 22 May 2023 08:32:16 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by domac.alu.hr (Postfix) with ESMTP id D265D6017E; Mon, 22 May 2023 17:32:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.unizg.hr; s=mail; t=1684769534; bh=RqvuOsJ8S7XdjoXvu70wev1e9QQK7l1N40NzkMAHzX8=; h=Date:From:Subject:To:Cc:From; b=LT5j5SjAGNIFjpZFPLIxMxTA8kJEM6iiS/Cx4UJNgNxQyU6aU2vmu5fC4bQTS/1S2 fqdEYzhR++jqx8rT5uU2u0j+waMJv9Th92bfHCd1AWZeXtjF/m8PCvHohjyjtemRFa jPD++DKXZ8Y67dbSVXKImbjz3Dq/sUgYSxLClTtPQ7SLeaSvutlVGi93HaG3IUKwY5 hoad7FZ1SmRvoT9dcooE0T0S7n6Y0hH08hQ9Ud9Edr0QoPGKn8Go9K6+/mKnjmDlOU QeAvYxWUAqPzHQnpy6JGj2tN/tgEp7BLYipxOc5uWYHtuTxDZPUiaJm0mAn4qvl1Do eWTfXolOUaL4A== X-Virus-Scanned: Debian amavisd-new at domac.alu.hr Received: from domac.alu.hr ([127.0.0.1]) by localhost (domac.alu.hr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cccNu_K_Opy5; Mon, 22 May 2023 17:32:12 +0200 (CEST) Received: from [193.198.186.200] (pc-mtodorov.slava.alu.hr [193.198.186.200]) by domac.alu.hr (Postfix) with ESMTPSA id 971516017C; Mon, 22 May 2023 17:32:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.unizg.hr; s=mail; t=1684769532; bh=RqvuOsJ8S7XdjoXvu70wev1e9QQK7l1N40NzkMAHzX8=; h=Date:From:Subject:To:Cc:From; b=b2MBIAjoXrkkWbHzTTNiaL8Ybasp/aWQctqNzYBXy5Sdat2DFo2HG4enNPsO56KFl jldM9PvrgPVvCHxV+VNf4JoqLlC9E3eD6eVflKp0V0WpxMWC8K9yXvu7wKmbjRgn+A BDb69+8SFkxyrg00mceEXwoOVTov9duFzJyAxV06WjzQgruLqqrfaEHA/Lnj2CP0K0 nowm7CBa3qhHwOXGSlyWMHQ1ydOawOAIup9QWGUFafUvuGm9RYZIqUTzMESzJIrKb0 uquXjs5lmCu6xSSfp+EVWJlOhChF9k9ADeYaNEaSK8nYUFDeNZMslrvBWTr6JF4BuR VbRR6eNJnjBSQ== Message-ID: <edac34c9-190c-0d80-8d95-2f42971cc870@alu.unizg.hr> Date: Mon, 22 May 2023 17:32:11 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Content-Language: en-US, hr From: Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr> Subject: [BUG] selftests: af_unix: unix:diag.c does not compile on AlmaLinux 8.7 To: linux-kselftest@vger.kernel.org Cc: "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Shuah Khan <shuah@kernel.org>, Kuniyuki Iwashima <kuniyu@amazon.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766610233457378132?= X-GMAIL-MSGID: =?utf-8?q?1766610233457378132?= |
Series |
[BUG] selftests: af_unix: unix:diag.c does not compile on AlmaLinux 8.7
|
|
Commit Message
Mirsad Todorovac
May 22, 2023, 3:32 p.m. UTC
Hi, On vanilla AlmaLinux 8.7 (CentOS fork) selftests/net/af_unix/diag_uid.c doesn't compile out of the box, giving the errors: make[2]: Entering directory '/home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix' gcc diag_uid.c -o /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix/diag_uid diag_uid.c:36:16: error: ‘UDIAG_SHOW_UID’ undeclared here (not in a function); did you mean ‘UDIAG_SHOW_VFS’? .udiag_show = UDIAG_SHOW_UID ^~~~~~~~~~~~~~ UDIAG_SHOW_VFS In file included from diag_uid.c:17: diag_uid.c: In function ‘render_response’: diag_uid.c:128:28: error: ‘UNIX_DIAG_UID’ undeclared (first use in this function); did you mean ‘UNIX_DIAG_VFS’? ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); ^~~~~~~~~~~~~ ../../kselftest_harness.h:707:13: note: in definition of macro ‘__EXPECT’ __typeof__(_seen) __seen = (_seen); \ ^~~~~ diag_uid.c:128:2: note: in expansion of macro ‘ASSERT_EQ’ ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); ^~~~~~~~~ diag_uid.c:128:28: note: each undeclared identifier is reported only once for each function it appears in ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); ^~~~~~~~~~~~~ ../../kselftest_harness.h:707:13: note: in definition of macro ‘__EXPECT’ __typeof__(_seen) __seen = (_seen); \ ^~~~~ diag_uid.c:128:2: note: in expansion of macro ‘ASSERT_EQ’ ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); ^~~~~~~~~ make[2]: *** [../../lib.mk:147: /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix/diag_uid] Error 1 The correct value is in <uapi/linux/unix_diag.h>: include/uapi/linux/unix_diag.h:23:#define UDIAG_SHOW_UID 0x00000040 /* show socket's UID */ The fix is as follows: --- tools/testing/selftests/net/af_unix/diag_uid.c | 4 ++++ 1 file changed, 4 insertions(+) Now, this is a change in enums and there doesn't seem to an easy way out here. (I think I saw an example, but I cannot recall which thread. I will do more research.) When I included # gcc -I ../../../../include diag_uid.c I've got the following error: [marvin@pc-mtodorov linux_torvalds]$ cd tools/testing/selftests/net/af_unix/ [marvin@pc-mtodorov af_unix]$ gcc -I ../../../../../include diag_uid.c -o /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix/diag_uid In file included from ../../../../../include/linux/build_bug.h:5, from ../../../../../include/linux/bits.h:21, from ../../../../../include/linux/capability.h:18, from ../../../../../include/linux/netlink.h:6, from diag_uid.c:8: ../../../../../include/linux/compiler.h:246:10: fatal error: asm/rwonce.h: No such file or directory #include <asm/rwonce.h> ^~~~~~~~~~~~~~ compilation terminated. [marvin@pc-mtodorov af_unix]$ At this point I gave up, as it would be an overkill to change kernel system header to make a test pass, and this probably wouldn't be accepted upsteam? Hope this helps. (If we still want to build on CentOS/AlmaLinux/Rocky 8?) Best regards, Mirsad
Comments
From: Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr> Date: Mon, 22 May 2023 17:32:11 +0200 > Hi, > > On vanilla AlmaLinux 8.7 (CentOS fork) selftests/net/af_unix/diag_uid.c doesn't > compile out of the box, giving the errors: > > make[2]: Entering directory '/home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix' > gcc diag_uid.c -o /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix/diag_uid > diag_uid.c:36:16: error: ‘UDIAG_SHOW_UID’ undeclared here (not in a function); did you mean ‘UDIAG_SHOW_VFS’? > .udiag_show = UDIAG_SHOW_UID > ^~~~~~~~~~~~~~ > UDIAG_SHOW_VFS > In file included from diag_uid.c:17: > diag_uid.c: In function ‘render_response’: > diag_uid.c:128:28: error: ‘UNIX_DIAG_UID’ undeclared (first use in this function); did you mean ‘UNIX_DIAG_VFS’? > ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); > ^~~~~~~~~~~~~ > ../../kselftest_harness.h:707:13: note: in definition of macro ‘__EXPECT’ > __typeof__(_seen) __seen = (_seen); \ > ^~~~~ > diag_uid.c:128:2: note: in expansion of macro ‘ASSERT_EQ’ > ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); > ^~~~~~~~~ > diag_uid.c:128:28: note: each undeclared identifier is reported only once for each function it appears in > ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); > ^~~~~~~~~~~~~ > ../../kselftest_harness.h:707:13: note: in definition of macro ‘__EXPECT’ > __typeof__(_seen) __seen = (_seen); \ > ^~~~~ > diag_uid.c:128:2: note: in expansion of macro ‘ASSERT_EQ’ > ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); > ^~~~~~~~~ > make[2]: *** [../../lib.mk:147: /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix/diag_uid] Error 1 > > The correct value is in <uapi/linux/unix_diag.h>: > > include/uapi/linux/unix_diag.h:23:#define UDIAG_SHOW_UID 0x00000040 /* show socket's UID */ > > The fix is as follows: > > --- > tools/testing/selftests/net/af_unix/diag_uid.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/tools/testing/selftests/net/af_unix/diag_uid.c b/tools/testing/selftests/net/af_unix/diag_uid.c > index 5b88f7129fea..66d75b646d35 100644 > --- a/tools/testing/selftests/net/af_unix/diag_uid.c > +++ b/tools/testing/selftests/net/af_unix/diag_uid.c > @@ -16,6 +16,10 @@ > > #include "../../kselftest_harness.h" > > +#ifndef UDIAG_SHOW_UID > +#define UDIAG_SHOW_UID 0x00000040 /* show socket's UID */ > +#endif > + > FIXTURE(diag_uid) > { > int netlink_fd; > > -- > > However, this patch reveals another undefined value: > > make[2]: Entering directory '/home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix' > gcc diag_uid.c -o /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix/diag_uid > In file included from diag_uid.c:17: > diag_uid.c: In function ‘render_response’: > diag_uid.c:132:28: error: ‘UNIX_DIAG_UID’ undeclared (first use in this function); did you mean ‘UNIX_DIAG_VFS’? > ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); > ^~~~~~~~~~~~~ > ../../kselftest_harness.h:707:13: note: in definition of macro ‘__EXPECT’ > __typeof__(_seen) __seen = (_seen); \ > ^~~~~ > diag_uid.c:132:2: note: in expansion of macro ‘ASSERT_EQ’ > ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); > ^~~~~~~~~ > diag_uid.c:132:28: note: each undeclared identifier is reported only once for each function it appears in > ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); > ^~~~~~~~~~~~~ > ../../kselftest_harness.h:707:13: note: in definition of macro ‘__EXPECT’ > __typeof__(_seen) __seen = (_seen); \ > ^~~~~ > diag_uid.c:132:2: note: in expansion of macro ‘ASSERT_EQ’ > ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); > ^~~~~~~~~ > make[2]: *** [../../lib.mk:147: /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix/diag_uid] Error 1 > > Apparently, AlmaLinux 8.7 lacks this enum UNIX_DIAG_UID: > > diff -u /usr/include/linux/unix_diag.h include/uapi/linux/unix_diag.h > --- /usr/include/linux/unix_diag.h 2023-05-16 13:47:51.000000000 +0200 > +++ include/uapi/linux/unix_diag.h 2022-10-12 07:35:58.253481367 +0200 > @@ -20,6 +20,7 @@ > #define UDIAG_SHOW_ICONS 0x00000008 /* show pending connections */ > #define UDIAG_SHOW_RQLEN 0x00000010 /* show skb receive queue len */ > #define UDIAG_SHOW_MEMINFO 0x00000020 /* show memory info of a socket */ > +#define UDIAG_SHOW_UID 0x00000040 /* show socket's UID */ > > struct unix_diag_msg { > __u8 udiag_family; > @@ -40,6 +41,7 @@ > UNIX_DIAG_RQLEN, > UNIX_DIAG_MEMINFO, > UNIX_DIAG_SHUTDOWN, > + UNIX_DIAG_UID, > > __UNIX_DIAG_MAX, > }; > > Now, this is a change in enums and there doesn't seem to an easy way out > here. (I think I saw an example, but I cannot recall which thread. I will do > more research.) > > When I included > > # gcc -I ../../../../include diag_uid.c > > I've got the following error: > > [marvin@pc-mtodorov linux_torvalds]$ cd tools/testing/selftests/net/af_unix/ > [marvin@pc-mtodorov af_unix]$ gcc -I ../../../../../include diag_uid.c -o > /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix/diag_uid > In file included from ../../../../../include/linux/build_bug.h:5, > from ../../../../../include/linux/bits.h:21, > from ../../../../../include/linux/capability.h:18, > from ../../../../../include/linux/netlink.h:6, > from diag_uid.c:8: > ../../../../../include/linux/compiler.h:246:10: fatal error: asm/rwonce.h: No such file or directory > #include <asm/rwonce.h> > ^~~~~~~~~~~~~~ > compilation terminated. > [marvin@pc-mtodorov af_unix]$ > > At this point I gave up, as it would be an overkill to change kernel system > header to make a test pass, and this probably wouldn't be accepted upsteam? > > Hope this helps. (If we still want to build on CentOS/AlmaLinux/Rocky 8?) I launched AlmaLinux/RockyLinux 8.7 and 9.2 with images listed in the pages below. https://wiki.almalinux.org/cloud/AWS.html#community-amis https://rockylinux.org/cloud-images/ The kernel versions in each image were : 8.7: Alma : 4.18.0-425.3.1.el8.x86_64 Rocky : 4.18.0-425.10.1.el8_7.x86_64 9.2: Alma : 5.14.0-284.11.1.el9_2.x86_64 Rocky : 5.14.0-284.11.1.el9_2.x86_64 So, this is not a bug. It's just because v4.18 does not support UNIX_DIAG_UID, which was introduced in v5.3. You should install 5.3+ kernel if you want to build the test. Thanks, Kuniyuki > > Best regards, > Mirsad > > -- > Mirsad Goran Todorovac > Sistem inženjer > Grafički fakultet | Akademija likovnih umjetnosti > Sveučilište u Zagrebu > > System engineer > Faculty of Graphic Arts | Academy of Fine Arts > University of Zagreb, Republic of Croatia
On 5/22/23 18:28, Kuniyuki Iwashima wrote: > From: Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr> > Date: Mon, 22 May 2023 17:32:11 +0200 >> Hi, >> >> On vanilla AlmaLinux 8.7 (CentOS fork) selftests/net/af_unix/diag_uid.c doesn't >> compile out of the box, giving the errors: >> >> make[2]: Entering directory '/home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix' >> gcc diag_uid.c -o /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix/diag_uid >> diag_uid.c:36:16: error: ‘UDIAG_SHOW_UID’ undeclared here (not in a function); did you mean ‘UDIAG_SHOW_VFS’? >> .udiag_show = UDIAG_SHOW_UID >> ^~~~~~~~~~~~~~ >> UDIAG_SHOW_VFS >> In file included from diag_uid.c:17: >> diag_uid.c: In function ‘render_response’: >> diag_uid.c:128:28: error: ‘UNIX_DIAG_UID’ undeclared (first use in this function); did you mean ‘UNIX_DIAG_VFS’? >> ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); >> ^~~~~~~~~~~~~ >> ../../kselftest_harness.h:707:13: note: in definition of macro ‘__EXPECT’ >> __typeof__(_seen) __seen = (_seen); \ >> ^~~~~ >> diag_uid.c:128:2: note: in expansion of macro ‘ASSERT_EQ’ >> ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); >> ^~~~~~~~~ >> diag_uid.c:128:28: note: each undeclared identifier is reported only once for each function it appears in >> ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); >> ^~~~~~~~~~~~~ >> ../../kselftest_harness.h:707:13: note: in definition of macro ‘__EXPECT’ >> __typeof__(_seen) __seen = (_seen); \ >> ^~~~~ >> diag_uid.c:128:2: note: in expansion of macro ‘ASSERT_EQ’ >> ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); >> ^~~~~~~~~ >> make[2]: *** [../../lib.mk:147: /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix/diag_uid] Error 1 >> >> The correct value is in <uapi/linux/unix_diag.h>: >> >> include/uapi/linux/unix_diag.h:23:#define UDIAG_SHOW_UID 0x00000040 /* show socket's UID */ >> >> The fix is as follows: >> >> --- >> tools/testing/selftests/net/af_unix/diag_uid.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/tools/testing/selftests/net/af_unix/diag_uid.c b/tools/testing/selftests/net/af_unix/diag_uid.c >> index 5b88f7129fea..66d75b646d35 100644 >> --- a/tools/testing/selftests/net/af_unix/diag_uid.c >> +++ b/tools/testing/selftests/net/af_unix/diag_uid.c >> @@ -16,6 +16,10 @@ >> >> #include "../../kselftest_harness.h" >> >> +#ifndef UDIAG_SHOW_UID >> +#define UDIAG_SHOW_UID 0x00000040 /* show socket's UID */ >> +#endif >> + >> FIXTURE(diag_uid) >> { >> int netlink_fd; >> >> -- >> >> However, this patch reveals another undefined value: >> >> make[2]: Entering directory '/home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix' >> gcc diag_uid.c -o /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix/diag_uid >> In file included from diag_uid.c:17: >> diag_uid.c: In function ‘render_response’: >> diag_uid.c:132:28: error: ‘UNIX_DIAG_UID’ undeclared (first use in this function); did you mean ‘UNIX_DIAG_VFS’? >> ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); >> ^~~~~~~~~~~~~ >> ../../kselftest_harness.h:707:13: note: in definition of macro ‘__EXPECT’ >> __typeof__(_seen) __seen = (_seen); \ >> ^~~~~ >> diag_uid.c:132:2: note: in expansion of macro ‘ASSERT_EQ’ >> ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); >> ^~~~~~~~~ >> diag_uid.c:132:28: note: each undeclared identifier is reported only once for each function it appears in >> ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); >> ^~~~~~~~~~~~~ >> ../../kselftest_harness.h:707:13: note: in definition of macro ‘__EXPECT’ >> __typeof__(_seen) __seen = (_seen); \ >> ^~~~~ >> diag_uid.c:132:2: note: in expansion of macro ‘ASSERT_EQ’ >> ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); >> ^~~~~~~~~ >> make[2]: *** [../../lib.mk:147: /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix/diag_uid] Error 1 >> >> Apparently, AlmaLinux 8.7 lacks this enum UNIX_DIAG_UID: >> >> diff -u /usr/include/linux/unix_diag.h include/uapi/linux/unix_diag.h >> --- /usr/include/linux/unix_diag.h 2023-05-16 13:47:51.000000000 +0200 >> +++ include/uapi/linux/unix_diag.h 2022-10-12 07:35:58.253481367 +0200 >> @@ -20,6 +20,7 @@ >> #define UDIAG_SHOW_ICONS 0x00000008 /* show pending connections */ >> #define UDIAG_SHOW_RQLEN 0x00000010 /* show skb receive queue len */ >> #define UDIAG_SHOW_MEMINFO 0x00000020 /* show memory info of a socket */ >> +#define UDIAG_SHOW_UID 0x00000040 /* show socket's UID */ >> >> struct unix_diag_msg { >> __u8 udiag_family; >> @@ -40,6 +41,7 @@ >> UNIX_DIAG_RQLEN, >> UNIX_DIAG_MEMINFO, >> UNIX_DIAG_SHUTDOWN, >> + UNIX_DIAG_UID, >> >> __UNIX_DIAG_MAX, >> }; >> >> Now, this is a change in enums and there doesn't seem to an easy way out >> here. (I think I saw an example, but I cannot recall which thread. I will do >> more research.) >> >> When I included >> >> # gcc -I ../../../../include diag_uid.c >> >> I've got the following error: >> >> [marvin@pc-mtodorov linux_torvalds]$ cd tools/testing/selftests/net/af_unix/ >> [marvin@pc-mtodorov af_unix]$ gcc -I ../../../../../include diag_uid.c -o >> /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix/diag_uid >> In file included from ../../../../../include/linux/build_bug.h:5, >> from ../../../../../include/linux/bits.h:21, >> from ../../../../../include/linux/capability.h:18, >> from ../../../../../include/linux/netlink.h:6, >> from diag_uid.c:8: >> ../../../../../include/linux/compiler.h:246:10: fatal error: asm/rwonce.h: No such file or directory >> #include <asm/rwonce.h> >> ^~~~~~~~~~~~~~ >> compilation terminated. >> [marvin@pc-mtodorov af_unix]$ >> >> At this point I gave up, as it would be an overkill to change kernel system >> header to make a test pass, and this probably wouldn't be accepted upsteam? >> >> Hope this helps. (If we still want to build on CentOS/AlmaLinux/Rocky 8?) > > I launched AlmaLinux/RockyLinux 8.7 and 9.2 with images listed in the pages > below. > > https://wiki.almalinux.org/cloud/AWS.html#community-amis > https://rockylinux.org/cloud-images/ > > The kernel versions in each image were : > > 8.7: > Alma : 4.18.0-425.3.1.el8.x86_64 > Rocky : 4.18.0-425.10.1.el8_7.x86_64 > > 9.2: > Alma : 5.14.0-284.11.1.el9_2.x86_64 > Rocky : 5.14.0-284.11.1.el9_2.x86_64 > > So, this is not a bug. It's just because v4.18 does not support > UNIX_DIAG_UID, which was introduced in v5.3. > > You should install 5.3+ kernel if you want to build the test. > > Thanks, > Kuniyuki Hi, Kuniyuki, Good point. However, newer kernel won't save me from old /usr/include headers, will it? I was actually testing the 6.4-rc3 on AlmaLinux 8.7, as it is my only RHEL-based box ... What would then be the right action? If it was a #define instead of enum, I'd probably work around and exclude the test that doesn't fit the kernel, or the system call would return -EINVAL? Including from the includes that came with the kernel might be a solution: ../../../../../include/uapi/linux/unix_diag.h:44: UNIX_DIAG_UID, Alas, when I try to include, I get these ugly errors: [marvin@pc-mtodorov af_unix]$ gcc -I ../../../../../include/ diag_uid.c In file included from ../../../../../include/linux/build_bug.h:5, from ../../../../../include/linux/bits.h:21, from ../../../../../include/linux/capability.h:18, from ../../../../../include/linux/netlink.h:6, from diag_uid.c:8: ../../../../../include/linux/compiler.h:246:10: fatal error: asm/rwonce.h: No such file or directory #include <asm/rwonce.h> ^~~~~~~~~~~~~~ compilation terminated. [marvin@pc-mtodorov af_unix]$ vi +246 ../../../../../include/linux/compiler.h [marvin@pc-mtodorov af_unix]$ find ../../../../../include -name rwonce.h ../../../../../include/asm-generic/rwonce.h [marvin@pc-mtodorov af_unix]$ Minimum reproducer is: [marvin@pc-mtodorov af_unix]$ gcc -I ../../../../../include/ reproducer.c In file included from ../../../../../include/linux/build_bug.h:5, from ../../../../../include/linux/bits.h:21, from ../../../../../include/linux/capability.h:18, from ../../../../../include/linux/netlink.h:6, from reproducer.c:5: ../../../../../include/linux/compiler.h:246:10: fatal error: asm/rwonce.h: No such file or directory #include <asm/rwonce.h> ^~~~~~~~~~~~~~ compilation terminated. [marvin@pc-mtodorov af_unix]$ [marvin@pc-mtodorov af_unix]$ nl reproducer.c 1 #define _GNU_SOURCE 2 #include <linux/netlink.h> [marvin@pc-mtodorov af_unix]$ Am I doing something very stupid right now, for actually I see #include <asm/rwonce.h> in "include/linux/compiler.h" 248L, 7843C while actual rwonce.h is in <asm-generic/rwonce.h> [marvin@pc-mtodorov af_unix]$ find ../../../../../include -name rwonce.h ../../../../../include/asm-generic/rwonce.h [marvin@pc-mtodorov af_unix]$ I must be doing something wrong, for I see that the kernel compiled despite not having include/asm ? When looking at the invocations of rwonce.h in the kernel, they seem to be equally spread between <asm-generic/rwonce.h> and <asm/rwonce.h> : [marvin@pc-mtodorov af_unix]$ grep --include="*.[ch]" -n -w rwonce.h -r ../../../../.. 2> /dev/null | less ../../../../../arch/alpha/include/asm/rwonce.h:33:#include <asm-generic/rwonce.h> ../../../../../arch/arm64/include/asm/rwonce.h:71:#include <asm-generic/rwonce.h> ../../../../../arch/arm64/kvm/hyp/include/nvhe/spinlock.h:18:#include <asm/rwonce.h> ../../../../../arch/s390/include/asm/rwonce.h:29:#include <asm-generic/rwonce.h> ../../../../../arch/x86/include/generated/asm/rwonce.h:1:#include <asm-generic/rwonce.h> ../../../../../include/asm-generic/barrier.h:18:#include <asm/rwonce.h> ../../../../../include/kunit/test.h:29:#include <asm/rwonce.h> ../../../../../include/linux/compiler.h:246:#include <asm/rwonce.h> I figured out I must be doing something wrong or the kernel otherwise would not build for me. Eventually, the UNIX_DIAG_UID enum is used in only one place: ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); That particular test should fail in case of kernel older than 5.3. However, I fell into a terrible mess where one thing breaks the other. I can't seem to make this work. Thanks, Mirsad
From: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr> Date: Mon, 22 May 2023 20:01:14 +0200 > On 5/22/23 18:28, Kuniyuki Iwashima wrote: > > From: Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr> > > Date: Mon, 22 May 2023 17:32:11 +0200 > >> Hi, > >> > >> On vanilla AlmaLinux 8.7 (CentOS fork) selftests/net/af_unix/diag_uid.c doesn't > >> compile out of the box, giving the errors: > >> > >> make[2]: Entering directory '/home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix' > >> gcc diag_uid.c -o /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix/diag_uid > >> diag_uid.c:36:16: error: ‘UDIAG_SHOW_UID’ undeclared here (not in a function); did you mean ‘UDIAG_SHOW_VFS’? > >> .udiag_show = UDIAG_SHOW_UID > >> ^~~~~~~~~~~~~~ > >> UDIAG_SHOW_VFS > >> In file included from diag_uid.c:17: > >> diag_uid.c: In function ‘render_response’: > >> diag_uid.c:128:28: error: ‘UNIX_DIAG_UID’ undeclared (first use in this function); did you mean ‘UNIX_DIAG_VFS’? > >> ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); > >> ^~~~~~~~~~~~~ > >> ../../kselftest_harness.h:707:13: note: in definition of macro ‘__EXPECT’ > >> __typeof__(_seen) __seen = (_seen); \ > >> ^~~~~ > >> diag_uid.c:128:2: note: in expansion of macro ‘ASSERT_EQ’ > >> ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); > >> ^~~~~~~~~ > >> diag_uid.c:128:28: note: each undeclared identifier is reported only once for each function it appears in > >> ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); > >> ^~~~~~~~~~~~~ > >> ../../kselftest_harness.h:707:13: note: in definition of macro ‘__EXPECT’ > >> __typeof__(_seen) __seen = (_seen); \ > >> ^~~~~ > >> diag_uid.c:128:2: note: in expansion of macro ‘ASSERT_EQ’ > >> ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); > >> ^~~~~~~~~ > >> make[2]: *** [../../lib.mk:147: /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix/diag_uid] Error 1 > >> > >> The correct value is in <uapi/linux/unix_diag.h>: > >> > >> include/uapi/linux/unix_diag.h:23:#define UDIAG_SHOW_UID 0x00000040 /* show socket's UID */ > >> > >> The fix is as follows: > >> > >> --- > >> tools/testing/selftests/net/af_unix/diag_uid.c | 4 ++++ > >> 1 file changed, 4 insertions(+) > >> > >> diff --git a/tools/testing/selftests/net/af_unix/diag_uid.c b/tools/testing/selftests/net/af_unix/diag_uid.c > >> index 5b88f7129fea..66d75b646d35 100644 > >> --- a/tools/testing/selftests/net/af_unix/diag_uid.c > >> +++ b/tools/testing/selftests/net/af_unix/diag_uid.c > >> @@ -16,6 +16,10 @@ > >> > >> #include "../../kselftest_harness.h" > >> > >> +#ifndef UDIAG_SHOW_UID > >> +#define UDIAG_SHOW_UID 0x00000040 /* show socket's UID */ > >> +#endif > >> + > >> FIXTURE(diag_uid) > >> { > >> int netlink_fd; > >> > >> -- > >> > >> However, this patch reveals another undefined value: > >> > >> make[2]: Entering directory '/home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix' > >> gcc diag_uid.c -o /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix/diag_uid > >> In file included from diag_uid.c:17: > >> diag_uid.c: In function ‘render_response’: > >> diag_uid.c:132:28: error: ‘UNIX_DIAG_UID’ undeclared (first use in this function); did you mean ‘UNIX_DIAG_VFS’? > >> ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); > >> ^~~~~~~~~~~~~ > >> ../../kselftest_harness.h:707:13: note: in definition of macro ‘__EXPECT’ > >> __typeof__(_seen) __seen = (_seen); \ > >> ^~~~~ > >> diag_uid.c:132:2: note: in expansion of macro ‘ASSERT_EQ’ > >> ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); > >> ^~~~~~~~~ > >> diag_uid.c:132:28: note: each undeclared identifier is reported only once for each function it appears in > >> ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); > >> ^~~~~~~~~~~~~ > >> ../../kselftest_harness.h:707:13: note: in definition of macro ‘__EXPECT’ > >> __typeof__(_seen) __seen = (_seen); \ > >> ^~~~~ > >> diag_uid.c:132:2: note: in expansion of macro ‘ASSERT_EQ’ > >> ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); > >> ^~~~~~~~~ > >> make[2]: *** [../../lib.mk:147: /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix/diag_uid] Error 1 > >> > >> Apparently, AlmaLinux 8.7 lacks this enum UNIX_DIAG_UID: > >> > >> diff -u /usr/include/linux/unix_diag.h include/uapi/linux/unix_diag.h > >> --- /usr/include/linux/unix_diag.h 2023-05-16 13:47:51.000000000 +0200 > >> +++ include/uapi/linux/unix_diag.h 2022-10-12 07:35:58.253481367 +0200 > >> @@ -20,6 +20,7 @@ > >> #define UDIAG_SHOW_ICONS 0x00000008 /* show pending connections */ > >> #define UDIAG_SHOW_RQLEN 0x00000010 /* show skb receive queue len */ > >> #define UDIAG_SHOW_MEMINFO 0x00000020 /* show memory info of a socket */ > >> +#define UDIAG_SHOW_UID 0x00000040 /* show socket's UID */ > >> > >> struct unix_diag_msg { > >> __u8 udiag_family; > >> @@ -40,6 +41,7 @@ > >> UNIX_DIAG_RQLEN, > >> UNIX_DIAG_MEMINFO, > >> UNIX_DIAG_SHUTDOWN, > >> + UNIX_DIAG_UID, > >> > >> __UNIX_DIAG_MAX, > >> }; > >> > >> Now, this is a change in enums and there doesn't seem to an easy way out > >> here. (I think I saw an example, but I cannot recall which thread. I will do > >> more research.) > >> > >> When I included > >> > >> # gcc -I ../../../../include diag_uid.c > >> > >> I've got the following error: > >> > >> [marvin@pc-mtodorov linux_torvalds]$ cd tools/testing/selftests/net/af_unix/ > >> [marvin@pc-mtodorov af_unix]$ gcc -I ../../../../../include diag_uid.c -o > >> /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix/diag_uid > >> In file included from ../../../../../include/linux/build_bug.h:5, > >> from ../../../../../include/linux/bits.h:21, > >> from ../../../../../include/linux/capability.h:18, > >> from ../../../../../include/linux/netlink.h:6, > >> from diag_uid.c:8: > >> ../../../../../include/linux/compiler.h:246:10: fatal error: asm/rwonce.h: No such file or directory > >> #include <asm/rwonce.h> > >> ^~~~~~~~~~~~~~ > >> compilation terminated. > >> [marvin@pc-mtodorov af_unix]$ > >> > >> At this point I gave up, as it would be an overkill to change kernel system > >> header to make a test pass, and this probably wouldn't be accepted upsteam? > >> > >> Hope this helps. (If we still want to build on CentOS/AlmaLinux/Rocky 8?) > > > > I launched AlmaLinux/RockyLinux 8.7 and 9.2 with images listed in the pages > > below. > > > > https://wiki.almalinux.org/cloud/AWS.html#community-amis > > https://rockylinux.org/cloud-images/ > > > > The kernel versions in each image were : > > > > 8.7: > > Alma : 4.18.0-425.3.1.el8.x86_64 > > Rocky : 4.18.0-425.10.1.el8_7.x86_64 > > > > 9.2: > > Alma : 5.14.0-284.11.1.el9_2.x86_64 > > Rocky : 5.14.0-284.11.1.el9_2.x86_64 > > > > So, this is not a bug. It's just because v4.18 does not support > > UNIX_DIAG_UID, which was introduced in v5.3. > > > > You should install 5.3+ kernel if you want to build the test. > > > > Thanks, > > Kuniyuki > > Hi, Kuniyuki, > > Good point. However, newer kernel won't save me from old /usr/include > headers, will it? Sorry, I meant kernel and kernel-headers package that should be updated along with kernel. You should use proper header files that match to the actual kernel version running on the machine. > I was actually testing the 6.4-rc3 on AlmaLinux 8.7, as it is my only > RHEL-based box ... > > What would then be the right action? make headers_install ? > If it was a #define instead of enum, I'd probably work around and > exclude the test that doesn't fit the kernel, or the system call > would return -EINVAL? > > Including from the includes that came with the kernel might be > a solution: > > ../../../../../include/uapi/linux/unix_diag.h:44: UNIX_DIAG_UID, > > Alas, when I try to include, I get these ugly errors: > > [marvin@pc-mtodorov af_unix]$ gcc -I ../../../../../include/ diag_uid.c > In file included from ../../../../../include/linux/build_bug.h:5, > from ../../../../../include/linux/bits.h:21, > from ../../../../../include/linux/capability.h:18, > from ../../../../../include/linux/netlink.h:6, > from diag_uid.c:8: > ../../../../../include/linux/compiler.h:246:10: fatal error: > asm/rwonce.h: No such file or directory > #include <asm/rwonce.h> > ^~~~~~~~~~~~~~ FWIW, this is provided by kernel-devel package. > compilation terminated. > [marvin@pc-mtodorov af_unix]$ vi +246 > ../../../../../include/linux/compiler.h > [marvin@pc-mtodorov af_unix]$ find ../../../../../include -name rwonce.h > ../../../../../include/asm-generic/rwonce.h > [marvin@pc-mtodorov af_unix]$ > > Minimum reproducer is: > > [marvin@pc-mtodorov af_unix]$ gcc -I ../../../../../include/ reproducer.c > In file included from ../../../../../include/linux/build_bug.h:5, > from ../../../../../include/linux/bits.h:21, > from ../../../../../include/linux/capability.h:18, > from ../../../../../include/linux/netlink.h:6, > from reproducer.c:5: > ../../../../../include/linux/compiler.h:246:10: fatal error: > asm/rwonce.h: No such file or directory > #include <asm/rwonce.h> > ^~~~~~~~~~~~~~ > compilation terminated. > [marvin@pc-mtodorov af_unix]$ > > [marvin@pc-mtodorov af_unix]$ nl reproducer.c > > 1 #define _GNU_SOURCE > 2 #include <linux/netlink.h> > > [marvin@pc-mtodorov af_unix]$ > > Am I doing something very stupid right now, for actually I see > > #include <asm/rwonce.h> > > in "include/linux/compiler.h" 248L, 7843C > > while actual rwonce.h is in <asm-generic/rwonce.h> > > [marvin@pc-mtodorov af_unix]$ find ../../../../../include -name rwonce.h > ../../../../../include/asm-generic/rwonce.h > [marvin@pc-mtodorov af_unix]$ > > I must be doing something wrong, for I see that the kernel compiled > despite not having include/asm ? > > When looking at the invocations of rwonce.h in the kernel, they seem to > be equally spread between <asm-generic/rwonce.h> and <asm/rwonce.h> : > > [marvin@pc-mtodorov af_unix]$ grep --include="*.[ch]" -n -w rwonce.h -r ../../../../.. 2> /dev/null | less > ../../../../../arch/alpha/include/asm/rwonce.h:33:#include <asm-generic/rwonce.h> > ../../../../../arch/arm64/include/asm/rwonce.h:71:#include <asm-generic/rwonce.h> > ../../../../../arch/arm64/kvm/hyp/include/nvhe/spinlock.h:18:#include <asm/rwonce.h> > ../../../../../arch/s390/include/asm/rwonce.h:29:#include <asm-generic/rwonce.h> > ../../../../../arch/x86/include/generated/asm/rwonce.h:1:#include <asm-generic/rwonce.h> > ../../../../../include/asm-generic/barrier.h:18:#include <asm/rwonce.h> > ../../../../../include/kunit/test.h:29:#include <asm/rwonce.h> > ../../../../../include/linux/compiler.h:246:#include <asm/rwonce.h> > > I figured out I must be doing something wrong or the kernel otherwise > would not build for me. > > Eventually, the UNIX_DIAG_UID enum is used in only one place: > > ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); > > That particular test should fail in case of kernel older than 5.3. We don't expect it to be run on older kernels in the first place. > > However, I fell into a terrible mess where one thing breaks the other. > > I can't seem to make this work. > > Thanks, > Mirsad
Hi, On 5/22/23 20:26, Kuniyuki Iwashima wrote: >>> >>> I launched AlmaLinux/RockyLinux 8.7 and 9.2 with images listed in the pages >>> below. >>> >>> https://wiki.almalinux.org/cloud/AWS.html#community-amis >>> https://rockylinux.org/cloud-images/ >>> >>> The kernel versions in each image were : >>> >>> 8.7: >>> Alma : 4.18.0-425.3.1.el8.x86_64 >>> Rocky : 4.18.0-425.10.1.el8_7.x86_64 >>> >>> 9.2: >>> Alma : 5.14.0-284.11.1.el9_2.x86_64 >>> Rocky : 5.14.0-284.11.1.el9_2.x86_64 >>> >>> So, this is not a bug. It's just because v4.18 does not support >>> UNIX_DIAG_UID, which was introduced in v5.3. >>> >>> You should install 5.3+ kernel if you want to build the test. >>> >>> Thanks, >>> Kuniyuki >> >> Hi, Kuniyuki, >> >> Good point. However, newer kernel won't save me from old /usr/include >> headers, will it? > > Sorry, I meant kernel and kernel-headers package that should be > updated along with kernel. > > You should use proper header files that match to the actual kernel > version running on the machine. > > >> I was actually testing the 6.4-rc3 on AlmaLinux 8.7, as it is my only >> RHEL-based box ... >> >> What would then be the right action? > > make headers_install ? I would rather not to. For the installation to remain manageable, preferably I'd have a kernel-devel RPM built. >> If it was a #define instead of enum, I'd probably work around and >> exclude the test that doesn't fit the kernel, or the system call >> would return -EINVAL? >> >> Including from the includes that came with the kernel might be >> a solution: >> >> ../../../../../include/uapi/linux/unix_diag.h:44: UNIX_DIAG_UID, >> >> Alas, when I try to include, I get these ugly errors: >> >> [marvin@pc-mtodorov af_unix]$ gcc -I ../../../../../include/ diag_uid.c >> In file included from ../../../../../include/linux/build_bug.h:5, >> from ../../../../../include/linux/bits.h:21, >> from ../../../../../include/linux/capability.h:18, >> from ../../../../../include/linux/netlink.h:6, >> from diag_uid.c:8: >> ../../../../../include/linux/compiler.h:246:10: fatal error: >> asm/rwonce.h: No such file or directory >> #include <asm/rwonce.h> >> ^~~~~~~~~~~~~~ > > FWIW, this is provided by kernel-devel package. Actually, what is provided is essentially the same as before: [root@pc-mtodorov kernel]# rpm -q --fileprovide kernel-devel-6.3.3 | grep rwonce.h /usr/src/kernels/6.3.3-100.fc37.x86_64/arch/x86/include/generated/asm/rwonce.h /usr/src/kernels/6.3.3-100.fc37.x86_64/include/asm-generic/rwonce.h [root@pc-mtodorov kernel]# >> compilation terminated. >> [marvin@pc-mtodorov af_unix]$ vi +246 >> ../../../../../include/linux/compiler.h >> [marvin@pc-mtodorov af_unix]$ find ../../../../../include -name rwonce.h >> ../../../../../include/asm-generic/rwonce.h >> [marvin@pc-mtodorov af_unix]$ >> >> Minimum reproducer is: >> >> [marvin@pc-mtodorov af_unix]$ gcc -I ../../../../../include/ reproducer.c >> In file included from ../../../../../include/linux/build_bug.h:5, >> from ../../../../../include/linux/bits.h:21, >> from ../../../../../include/linux/capability.h:18, >> from ../../../../../include/linux/netlink.h:6, >> from reproducer.c:5: >> ../../../../../include/linux/compiler.h:246:10: fatal error: >> asm/rwonce.h: No such file or directory >> #include <asm/rwonce.h> >> ^~~~~~~~~~~~~~ >> compilation terminated. >> [marvin@pc-mtodorov af_unix]$ >> >> [marvin@pc-mtodorov af_unix]$ nl reproducer.c >> >> 1 #define _GNU_SOURCE >> 2 #include <linux/netlink.h> >> >> [marvin@pc-mtodorov af_unix]$ >> >> Am I doing something very stupid right now, for actually I see >> >> #include <asm/rwonce.h> >> >> in "include/linux/compiler.h" 248L, 7843C >> >> while actual rwonce.h is in <asm-generic/rwonce.h> >> >> [marvin@pc-mtodorov af_unix]$ find ../../../../../include -name rwonce.h >> ../../../../../include/asm-generic/rwonce.h >> [marvin@pc-mtodorov af_unix]$ >> >> I must be doing something wrong, for I see that the kernel compiled >> despite not having include/asm ? >> >> When looking at the invocations of rwonce.h in the kernel, they seem to >> be equally spread between <asm-generic/rwonce.h> and <asm/rwonce.h> : >> >> [marvin@pc-mtodorov af_unix]$ grep --include="*.[ch]" -n -w rwonce.h -r ../../../../.. 2> /dev/null | less >> ../../../../../arch/alpha/include/asm/rwonce.h:33:#include <asm-generic/rwonce.h> >> ../../../../../arch/arm64/include/asm/rwonce.h:71:#include <asm-generic/rwonce.h> >> ../../../../../arch/arm64/kvm/hyp/include/nvhe/spinlock.h:18:#include <asm/rwonce.h> >> ../../../../../arch/s390/include/asm/rwonce.h:29:#include <asm-generic/rwonce.h> >> ../../../../../arch/x86/include/generated/asm/rwonce.h:1:#include <asm-generic/rwonce.h> >> ../../../../../include/asm-generic/barrier.h:18:#include <asm/rwonce.h> >> ../../../../../include/kunit/test.h:29:#include <asm/rwonce.h> >> ../../../../../include/linux/compiler.h:246:#include <asm/rwonce.h> >> >> I figured out I must be doing something wrong or the kernel otherwise >> would not build for me. >> >> Eventually, the UNIX_DIAG_UID enum is used in only one place: >> >> ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); >> >> That particular test should fail in case of kernel older than 5.3. > > We don't expect it to be run on older kernels in the first place. Certainly. >> However, I fell into a terrible mess where one thing breaks the other. >> >> I can't seem to make this work. >> >> Thanks, >> Mirsad
diff --git a/tools/testing/selftests/net/af_unix/diag_uid.c b/tools/testing/selftests/net/af_unix/diag_uid.c index 5b88f7129fea..66d75b646d35 100644 --- a/tools/testing/selftests/net/af_unix/diag_uid.c +++ b/tools/testing/selftests/net/af_unix/diag_uid.c @@ -16,6 +16,10 @@ #include "../../kselftest_harness.h" +#ifndef UDIAG_SHOW_UID +#define UDIAG_SHOW_UID 0x00000040 /* show socket's UID */ +#endif + FIXTURE(diag_uid) { int netlink_fd; -- However, this patch reveals another undefined value: make[2]: Entering directory '/home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix' gcc diag_uid.c -o /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix/diag_uid In file included from diag_uid.c:17: diag_uid.c: In function ‘render_response’: diag_uid.c:132:28: error: ‘UNIX_DIAG_UID’ undeclared (first use in this function); did you mean ‘UNIX_DIAG_VFS’? ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); ^~~~~~~~~~~~~ ../../kselftest_harness.h:707:13: note: in definition of macro ‘__EXPECT’ __typeof__(_seen) __seen = (_seen); \ ^~~~~ diag_uid.c:132:2: note: in expansion of macro ‘ASSERT_EQ’ ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); ^~~~~~~~~ diag_uid.c:132:28: note: each undeclared identifier is reported only once for each function it appears in ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); ^~~~~~~~~~~~~ ../../kselftest_harness.h:707:13: note: in definition of macro ‘__EXPECT’ __typeof__(_seen) __seen = (_seen); \ ^~~~~ diag_uid.c:132:2: note: in expansion of macro ‘ASSERT_EQ’ ASSERT_EQ(attr->rta_type, UNIX_DIAG_UID); ^~~~~~~~~ make[2]: *** [../../lib.mk:147: /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/net/af_unix/diag_uid] Error 1 Apparently, AlmaLinux 8.7 lacks this enum UNIX_DIAG_UID: diff -u /usr/include/linux/unix_diag.h include/uapi/linux/unix_diag.h --- /usr/include/linux/unix_diag.h 2023-05-16 13:47:51.000000000 +0200 +++ include/uapi/linux/unix_diag.h 2022-10-12 07:35:58.253481367 +0200 @@ -20,6 +20,7 @@ #define UDIAG_SHOW_ICONS 0x00000008 /* show pending connections */ #define UDIAG_SHOW_RQLEN 0x00000010 /* show skb receive queue len */ #define UDIAG_SHOW_MEMINFO 0x00000020 /* show memory info of a socket */ +#define UDIAG_SHOW_UID 0x00000040 /* show socket's UID */ struct unix_diag_msg { __u8 udiag_family; @@ -40,6 +41,7 @@ UNIX_DIAG_RQLEN, UNIX_DIAG_MEMINFO, UNIX_DIAG_SHUTDOWN, + UNIX_DIAG_UID, __UNIX_DIAG_MAX, };