Skip to content

New fortify warning in fs/smb/client/cifsencrypt.c after LLVM commit d77067d08a3f56dc2d0e6c95bd2852c943df743a #1966

@nathanchance

Description

@nathanchance

After llvm/llvm-project@d77067d, I see a warning in fs/smb/client/cifsencrypt.c with multiple architectures.

$ make -skj"$(nproc)" ARCH=arm64 LLVM=1 mrproper allmodconfig fs/smb/client/cifsencrypt.o
In file included from fs/smb/client/cifsencrypt.c:12:
In file included from include/linux/fs.h:6:
In file included from include/linux/wait_bit.h:8:
In file included from include/linux/wait.h:9:
In file included from include/linux/spinlock.h:56:
In file included from include/linux/preempt.h:79:
In file included from arch/x86/include/asm/preempt.h:9:
In file included from include/linux/thread_info.h:60:
In file included from arch/x86/include/asm/thread_info.h:53:
In file included from arch/x86/include/asm/cpufeature.h:5:
In file included from arch/x86/include/asm/processor.h:19:
In file included from arch/x86/include/asm/cpuid.h:62:
In file included from arch/x86/include/asm/paravirt.h:17:
In file included from include/linux/cpumask.h:12:
In file included from include/linux/bitmap.h:12:
In file included from include/linux/string.h:295:
include/linux/fortify-string.h:489:4: error: call to '__write_overflow_field' declared with 'warning' attribute: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror,-Wattribute-warning]
  489 |                         __write_overflow_field(p_size_field, size);
      |                         ^
1 error generated.

cvise spits out:

char calc_ntlmv2_hash_ses_1;
long calc_ntlmv2_hash___trans_tmp_3, calc_ntlmv2_hash___trans_tmp_1;
short *calc_ntlmv2_hash_user;
void __write_overflow_field()
    __attribute__((__warning__("detected write beyond size of field (1st "
                               "parameter); maybe use struct_group()?")));
__attribute__((__alloc_size__(1))) void *kmalloc(long);
int calc_ntlmv2_hash() {
  int len = calc_ntlmv2_hash_ses_1
                ? __builtin_choose_expr(0, 0, calc_ntlmv2_hash___trans_tmp_3)
                : 0;
  calc_ntlmv2_hash_user = kmalloc(2 + len * 2);
  if (len)
    ;
  else {
    long __fortify_size = 2, size = __fortify_size;
    calc_ntlmv2_hash___trans_tmp_1 =
        __builtin_dynamic_object_size(calc_ntlmv2_hash_user, 1);
    int p_size_field = calc_ntlmv2_hash___trans_tmp_1;
    if (p_size_field < size)
      __write_overflow_field();
  }
  return 0;
}

@ llvm/llvm-project@a1b9736:

$ clang -O2 -c -o /dev/null cifsencrypt.i

@ llvm/llvm-project@d77067d:

$ clang -O2 -c -o /dev/null cifsencrypt.i
cifsencrypt.i:21:7: warning: call to '__write_overflow_field' declared with 'warning' attribute: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Wattribute-warning]
   21 |       __write_overflow_field();
      |       ^
1 warning generated.

GCC 13.2.0 also does not show any warning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Reported upstreamThis bug was filed on LLVM’s issue tracker, Phabricator, or the kernel mailing list.[BUG] llvm (main)A bug in an unreleased version of LLVM (this label is appropriate for regressions)[WORKAROUND] AppliedThis bug has an applied workaround

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions