* [PATCH] hv: hyperv.h: Annotate vmbus_channel_gpadl_header with __counted_by()
@ 2024-10-15 10:18 Thorsten Blum
2024-10-16 4:16 ` kernel test robot
2024-12-07 7:48 ` Wei Liu
0 siblings, 2 replies; 5+ messages in thread
From: Thorsten Blum @ 2024-10-15 10:18 UTC (permalink / raw)
To: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Kees Cook,
Gustavo A. R. Silva
Cc: Thorsten Blum, linux-hyperv, linux-kernel, linux-hardening
Add the __counted_by compiler attribute to the flexible array member
range to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
CONFIG_FORTIFY_SOURCE.
Compile-tested only.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
include/linux/hyperv.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 22c22fb91042..ec62d625c439 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -643,7 +643,7 @@ struct vmbus_channel_gpadl_header {
u32 gpadl;
u16 range_buflen;
u16 rangecount;
- struct gpa_range range[];
+ struct gpa_range range[] __counted_by(rangecount);
} __packed;
/* This is the followup packet that contains more PFNs. */
--
2.47.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] hv: hyperv.h: Annotate vmbus_channel_gpadl_header with __counted_by()
2024-10-15 10:18 [PATCH] hv: hyperv.h: Annotate vmbus_channel_gpadl_header with __counted_by() Thorsten Blum
@ 2024-10-16 4:16 ` kernel test robot
2024-12-07 7:48 ` Wei Liu
1 sibling, 0 replies; 5+ messages in thread
From: kernel test robot @ 2024-10-16 4:16 UTC (permalink / raw)
To: Thorsten Blum, K. Y. Srinivasan, Haiyang Zhang, Wei Liu,
Dexuan Cui, Kees Cook, Gustavo A. R. Silva
Cc: llvm, oe-kbuild-all, Thorsten Blum, linux-hyperv, linux-kernel,
linux-hardening
Hi Thorsten,
kernel test robot noticed the following build warnings:
[auto build test WARNING on kees/for-next/pstore]
[also build test WARNING on kees/for-next/kspp linus/master v6.12-rc3 next-20241015]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Thorsten-Blum/hv-hyperv-h-Annotate-vmbus_channel_gpadl_header-with-__counted_by/20241015-182055
base: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/pstore
patch link: https://lore.kernel.org/r/20241015101829.94876-2-thorsten.blum%40linux.dev
patch subject: [PATCH] hv: hyperv.h: Annotate vmbus_channel_gpadl_header with __counted_by()
config: arm64-randconfig-001-20241016 (https://download.01.org/0day-ci/archive/20241016/202410161148.ODpoEJF0-lkp@intel.com/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project bfe84f7085d82d06d61c632a7bad1e692fd159e4)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241016/202410161148.ODpoEJF0-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410161148.ODpoEJF0-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from arch/arm64/hyperv/hv_core.c:13:
In file included from include/linux/mm.h:2228:
include/linux/vmstat.h:500:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
500 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
501 | item];
| ~~~~
include/linux/vmstat.h:507:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
507 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
508 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
514 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:519:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
519 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
520 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:528:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
528 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
529 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
In file included from arch/arm64/hyperv/hv_core.c:14:
>> include/linux/hyperv.h:646:2: warning: 'counted_by' should not be applied to an array with element of unknown size because 'struct gpa_range' is a struct type with a flexible array member. This will be an error in a future compiler version [-Wbounds-safety-counted-by-elt-type-unknown-size]
646 | struct gpa_range range[] __counted_by(rangecount);
| ^~~~~~~~~~~~~~~~~~~~~~~~
6 warnings generated.
vim +646 include/linux/hyperv.h
633
634 /*
635 * The number of PFNs in a GPADL message is defined by the number of
636 * pages that would be spanned by ByteCount and ByteOffset. If the
637 * implied number of PFNs won't fit in this packet, there will be a
638 * follow-up packet that contains more.
639 */
640 struct vmbus_channel_gpadl_header {
641 struct vmbus_channel_message_header header;
642 u32 child_relid;
643 u32 gpadl;
644 u16 range_buflen;
645 u16 rangecount;
> 646 struct gpa_range range[] __counted_by(rangecount);
647 } __packed;
648
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] hv: hyperv.h: Annotate vmbus_channel_gpadl_header with __counted_by()
2024-10-15 10:18 [PATCH] hv: hyperv.h: Annotate vmbus_channel_gpadl_header with __counted_by() Thorsten Blum
2024-10-16 4:16 ` kernel test robot
@ 2024-12-07 7:48 ` Wei Liu
2024-12-09 0:16 ` Thorsten Blum
1 sibling, 1 reply; 5+ messages in thread
From: Wei Liu @ 2024-12-07 7:48 UTC (permalink / raw)
To: Thorsten Blum
Cc: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Kees Cook,
Gustavo A. R. Silva, linux-hyperv, linux-kernel, linux-hardening
On Tue, Oct 15, 2024 at 12:18:29PM +0200, Thorsten Blum wrote:
> Add the __counted_by compiler attribute to the flexible array member
> range to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
> CONFIG_FORTIFY_SOURCE.
>
> Compile-tested only.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Applied to hyperv-fixes. Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] hv: hyperv.h: Annotate vmbus_channel_gpadl_header with __counted_by()
2024-12-07 7:48 ` Wei Liu
@ 2024-12-09 0:16 ` Thorsten Blum
2024-12-09 0:46 ` Wei Liu
0 siblings, 1 reply; 5+ messages in thread
From: Thorsten Blum @ 2024-12-09 0:16 UTC (permalink / raw)
To: Wei Liu
Cc: K. Y. Srinivasan, Haiyang Zhang, Dexuan Cui, Kees Cook,
Gustavo A. R. Silva, linux-hyperv, linux-kernel, linux-hardening
On 7. Dec 2024, at 08:48, Wei Liu wrote:
> On Tue, Oct 15, 2024 at 12:18:29PM +0200, Thorsten Blum wrote:
>> Add the __counted_by compiler attribute to the flexible array member
>> range to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
>> CONFIG_FORTIFY_SOURCE.
>>
>> Compile-tested only.
>>
>> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
>
> Applied to hyperv-fixes. Thanks.
This should probably not be applied anymore given the kernel test robot
build warnings. Unless I missed something and this works now?
Thanks,
Thorsten
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] hv: hyperv.h: Annotate vmbus_channel_gpadl_header with __counted_by()
2024-12-09 0:16 ` Thorsten Blum
@ 2024-12-09 0:46 ` Wei Liu
0 siblings, 0 replies; 5+ messages in thread
From: Wei Liu @ 2024-12-09 0:46 UTC (permalink / raw)
To: Thorsten Blum
Cc: Wei Liu, K. Y. Srinivasan, Haiyang Zhang, Dexuan Cui, Kees Cook,
Gustavo A. R. Silva, linux-hyperv, linux-kernel, linux-hardening
On Mon, Dec 09, 2024 at 01:16:01AM +0100, Thorsten Blum wrote:
> On 7. Dec 2024, at 08:48, Wei Liu wrote:
> > On Tue, Oct 15, 2024 at 12:18:29PM +0200, Thorsten Blum wrote:
> >> Add the __counted_by compiler attribute to the flexible array member
> >> range to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
> >> CONFIG_FORTIFY_SOURCE.
> >>
> >> Compile-tested only.
> >>
> >> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> >
> > Applied to hyperv-fixes. Thanks.
>
> This should probably not be applied anymore given the kernel test robot
> build warnings. Unless I missed something and this works now?
Yes, you're right. The patch has been dropped from hyperv-fixes.
Thanks,
Wei.
>
> Thanks,
> Thorsten
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-12-09 0:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-15 10:18 [PATCH] hv: hyperv.h: Annotate vmbus_channel_gpadl_header with __counted_by() Thorsten Blum
2024-10-16 4:16 ` kernel test robot
2024-12-07 7:48 ` Wei Liu
2024-12-09 0:16 ` Thorsten Blum
2024-12-09 0:46 ` Wei Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox