[llvm-bugs] [Bug 26979] New: UBSan: missing checks for invalid arguments of __builtin_clz and friends

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 17 15:57:19 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=26979

            Bug ID: 26979
           Summary: UBSan: missing checks for invalid arguments of
                    __builtin_clz and friends
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: vonosmas at gmail.com
                CC: kcc at google.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk
    Classification: Unclassified

@llvm.ctlz and @llvm.cttz intrinsics have argument "i1 <is_zero_undef>" which
is defined by the target. If passing zero is considered an undefined behavior
(e.g. this is often the case for __builtin_ctz), UBSan can emit a runtime
check, that would print an error report if the argument happens to be zero.

The code in question is CodeGenFunction::EmitBuiltinExpr: if we figure out that
getTarget().isCLZForZeroUndef() is true, we can emit a regular UBSan check.
It's possible we will need to introduce a separate handler for that.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160317/bb6fe055/attachment-0001.html>


More information about the llvm-bugs mailing list