lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210521085849.37676-1-joerichey94@gmail.com>
Date:   Fri, 21 May 2021 01:58:41 -0700
From:   Joe Richey <joerichey94@...il.com>
To:     trivial@...nel.org
Cc:     Joe Richey <joerichey@...gle.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        Zhangfei Gao <zhangfei.gao@...aro.org>,
        Zhou Wang <wangzhou1@...ilicon.com>,
        Andy Whitcroft <apw@...onical.com>,
        Joe Perches <joe@...ches.com>,
        Dwaipayan Ray <dwaipayanray1@...il.com>,
        Lukas Bulwahn <lukas.bulwahn@...il.com>,
        Andi Kleen <ak@...ux.intel.com>,
        "Chang S. Bae" <chang.seok.bae@...el.com>,
        Sasha Levin <sashal@...nel.org>, Peter Xu <peterx@...hat.com>,
        Lei Cao <lei.cao@...atus.com>,
        Ulf Hansson <ulf.hansson@...aro.org>,
        "Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
        Daniel Lezcano <daniel.lezcano@...aro.org>,
        Kenneth Lee <liguozhu@...ilicon.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Jean-Philippe Brucker <jean-philippe@...aro.org>,
        Jonathan Cameron <Jonathan.Cameron@...wei.com>,
        Hans Verkuil <hverkuil-cisco@...all.nl>,
        linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org, linux-media@...r.kernel.org,
        linux-accelerators@...ts.ozlabs.org
Subject: [PATCH v2 0/7] Don't use BIT() macro in UAPI headers

From: Joe Richey <joerichey@...gle.com>

The BIT(n) macro is used in the kernel as an alias for (1 << n).
However, it is not defined in the UAPI headers, they should instead use
the _BITUL(n) macro. This patch chages all existing usages in UAPI
headers and updates ./scripts/checkpatch.pl to properly reccomend the
correct macro depending on context.

Running the below commands shows no more incorrect macro usages:
    rg "BIT\(" **/uapi/**
    rg "BIT_ULL\(" **/uapi/**

Tested by building a basic kernel. Changes are trivial.

I encountered this issue when compiling the following program:
    #include <sys/auxv.h>
    #include <asm/hwcap2.h>
    // Detect if FSGSBASE instructions are enabled
    int main() {
        unsigned long val = getauxval(AT_HWCAP2);
        return !(val & HWCAP2_FSGSBASE);
    }

Resulting in the following likner error:
    /usr/bin/ld: /tmp/cceFpAdR.o: in function `main':
    gs.c:(.text+0x21): undefined reference to `BIT'

Changes from V1 to V2:
  - Use _BITUL() macro instead of open-coding
  - Fixup HWCAP2_RING3MWAIT as well
  - Shorten commits and added "Fixes" per reviewer comments
  - checkpatch: Broaden UAPI regex
  - checkpatch: Reccomend _BITULL()/_BITUL() for UAPI headers

Joe Richey (7):
  x86/elf: Use _BITUL() macro in UAPI headers
  KVM: X86: Use _BITUL() macro in UAPI headers
  drivers: firmware: psci:  Use _BITUL() macro in UAPI headers
  uacce: Use _BITUL() macro in UAPI headers
  media: vicodec: Use _BITUL() macro in UAPI headers
  tools headers UAPI: Sync pkt_sched.h with the kernel sources
  checkpatch: suggest _BITULL() and _BITUL() for UAPI headers

 arch/x86/include/uapi/asm/hwcap2.h   |   6 +-
 include/uapi/linux/kvm.h             |   5 +-
 include/uapi/linux/psci.h            |   4 +-
 include/uapi/linux/v4l2-controls.h   |  23 ++---
 include/uapi/misc/uacce/uacce.h      |   3 +-
 scripts/checkpatch.pl                |  16 ++--
 tools/include/uapi/linux/kvm.h       |   5 +-
 tools/include/uapi/linux/pkt_sched.h | 122 ++++++++++++++++++++++++---
 8 files changed, 148 insertions(+), 36 deletions(-)

-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ