treewide: address gcc-11 -Wstringop-overread warnings
Subsystems (18)
cover treewide: address gcc-11 -Wstringop-overread warnings
From: Arnd Bergmann <[email protected]>
The coming gcc release introduces a new warning for string operations reading beyond the end of a fixed-length object. After testing randconfig kernels for a while, think I have patches for any such warnings that came up on x86, arm and arm64.
Most of these warnings are false-positive ones, either gcc warning about something that is entirely correct, or about something that looks suspicious but turns out to be correct after all.
The two patches for the i915 driver look like something that might be actual bugs, but I am not sure about those either.
We probably want some combination of workaround like the ones I post here and changes to gcc to have fewer false positives in the release. I'm posting the entire set of workaround that give me a cleanly building kernel for reference here.
Arnd
Arnd Bergmann (11):
x86: compressed: avoid gcc-11 -Wstringop-overread warning
x86: tboot: avoid Wstringop-overread-warning
security: commoncap: fix -Wstringop-overread warning
ath11: Wstringop-overread warning
qnx: avoid -Wstringop-overread warning
cgroup: fix -Wzero-length-bounds warnings
ARM: sharpsl_param: work around -Wstringop-overread warning
atmel: avoid gcc -Wstringop-overflow warning
scsi: lpfc: fix gcc -Wstringop-overread warning drm/i915: avoid stringop-overread warning on pri_latency [RFC] drm/i915/dp: fix array overflow warning
arch/arm/common/sharpsl_param.c | 4 ++- arch/x86/boot/compressed/misc.c | 2 -- arch/x86/kernel/tboot.c | 44 +++++++++++++++---------- drivers/gpu/drm/i915/display/intel_dp.c | 2 +- drivers/gpu/drm/i915/i915_drv.h | 6 ++-- drivers/net/wireless/ath/ath11k/mac.c | 2 +- drivers/net/wireless/atmel/atmel.c | 25 ++++++++------ drivers/scsi/lpfc/lpfc_attr.c | 6 ++-- fs/qnx4/dir.c | 11 +++---- kernel/cgroup/cgroup.c | 15 +++++++-- security/commoncap.c | 2 +- 11 files changed, 69 insertions(+), 50 deletions(-)
Signature · 1 line
2.29.2
PATCH 1/11 x86: compressed: avoid gcc-11 -Wstringop-overread warning
From: Arnd Bergmann <[email protected]>
gcc gets confused by the comparison of a pointer to an integer listeral, with the assumption that this is an offset from a NULL pointer and that dereferencing it is invalid:
In file included from arch/x86/boot/compressed/misc.c:18:
In function ‘parse_elf’,
inlined from ‘extract_kernel’ at arch/x86/boot/compressed/misc.c:442:2:arch/x86/boot/compressed/../string.h:15:23: error: ‘__builtin_memcpy’ reading 64 bytes from a region of size 0 [-Werror=stringop-overread]
15 | #define memcpy(d,s,l) __builtin_memcpy(d,s,l)
| ^~~~~~~~~~~~~~~~~~~~~~~
arch/x86/boot/compressed/misc.c:283:9: note: in expansion of macro ‘memcpy’
283 | memcpy(&ehdr, output, sizeof(ehdr));
| ^~~~~~I could not find any good workaround for this, but as this is only a warning for a failure during early boot, removing the line entirely works around the warning.
This should probably get addressed in gcc instead, before 11.1 gets released.
--- arch/x86/boot/compressed/misc.c | 2 -- 1 file changed, 2 deletions(-)
arch/x86/boot/compressed/misc.c +0 -2
@@ -430,8 +430,6 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,error ("Destination address too large" );#endif #ifndef CONFIG_RELOCATABLE -if ((unsigned long )output !=LOAD_PHYSICAL_ADDR ) -error ("Destination address does not match LOAD_PHYSICAL_ADDR" );if (virt_addr !=LOAD_PHYSICAL_ADDR )error ("Destination virtual address changed when not relocatable" );#endif
Signature · 1 line
2.29.2
PATCH 2/11 x86: tboot: avoid Wstringop-overread-warning
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
gcc-11 warns about using string operations on pointers that are defined at compile time as offsets from a NULL pointer. Unfortunately that also happens on the result of fix_to_virt(), which is a compile-time constant for a constantn input:
arch/x86/kernel/tboot.c: In function 'tboot_probe':arch/x86/kernel/tboot.c:70:13: error: '__builtin_memcmp_eq' specified bound 16 exceeds source size 0 [-Werror=stringop-overread]
70 | if (memcmp(&tboot_uuid, &tboot->uuid, sizeof(tboot->uuid))) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~I hope this can get addressed in gcc-11 before the release.
As a workaround, split up the tboot_probe() function in two halves to separate the pointer generation from the usage. This is a bit ugly, and hopefully gcc understands that the code is actually correct before it learns to peek into the noinline function.
--- arch/x86/kernel/tboot.c | 44 ++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 18 deletions(-)
arch/x86/kernel/tboot.c +26 -18
@@ -49,6 +49,30 @@ bool tboot_enabled(void)return tboot !=NULL ; } +/* noinline to prevent gcc from warning about dereferencing constant fixaddr */ +static noinline __init bool check_tboot_version(void) +{ +if (memcmp (&tboot_uuid, &tboot->uuid,sizeof (tboot->uuid))) { +pr_warn ("tboot at 0x%llx is invalid\n" , boot_params.tboot_addr); +return false; + } + +if (tboot->version <5 ) { +pr_warn ("tboot version is invalid: %u\n" , tboot->version); +return false; + } + +pr_info ("found shared page at phys addr 0x%llx:\n" , + boot_params.tboot_addr); +pr_debug ("version: %d\n" , tboot->version); +pr_debug ("log_addr: 0x%08x\n" , tboot->log_addr); +pr_debug ("shutdown_entry: 0x%x\n" , tboot->shutdown_entry); +pr_debug ("tboot_base: 0x%08x\n" , tboot->tboot_base); +pr_debug ("tboot_size: 0x%x\n" , tboot->tboot_size); + +return true; +} +void __init tboot_probe (void ) {/* Look for valid page-aligned address for shared page. */
@@ -66,25 +90,9 @@ void __init tboot_probe(void)/* Map and check for tboot UUID. */ set_fixmap (FIX_TBOOT_BASE , boot_params.tboot_addr); - tboot = (struct tboot *)fix_to_virt (FIX_TBOOT_BASE ); -if (memcmp (&tboot_uuid, &tboot->uuid,sizeof (tboot->uuid))) { -pr_warn ("tboot at 0x%llx is invalid\n" , boot_params.tboot_addr); + tboot = (void *)fix_to_virt (FIX_TBOOT_BASE ); +if (!check_tboot_version ()) tboot =NULL ; -return ; - } -if (tboot->version <5 ) { -pr_warn ("tboot version is invalid: %u\n" , tboot->version); - tboot =NULL ; -return ; - } - -pr_info ("found shared page at phys addr 0x%llx:\n" , - boot_params.tboot_addr); -pr_debug ("version: %d\n" , tboot->version); -pr_debug ("log_addr: 0x%08x\n" , tboot->log_addr); -pr_debug ("shutdown_entry: 0x%x\n" , tboot->shutdown_entry); -pr_debug ("tboot_base: 0x%08x\n" , tboot->tboot_base); -pr_debug ("tboot_size: 0x%x\n" , tboot->tboot_size); }static pgd_t *tboot_pg_dir;
Signature · 1 line
2.29.2
PATCH 3/11 security: commoncap: fix -Wstringop-overread warning
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
gcc-11 introdces a harmless warning for cap_inode_getsecurity:
security/commoncap.c: In function ‘cap_inode_getsecurity’:security/commoncap.c:440:33: error: ‘memcpy’ reading 16 bytes from a region of size 0 [-Werror=stringop-overread]
440 | memcpy(&nscap->data, &cap->data, sizeof(__le32) * 2 * VFS_CAP_U32);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~The problem here is that tmpbuf is initialized to NULL, so gcc assumes it is not accessible unless it gets set by vfs_getxattr_alloc(). This is a legitimate warning as far as I can tell, but the code is correct since it correctly handles the error when that function fails.
Add a separate NULL check to tell gcc about it as well.
--- security/commoncap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/commoncap.c +1 -1
@@ -400,7 +400,7 @@ int cap_inode_getsecurity(struct user_namespace *mnt_userns, &tmpbuf, size, GFP_NOFS);dput (dentry); -if (ret <0 ) +if (ret <0 || !tmpbuf)return ret; fs_ns = inode->i_sb->s_user_ns;
Signature · 1 line
2.29.2
PATCH 4/11 ath11: Wstringop-overread warning
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
gcc-11 with the kernel address sanitizer prints a warning for this driver:
In function 'ath11k_peer_assoc_h_vht',
inlined from 'ath11k_peer_assoc_prepare' at drivers/net/wireless/ath/ath11k/mac.c:1632:2:
drivers/net/wireless/ath/ath11k/mac.c:1164:13: error: 'ath11k_peer_assoc_h_vht_masked' reading 16 bytes from a region of size 4 [-Werror=stringop-overread]
1164 | if (ath11k_peer_assoc_h_vht_masked(vht_mcs_mask))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~drivers/net/wireless/ath/ath11k/mac.c: In function 'ath11k_peer_assoc_prepare':drivers/net/wireless/ath/ath11k/mac.c:1164:13: note: referencing argument 1 of type 'const u16 *' {aka 'const short unsigned int *'} drivers/net/wireless/ath/ath11k/mac.c:969:1: note: in a call to function 'ath11k_peer_assoc_h_vht_masked'
969 | ath11k_peer_assoc_h_vht_masked(const u16 vht_mcs_mask[NL80211_VHT_NSS_MAX])
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
According to analysis from gcc developers, this is a glitch in the way gcc tracks the size of struct members. This should really get fixed in gcc, but it's also easy to work around this instance by changing the function prototype to no include the length of the array.
--- drivers/net/wireless/ath/ath11k/mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/mac.c +1 -1
@@ -966,7 +966,7 @@ ath11k_peer_assoc_h_ht_masked(const u8 ht_mcs_mask[IEEE80211_HT_MCS_MASK_LEN]) }static bool -ath11k_peer_assoc_h_vht_masked (const u16 vht_mcs_mask[NL80211_VHT_NSS_MAX ]) +ath11k_peer_assoc_h_vht_masked (const u16 vht_mcs_mask[]) {int nss;
Signature · 1 line
2.29.2
PATCH 5/11 qnx: avoid -Wstringop-overread warning
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
gcc-11 warns that the size of the link name is longer than the di_fname field:
fs/qnx4/dir.c: In function ‘qnx4_readdir’:fs/qnx4/dir.c:51:32: error: ‘strnlen’ specified bound 48 exceeds source size 16 [-Werror=stringop-overread]
51 | size = strnlen(de->di_fname, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from fs/qnx4/qnx4.h:3,
from fs/qnx4/dir.c:16:include/uapi/linux/qnx4_fs.h:45:25: note: source object declared here
45 | char di_fname[QNX4_SHORT_NAME_MAX];
The problem here is that we access the same pointer using two different structure layouts, but gcc determines the object size based on whatever it encounters first.
Change the strnlen to use the correct field size in each case, and change the first access to be on the longer field.
--- fs/qnx4/dir.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
fs/qnx4/dir.c +5 -6
@@ -39,21 +39,20 @@ static int qnx4_readdir(struct file *file, struct dir_context *ctx) ix = (ctx->pos >>QNX4_DIR_ENTRY_SIZE_BITS ) %QNX4_INODES_PER_BLOCK ;for (; ix <QNX4_INODES_PER_BLOCK ; ix++, ctx->pos +=QNX4_DIR_ENTRY_SIZE ) { offset = ix *QNX4_DIR_ENTRY_SIZE ; - de = (struct qnx4_inode_entry *) (bh->b_data + offset); -if (!de->di_fname[0 ]) + le = (struct qnx4_link_info *)(bh->b_data + offset); + de = (struct qnx4_inode_entry *)(bh->b_data + offset); +if (!le->dl_fname[0 ])continue ;if (!(de->di_status & (QNX4_FILE_USED |QNX4_FILE_LINK )))continue ;if (!(de->di_status &QNX4_FILE_LINK )) - size =QNX4_SHORT_NAME_MAX ; + size =strnlen (de->di_fname,sizeof (de->di_fname));else - size =QNX4_NAME_MAX ; - size =strnlen (de->di_fname, size); + size =strnlen (le->dl_fname,sizeof (le->dl_fname));QNX4DEBUG ((KERN_INFO "qnx4_readdir:%.*s\n" , size, de->di_fname));if (!(de->di_status &QNX4_FILE_LINK )) ino = blknum *QNX4_INODES_PER_BLOCK + ix -1 ;else { - le = (struct qnx4_link_info *)de; ino = (le32_to_cpu (le->dl_inode_blk) -1 ) *QNX4_INODES_PER_BLOCK + le->dl_inode_ndx;
Signature · 1 line
2.29.2
PATCH 6/11 cgroup: fix -Wzero-length-bounds warnings
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
When cgroups are enabled, but every single subsystem is turned off, CGROUP_SUBSYS_COUNT is zero, and the cgrp->subsys[] array has no members.
gcc-11 points out that this leads to an invalid access in any function that might access this array:
kernel/cgroup/cgroup.c: In function 'cgroup_addrm_files':kernel/cgroup/cgroup.c:460:58: warning: array subscript '<unknown>' is outside the bounds of an interior zero-length array 'struct cgroup_subsys_state *[0]' [-Wzero-length-bounds] kernel/cgroup/cgroup.c:460:24: note: in expansion of macro 'rcu_dereference_check'
460 | return rcu_dereference_check(cgrp->subsys[ss->id],
| ^~~~~~~~~~~~~~~~~~~~~
In file included from include/linux/cgroup.h:28,
from kernel/cgroup/cgroup-internal.h:5, from kernel/cgroup/cgroup.c:31:include/linux/cgroup-defs.h:422:43: note: while referencing 'subsys'
422 | struct cgroup_subsys_state __rcu *subsys[CGROUP_SUBSYS_COUNT];
I'm not sure what is expected to happen for such a configuration, presumably these functions are never calls in that case. Adding a sanity check in each function we get the warning for manages to shut up the warnings and do nothing instead.
---
I'm grouping this together with the -Wstringop-overread warnings, since the underlying logic in gcc seems to be the same.
--- kernel/cgroup/cgroup.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
kernel/cgroup/cgroup.c +12 -3
@@ -456,7 +456,7 @@ static u16 cgroup_ss_mask(struct cgroup *cgrp)static struct cgroup_subsys_state *cgroup_css (struct cgroup *cgrp,struct cgroup_subsys *ss) { -if (ss) +if (ss && (CGROUP_SUBSYS_COUNT >0 ))return rcu_dereference_check (cgrp->subsys[ss->id],lockdep_is_held (&cgroup_mutex));else
@@ -534,6 +534,9 @@ struct cgroup_subsys_state *cgroup_e_css(struct cgroup *cgrp, {struct cgroup_subsys_state *css; +if (CGROUP_SUBSYS_COUNT ==0 ) +return NULL ; + do { css = cgroup_css(cgrp, ss);
@@ -561,6 +564,9 @@ struct cgroup_subsys_state *cgroup_get_e_css(struct cgroup *cgrp, {struct cgroup_subsys_state *css; +if (CGROUP_SUBSYS_COUNT ==0 ) +return NULL ; +rcu_read_lock (); do {
@@ -630,7 +636,7 @@ struct cgroup_subsys_state *of_css(struct kernfs_open_file *of)* the matching css from the cgroup's subsys table is guaranteed to * be and stay valid until the enclosing operation is complete. */ -if (cft->ss) +if (cft->ss &&CGROUP_SUBSYS_COUNT >0 )return rcu_dereference_raw (cgrp->subsys[cft->ss->id]);else return &cgrp->self;
@@ -2343,6 +2349,9 @@ struct task_struct *cgroup_taskset_next(struct cgroup_taskset *tset,struct css_set *cset = tset->cur_cset;struct task_struct *task = tset->cur_task; +if (CGROUP_SUBSYS_COUNT ==0 ) +return NULL ; +while (&cset->mg_node != tset->csets) {if (!task) task = list_first_entry(&cset->mg_tasks,
@@ -4523,7 +4532,7 @@ void css_task_iter_start(struct cgroup_subsys_state *css, unsigned int flags, it->ss = css->ss; it->flags = flags; -if (it->ss) +if (it->ss &&CGROUP_SUBSYS_COUNT >0 ) it->cset_pos = &css->cgroup->e_csets[css->ss->id];else it->cset_pos = &css->cgroup->cset_links;
Signature · 1 line
2.29.2
PATCH 7/11 ARM: sharpsl_param: work around -Wstringop-overread warning
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
gcc warns that accessing a pointer based on a numeric constant may be an offset into a NULL pointer, and would therefore has zero accessible bytes:
arch/arm/common/sharpsl_param.c: In function ‘sharpsl_save_param’:arch/arm/common/sharpsl_param.c:43:9: error: ‘memcpy’ reading 64 bytes from a region of size 0 [-Werror=stringop-overread]
43 | memcpy(&sharpsl_param, param_start(PARAM_BASE), sizeof(struct sharpsl_param_info));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~In this particular case, the warning is bogus since this is the actual pointer, not an offset on a NULL pointer. Add a local variable to shut up the warning and hope it doesn't come back.
--- arch/arm/common/sharpsl_param.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm/common/sharpsl_param.c +3 -1
@@ -40,7 +40,9 @@ EXPORT_SYMBOL(sharpsl_param);void sharpsl_save_param (void ) { -memcpy (&sharpsl_param,param_start (PARAM_BASE ),sizeof (struct sharpsl_param_info )); +struct sharpsl_param_info *params =param_start (PARAM_BASE ); + +memcpy (&sharpsl_param, params,sizeof (*params));if (sharpsl_param.comadj_keyword !=COMADJ_MAGIC ) sharpsl_param.comadj=-1 ;
Signature · 1 line
2.29.2
PATCH 8/11 atmel: avoid gcc -Wstringop-overflow warning
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
gcc-11 notices that the fields as defined in the ass_req_format structure do not match the actual use of that structure:
cc1: error: writing 4 bytes into a region of size between 18446744073709551613 and 2 [-Werror=stringop-overflow=] drivers/net/wireless/atmel/atmel.c:2884:20: note: at offset [4, 6] into destination object ‘ap’ of size 6
2884 | u8 ap[ETH_ALEN]; /* nothing after here directly accessible */
| ^~drivers/net/wireless/atmel/atmel.c:2885:20: note: at offset [4, 6] into destination object ‘ssid_el_id’ of size 1
2885 | u8 ssid_el_id;
| ^~~~~~~~~~This is expected here because the actual structure layout is variable. As the code does not actually access the individual fields, replace them with a comment and fixed-length array so prevent gcc from complaining about it.
--- drivers/net/wireless/atmel/atmel.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
drivers/net/wireless/atmel/atmel.c +15 -10
@@ -2881,13 +2881,18 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)struct ass_req_format {__le16 capability;__le16 listen_interval; -u8 ap[ETH_ALEN ];/* nothing after here directly accessible */ -u8 ssid_el_id; -u8 ssid_len; -u8 ssid[MAX_SSID_LENGTH ]; -u8 sup_rates_el_id; -u8 sup_rates_len; -u8 rates[4 ]; +u8 ssid_el[ETH_ALEN +2 +MAX_SSID_LENGTH +2 +4 ]; +/* +* nothing after here directly accessible: +* +* u8 ap[ETH_ALEN]; +* u8 ssid_el_id; +* u8 ssid_len; +* u8 ssid[MAX_SSID_LENGTH]; +* u8 sup_rates_el_id; +* u8 sup_rates_len; +* u8 rates[4]; +*/ } body; header.frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
@@ -2907,13 +2912,13 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc) body.listen_interval =cpu_to_le16 (priv->listen_interval * priv->beacon_period); + ssid_el_p = body.ssid_el;/* current AP address - only in reassoc frame */ if (is_reassoc) { -memcpy (body.ap, priv->CurrentBSSID,ETH_ALEN ); - ssid_el_p = &body.ssid_el_id; +memcpy (ssid_el_p, priv->CurrentBSSID,ETH_ALEN ); + ssid_el_p +=ETH_ALEN ; bodysize =18 + priv->SSID_size; }else { - ssid_el_p = &body.ap[0 ]; bodysize =12 + priv->SSID_size; }
Signature · 1 line
2.29.2
PATCH 9/11 scsi: lpfc: fix gcc -Wstringop-overread warning
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
gcc-11 warns about an strnlen with a length larger than the size of the passed buffer:
drivers/scsi/lpfc/lpfc_attr.c: In function 'lpfc_nvme_info_show':drivers/scsi/lpfc/lpfc_attr.c:518:25: error: 'strnlen' specified bound 4095 exceeds source size 24 [-Werror=stringop-overread]
518 | strnlen(LPFC_NVME_INFO_MORE_STR, PAGE_SIZE - 1)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~In this case, the code is entirely valid, as the string is properly terminated, and the size argument is only there out of extra caution in case it exceeds a page.
This cannot really happen here, so just simplify it to a sizeof().
--- drivers/scsi/lpfc/lpfc_attr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/lpfc/lpfc_attr.c +2 -4
@@ -512,11 +512,9 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr,"6314 Catching potential buffer " "overflow > PAGE_SIZE = %lu bytes\n" , PAGE_SIZE); -strlcpy (buf +PAGE_SIZE -1 - -strnlen (LPFC_NVME_INFO_MORE_STR ,PAGE_SIZE -1 ), +strlcpy (buf +PAGE_SIZE -1 -sizeof (LPFC_NVME_INFO_MORE_STR ),LPFC_NVME_INFO_MORE_STR , -strnlen (LPFC_NVME_INFO_MORE_STR ,PAGE_SIZE -1 ) - +1 ); +sizeof (LPFC_NVME_INFO_MORE_STR ) +1 ); }return len;
Signature · 1 line
2.29.2
PATCH 10/11 drm/i915: avoid stringop-overread warning on pri_latency
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
gcc-11 warns about what appears to be an out-of-range array access:
In function ‘snb_wm_latency_quirk’,
inlined from ‘ilk_setup_wm_latency’ at drivers/gpu/drm/i915/intel_pm.c:3108:3:drivers/gpu/drm/i915/intel_pm.c:3057:9: error: ‘intel_print_wm_latency’ reading 16 bytes from a region of size 10 [-Werror=stringop-overread]
3057 | intel_print_wm_latency(dev_priv, "Primary", dev_priv->wm.pri_latency);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~drivers/gpu/drm/i915/intel_pm.c: In function ‘ilk_setup_wm_latency’:drivers/gpu/drm/i915/intel_pm.c:3057:9: note: referencing argument 3 of type ‘const u16 *’ {aka ‘const short unsigned int *’} drivers/gpu/drm/i915/intel_pm.c:2994:13: note: in a call to function ‘intel_print_wm_latency’
2994 | static void intel_print_wm_latency(struct drm_i915_private *dev_priv,
| ^~~~~~~~~~~~~~~~~~~~~~
My guess is that this code is actually safe because the size of the array depends on the hardware generation, and the function checks for that, but at the same time I would not expect the compiler to work it out correctly, and the code seems a little fragile with regards to future changes. Simply increasing the size of the array should help.
--- drivers/gpu/drm/i915/i915_drv.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -3
@@ -1095,11 +1095,11 @@ struct drm_i915_private {* in 0.5us units for WM1+. */ /* primary */ -u16 pri_latency[5 ]; +u16 pri_latency[8 ];/* sprite */ -u16 spr_latency[5 ]; +u16 spr_latency[8 ];/* cursor */ -u16 cur_latency[5 ]; +u16 cur_latency[8 ];/* * Raw watermark memory latency values * for SKL for all 8 levels
Signature · 1 line
2.29.2
RFC PATCH 11/11 drm/i915/dp: fix array overflow warning
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
gcc-11 warns that intel_dp_check_mst_status() has a local array of fourteen bytes and passes the last four bytes into a function that expects a six-byte array:
drivers/gpu/drm/i915/display/intel_dp.c: In function ‘intel_dp_check_mst_status’:drivers/gpu/drm/i915/display/intel_dp.c:4556:22: error: ‘drm_dp_channel_eq_ok’ reading 6 bytes from a region of size 4 [-Werror=stringop-overread]
4556 | !drm_dp_channel_eq_ok(&esi[10], intel_dp->lane_count)) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~drivers/gpu/drm/i915/display/intel_dp.c:4556:22: note: referencing argument 1 of type ‘const u8 *’ {aka ‘const unsigned char *’} In file included from drivers/gpu/drm/i915/display/intel_dp.c:38:include/drm/drm_dp_helper.h:1459:6: note: in a call to function ‘drm_dp_channel_eq_ok’
1459 | bool drm_dp_channel_eq_ok(const u8 link_status[DP_LINK_STATUS_SIZE],
| ^~~~~~~~~~~~~~~~~~~~
Clearly something is wrong here, but I can't quite figure out what. Changing the array size to 16 bytes avoids the warning, but is probably the wrong solution here.
--- drivers/gpu/drm/i915/display/intel_dp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_dp.c +1 -1
@@ -65,7 +65,7 @@#include "intel_vdsc.h" #include "intel_vrr.h" -#define DP_DPRX_ESI_LEN 14 +#define DP_DPRX_ESI_LEN 16/* DP DSC throughput values used for slice count calculations KPixels/s */ #define DP_DSC_PEAK_PIXEL_RATE 2720000
Signature · 1 line
2.29.2
Re: [PATCH 03/11] security: commoncap: fix -Wstringop-overread warning
In reply to Arnd BergmannQuoted 14 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
gcc-11 introdces a harmless warning for
cap_inode_getsecurity:
security/commoncap.c: In function ‘cap_inode_getsecurity’:security/commoncap.c:440:33: error: ‘memcpy’ reading 16 bytes from a region of size 0 [-Werror=stringop-overread]440 | memcpy(&nscap->data, &cap->data, sizeof(__le32) * 2 * VFS_CAP_U32); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~The problem here is that tmpbuf is initialized to NULL, so gcc assumes it is not accessible unless it gets set by
vfs_getxattr_alloc(). This is a legitimate warning as far as I can tell, but the code is correct since it correctly handles the error when that function fails.
Quoted 4 lines
Add a separate NULL check to tell gcc about it as well.
Signed-off-by Arnd Bergmann <[email protected]>---
Seems reasonable,
Patchwork
CI[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for treewide: address gcc-11 -Wstringop-overread warnings
In reply to Arnd Bergmann== Series Details ==
== Series Details ==
Series: treewide: address gcc-11 -Wstringop-overread warnings
URL : https://patchwork.freedesktop.org/series/88295/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip
8b23b18b19c9 x86: compressed: avoid gcc-11 -Wstringop-overread warning
-:15: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line)
#15:
inlined from ‘extract_kernel’ at arch/x86/boot/compressed/misc.c:442:2:total: 0 errors, 1 warnings, 0 checks, 8 lines checked6128f7213e8c x86: tboot: avoid Wstringop-overread-warning
-:13: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #13:
70 | if (memcmp(&tboot_uuid, &tboot->uuid, sizeof(tboot->uuid))) {
total: 0 errors, 1 warnings, 0 checks, 57 lines checked86478fbc483a security: commoncap: fix -Wstringop-overread warning
-:13: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #13:
440 | memcpy(&nscap->data, &cap->data, sizeof(__le32) * 2 * VFS_CAP_U32);
total: 0 errors, 1 warnings, 0 checks, 8 lines checked5dbb709eb530 ath11: Wstringop-overread warning
-:10: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #10:
inlined from 'ath11k_peer_assoc_prepare' at drivers/net/wireless/ath/ath11k/mac.c:1632:2:
total: 0 errors, 1 warnings, 0 checks, 8 lines checked85a87603017e qnx: avoid -Wstringop-overread warningc20cb7a6e190 cgroup: fix -Wzero-length-bounds warnings
-:22: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #22:
422 | struct cgroup_subsys_state __rcu *subsys[CGROUP_SUBSYS_COUNT];
-:40: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'CGROUP_SUBSYS_COUNT > 0' #40: FILE: kernel/cgroup/cgroup.c:459:
+ if (ss && (CGROUP_SUBSYS_COUNT > 0))
total: 0 errors, 1 warnings, 1 checks, 51 lines checkeda23dcecdfe93 ARM: sharpsl_param: work around -Wstringop-overread warning
-:15: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #15:
43 | memcpy(&sharpsl_param, param_start(PARAM_BASE), sizeof(struct sharpsl_param_info));
total: 0 errors, 1 warnings, 0 checks, 10 lines checkedce0bcacc57ff atmel: avoid gcc -Wstringop-overflow warning
-:12: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #12:
cc1: error: writing 4 bytes into a region of size between 18446744073709551613 and 2 [-Werror=stringop-overflow=]
-:44: WARNING:NETWORKING_BLOCK_COMMENT_STYLE: networking block comments don't use an empty /* line, use /* Comment... #44: FILE: drivers/net/wireless/atmel/atmel.c:2885:
+ /*
+ * nothing after here directly accessible:
total: 0 errors, 2 warnings, 0 checks, 41 lines checkedf449f33af4a3 scsi: lpfc: fix gcc -Wstringop-overread warning
-:11: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #11:
518 | strnlen(LPFC_NVME_INFO_MORE_STR, PAGE_SIZE - 1)
-:33: WARNING:STRLCPY: Prefer strscpy over strlcpy - see: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
#33: FILE: drivers/scsi/lpfc/lpfc_attr.c:515:
+ strlcpy(buf + PAGE_SIZE - 1 - sizeof(LPFC_NVME_INFO_MORE_STR),
total: 0 errors, 2 warnings, 0 checks, 13 lines checkede77df84376b1 drm/i915: avoid stringop-overread warning on pri_latency
-:12: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #12:
inlined from ‘ilk_setup_wm_latency’ at drivers/gpu/drm/i915/intel_pm.c:3108:3:
total: 0 errors, 1 warnings, 0 checks, 14 lines checkede9066fbd700e drm/i915/dp: fix array overflow warning
-:15: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #15:
4556 | !drm_dp_channel_eq_ok(&esi[10], intel_dp->lane_count)) {
total: 0 errors, 1 warnings, 0 checks, 8 lines checked
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✗ Fi.CI.SPARSE: warning for treewide: address gcc-11 -Wstringop-overread warnings
In reply to Arnd Bergmann== Series Details ==
== Series Details ==
Series: treewide: address gcc-11 -Wstringop-overread warnings
URL : https://patchwork.freedesktop.org/series/88295/
State : warning
== Summary ==
$ dim sparse --fast origin/drm-tip Sparse version: v0.6.2 Fast mode used, each commit won't be checked separately. - +drivers/gpu/drm/i915/gt/intel_reset.c:1323:5: warning: context imbalance in 'intel_gt_reset_trylock' - different lock contexts for basic block +drivers/gpu/drm/i915/gvt/mmio.c:295:23: warning: memcpy with byte count of 279040 +drivers/gpu/drm/i915/i915_perf.c:1434:15: warning: memset with byte count of 16777216 +drivers/gpu/drm/i915/i915_perf.c:1488:15: warning: memset with byte count of 16777216 +./include/linux/spinlock.h:409:9: warning: context imbalance in 'fwtable_read16' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'fwtable_read32' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'fwtable_read64' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'fwtable_read8' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'fwtable_write16' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'fwtable_write32' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'fwtable_write8' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen11_fwtable_read16' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen11_fwtable_read32' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen11_fwtable_read64' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen11_fwtable_read8' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen11_fwtable_write16' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen11_fwtable_write32' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen11_fwtable_write8' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen12_fwtable_read16' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen12_fwtable_read32' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen12_fwtable_read64' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen12_fwtable_read8' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen12_fwtable_write16' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen12_fwtable_write32' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen12_fwtable_write8' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen6_read16' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen6_read32' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen6_read64' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen6_read8' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen6_write16' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen6_write32' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen6_write8' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen8_write16' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen8_write32' - different lock contexts for basic block +./include/linux/spinlock.h:409:9: warning: context imbalance in 'gen8_write8' - different lock contexts for basic block
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✓ Fi.CI.BAT: success for treewide: address gcc-11 -Wstringop-overread warnings
In reply to Arnd Bergmann== Series Details ==
== Series Details ==
Series: treewide: address gcc-11 -Wstringop-overread warnings
URL : https://patchwork.freedesktop.org/series/88295/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_9880 -> Patchwork_19830
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/index.html
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_19830:
### IGT changes ###
#### Suppressed ####
The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.
* igt@gem_exec_fence@nb-await@vcs0:
- {fi-rkl-11500t}: NOTRUN -> [FAIL][1] +38 similar issues
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-rkl-11500t/igt@gem_exec_fence@[email protected]
* igt@prime_vgem@basic-read:
- {fi-rkl-11500t}: NOTRUN -> [SKIP][2] +3 similar issues
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-rkl-11500t/igt@[email protected]
Known issues
------------
Here are the changes found in Patchwork_19830 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@amdgpu/amd_basic@query-info:
- fi-tgl-y: NOTRUN -> [SKIP][3] ([fdo#109315])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-tgl-y/igt@amdgpu/[email protected]
* igt@amdgpu/amd_basic@semaphore:
- fi-icl-y: NOTRUN -> [SKIP][4] ([fdo#109315]) +17 similar issues
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-icl-y/igt@amdgpu/[email protected]
* igt@amdgpu/amd_cs_nop@fork-gfx0:
- fi-tgl-y: NOTRUN -> [SKIP][5] ([fdo#109315] / [i915#2575]) +16 similar issues
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-tgl-y/igt@amdgpu/[email protected]
* igt@debugfs_test@read_all_entries:
- fi-tgl-y: NOTRUN -> [DMESG-WARN][6] ([i915#402]) +2 similar issues
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-tgl-y/igt@debugfs_test@read_all_entries.html
* igt@gem_exec_suspend@basic-s0:
- fi-kbl-soraka: [PASS][7] -> [INCOMPLETE][8] ([i915#155])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9880/fi-kbl-soraka/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-kbl-soraka/igt@[email protected]
* igt@gem_huc_copy@huc-copy:
- fi-glk-dsi: NOTRUN -> [SKIP][9] ([fdo#109271] / [i915#2190])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-glk-dsi/igt@[email protected]
- fi-tgl-y: NOTRUN -> [SKIP][10] ([i915#2190])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-tgl-y/igt@[email protected]
- fi-icl-y: NOTRUN -> [SKIP][11] ([i915#2190])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-icl-y/igt@[email protected]
* igt@gem_tiled_fence_blits@basic:
- fi-kbl-8809g: [PASS][12] -> [TIMEOUT][13] ([i915#3145])
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9880/fi-kbl-8809g/igt@[email protected]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-kbl-8809g/igt@[email protected]
* igt@i915_pm_rpm@basic-pci-d3-state:
- fi-glk-dsi: NOTRUN -> [DMESG-WARN][14] ([i915#3143]) +26 similar issues
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-glk-dsi/igt@[email protected]
* igt@i915_pm_rpm@module-reload:
- fi-glk-dsi: NOTRUN -> [DMESG-WARN][15] ([i915#1982] / [i915#3143])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-glk-dsi/igt@[email protected]
* igt@i915_selftest@live@execlists:
- fi-bsw-kefka: [PASS][16] -> [INCOMPLETE][17] ([i915#2782] / [i915#2940])
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9880/fi-bsw-kefka/igt@i915_selftest@[email protected]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-bsw-kefka/igt@i915_selftest@[email protected]
* igt@i915_selftest@live@gt_heartbeat:
- fi-icl-y: NOTRUN -> [DMESG-FAIL][18] ([i915#2291] / [i915#541])
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-icl-y/igt@i915_selftest@live@gt_heartbeat.html
* igt@i915_selftest@live@gt_lrc:
- fi-tgl-y: NOTRUN -> [DMESG-FAIL][19] ([i915#2373])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-tgl-y/igt@i915_selftest@live@gt_lrc.html
* igt@i915_selftest@live@gt_pm:
- fi-tgl-y: NOTRUN -> [DMESG-FAIL][20] ([i915#1759])
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-tgl-y/igt@i915_selftest@live@gt_pm.html
* igt@kms_chamelium@dp-crc-fast:
- fi-icl-y: NOTRUN -> [SKIP][21] ([fdo#109284] / [fdo#111827]) +8 similar issues
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-icl-y/igt@[email protected]
* igt@kms_chamelium@hdmi-hpd-fast:
- fi-glk-dsi: NOTRUN -> [SKIP][22] ([fdo#109271] / [fdo#111827]) +8 similar issues
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-glk-dsi/igt@[email protected]
* igt@kms_chamelium@vga-edid-read:
- fi-tgl-y: NOTRUN -> [SKIP][23] ([fdo#111827]) +8 similar issues
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-tgl-y/igt@[email protected]
* igt@kms_force_connector_basic@force-load-detect:
- fi-icl-y: NOTRUN -> [SKIP][24] ([fdo#109285])
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-icl-y/igt@[email protected]
- fi-tgl-y: NOTRUN -> [SKIP][25] ([fdo#109285])
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-tgl-y/igt@[email protected]
* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-d:
- fi-glk-dsi: NOTRUN -> [SKIP][26] ([fdo#109271] / [i915#533])
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-glk-dsi/igt@[email protected]
- fi-icl-y: NOTRUN -> [SKIP][27] ([fdo#109278])
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-icl-y/igt@[email protected]
* igt@kms_psr@primary_mmap_gtt:
- fi-icl-y: NOTRUN -> [SKIP][28] ([fdo#110189]) +3 similar issues
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-icl-y/igt@kms_psr@primary_mmap_gtt.html
* igt@kms_psr@primary_page_flip:
- fi-glk-dsi: NOTRUN -> [SKIP][29] ([fdo#109271]) +27 similar issues
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-glk-dsi/igt@kms_psr@primary_page_flip.html
#### Possible fixes ####
* igt@gem_tiled_blits@basic:
- fi-kbl-8809g: [TIMEOUT][30] ([i915#2502] / [i915#3145]) -> [PASS][31]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9880/fi-kbl-8809g/igt@[email protected]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-kbl-8809g/igt@[email protected]
* igt@i915_selftest@live@execlists:
- fi-cfl-8109u: [DMESG-WARN][32] -> [PASS][33]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9880/fi-cfl-8109u/igt@i915_selftest@[email protected]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-cfl-8109u/igt@i915_selftest@[email protected]
* igt@i915_selftest@live@late_gt_pm:
- fi-cfl-8109u: [DMESG-WARN][34] ([i915#203]) -> [PASS][35] +2 similar issues
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9880/fi-cfl-8109u/igt@i915_selftest@live@late_gt_pm.html
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-cfl-8109u/igt@i915_selftest@live@late_gt_pm.html
* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-b:
- {fi-tgl-dsi}: [DMESG-WARN][36] ([i915#402]) -> [PASS][37]
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9880/fi-tgl-dsi/igt@[email protected]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/fi-tgl-dsi/igt@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109284]: https://bugs.freedesktop.org/show_bug.cgi?id=109284
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#109315]: https://bugs.freedesktop.org/show_bug.cgi?id=109315
[fdo#110189]: https://bugs.freedesktop.org/show_bug.cgi?id=110189
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#155]: https://gitlab.freedesktop.org/drm/intel/issues/155
[i915#1759]: https://gitlab.freedesktop.org/drm/intel/issues/1759
[i915#1982]: https://gitlab.freedesktop.org/drm/intel/issues/1982
[i915#203]: https://gitlab.freedesktop.org/drm/intel/issues/203
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#2291]: https://gitlab.freedesktop.org/drm/intel/issues/2291
[i915#2373]: https://gitlab.freedesktop.org/drm/intel/issues/2373
[i915#2502]: https://gitlab.freedesktop.org/drm/intel/issues/2502
[i915#2575]: https://gitlab.freedesktop.org/drm/intel/issues/2575
[i915#2782]: https://gitlab.freedesktop.org/drm/intel/issues/2782
[i915#2940]: https://gitlab.freedesktop.org/drm/intel/issues/2940
[i915#3012]: https://gitlab.freedesktop.org/drm/intel/issues/3012
[i915#3143]: https://gitlab.freedesktop.org/drm/intel/issues/3143
[i915#3145]: https://gitlab.freedesktop.org/drm/intel/issues/3145
[i915#402]: https://gitlab.freedesktop.org/drm/intel/issues/402
[i915#533]: https://gitlab.freedesktop.org/drm/intel/issues/533
[i915#541]: https://gitlab.freedesktop.org/drm/intel/issues/541
Participating hosts (42 -> 43)
------------------------------
Additional (4): fi-icl-y fi-rkl-11500t fi-glk-dsi fi-tgl-y
Missing (3): fi-ilk-m540 fi-bsw-cyan fi-bdw-samus
Build changes
-------------
* Linux: CI_DRM_9880 -> Patchwork_19830
CI-20190529: 20190529
CI_DRM_9880: ec7a4e63b83999b055ba61da41bdd0ce656485d4 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_6040: 69b578b6ab0a36750f0d23c223a3487fc88fb6a7 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_19830: e9066fbd700e41816399a5113039b13cd92970ce @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
e9066fbd700e drm/i915/dp: fix array overflow warning e77df84376b1 drm/i915: avoid stringop-overread warning on pri_latency f449f33af4a3 scsi: lpfc: fix gcc -Wstringop-overread warning ce0bcacc57ff atmel: avoid gcc -Wstringop-overflow warning a23dcecdfe93 ARM: sharpsl_param: work around -Wstringop-overread warning c20cb7a6e190 cgroup: fix -Wzero-length-bounds warnings 85a87603017e qnx: avoid -Wstringop-overread warning 5dbb709eb530 ath11: Wstringop-overread warning86478fbc483a security: commoncap: fix -Wstringop-overread warning 6128f7213e8c x86: tboot: avoid Wstringop-overread-warning 8b23b18b19c9 x86: compressed: avoid gcc-11 -Wstringop-overread warning
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19830/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 02/11] x86: tboot: avoid Wstringop-overread-warning
In reply to Arnd BergmannQuoted 75 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
gcc-11 warns about using string operations on pointers that are defined at compile time as offsets from a NULL pointer. Unfortunately that also happens on the result of
fix_to_virt(), which is a compile-time constant for a constantn input:
arch/x86/kernel/tboot.c: In function 'tboot_probe':arch/x86/kernel/tboot.c:70:13: error: '__builtin_memcmp_eq' specified bound 16 exceeds source size 0 [-Werror=stringop-overread]70 | if (memcmp(&tboot_uuid, &tboot->uuid, sizeof(tboot->uuid))) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~I hope this can get addressed in gcc-11 before the release.
As a workaround, split up the
tboot_probe()function in two halves to separate the pointer generation from the usage. This is a bit ugly, and hopefully gcc understands that the code is actually correct before it learns to peek into the noinline function.Signed-off-by Arnd Bergmann <[email protected]>--- arch/x86/kernel/tboot.c | 44 ++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 18 deletions(-)arch/x86/kernel/tboot.c +26
-8@@ -49,6 +49,30 @@ bool tboot_enabled(void)return tboot !=NULL ; } +/* noinline to prevent gcc from warning about dereferencing constant fixaddr */ +static noinline __init bool check_tboot_version(void) +{ +if (memcmp (&tboot_uuid, &tboot->uuid,sizeof (tboot->uuid))) { +pr_warn ("tboot at 0x%llx is invalid\n" , boot_params.tboot_addr); +return false; + } + +if (tboot->version <5 ) { +pr_warn ("tboot version is invalid: %u\n" , tboot->version); +return false; + } + +pr_info ("found shared page at phys addr 0x%llx:\n" , + boot_params.tboot_addr); +pr_debug ("version: %d\n" , tboot->version); +pr_debug ("log_addr: 0x%08x\n" , tboot->log_addr); +pr_debug ("shutdown_entry: 0x%x\n" , tboot->shutdown_entry); +pr_debug ("tboot_base: 0x%08x\n" , tboot->tboot_base); +pr_debug ("tboot_size: 0x%x\n" , tboot->tboot_size); + +return true; +} +void __init tboot_probe (void ) {/* Look for valid page-aligned address for shared page. */ @@ -66,25 +90,9 @@ void __init tboot_probe(void)/* Map and check for tboot UUID. */ set_fixmap (FIX_TBOOT_BASE , boot_params.tboot_addr); - tboot = (struct tboot *)fix_to_virt (FIX_TBOOT_BASE ); -if (memcmp (&tboot_uuid, &tboot->uuid,sizeof (tboot->uuid))) { -pr_warn ("tboot at 0x%llx is invalid\n" , boot_params.tboot_addr); + tboot = (void *)fix_to_virt (FIX_TBOOT_BASE ); +if (!check_tboot_version ()) tboot =NULL ; -return ; - } -if (tboot->version <5 ) { -pr_warn ("tboot version is invalid: %u\n" , tboot->version); - tboot =NULL ;
arch/x86/kernel/tboot.c void __init tboot_probe(void) · line 87
Quoted 10 lines
arch/x86/kernel/tboot.c +0
-10-return ; - } - -pr_info ("found shared page at phys addr 0x%llx:\n" , - boot_params.tboot_addr); -pr_debug ("version: %d\n" , tboot->version); -pr_debug ("log_addr: 0x%08x\n" , tboot->log_addr); -pr_debug ("shutdown_entry: 0x%x\n" , tboot->shutdown_entry); -pr_debug ("tboot_base: 0x%08x\n" , tboot->tboot_base); -pr_debug ("tboot_size: 0x%x\n" , tboot->tboot_size);
This is indeed rather ugly - and the other patch that removes a debug check seems counterproductive as well.
Do we know how many genuine bugs -Wstringop-overread-warning has caught or is about to catch?
I.e. the real workaround might be to turn off the -Wstringop-overread-warning, until GCC-11 gets fixed?
Thanks,
Ingo
Re: [PATCH 02/11] x86: tboot: avoid Wstringop-overread-warning
Quoted 11 lines · Ingo Molnar
Quoted 1 line · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
This is indeed rather ugly - and the other patch that removes a debug check seems counterproductive as well.
Do we know how many genuine bugs -Wstringop-overread-warning has caught or is about to catch?
I.e. the real workaround might be to turn off the -Wstringop-overread-warning, until GCC-11 gets fixed?
See the [PATCH 0/11] message. The last two patches in the series are for code that I suspect may be broken, the others are basically all false positives.
As gcc-11 is not released yet, I don't think we have to apply any of the patches or disable the warning at the moment, but I posted all the patches to get a better understanding on which of them should be addressed in the kernel vs gcc.
Arnd
Re: [PATCH 02/11] x86: tboot: avoid Wstringop-overread-warning
In reply to Ingo MolnarQuoted 92 lines · Ingo Molnar
Quoted 75 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
gcc-11 warns about using string operations on pointers that are defined at compile time as offsets from a NULL pointer. Unfortunately that also happens on the result of
fix_to_virt(), which is a compile-time constant for a constantn input:
arch/x86/kernel/tboot.c: In function 'tboot_probe':arch/x86/kernel/tboot.c:70:13: error: '__builtin_memcmp_eq' specified bound 16 exceeds source size 0 [-Werror=stringop-overread]70 | if (memcmp(&tboot_uuid, &tboot->uuid, sizeof(tboot->uuid))) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~I hope this can get addressed in gcc-11 before the release.
As a workaround, split up the
tboot_probe()function in two halves to separate the pointer generation from the usage. This is a bit ugly, and hopefully gcc understands that the code is actually correct before it learns to peek into the noinline function.Signed-off-by Arnd Bergmann <[email protected]>--- arch/x86/kernel/tboot.c | 44 ++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 18 deletions(-)arch/x86/kernel/tboot.c +26
-8@@ -49,6 +49,30 @@ bool tboot_enabled(void)return tboot !=NULL ; } +/* noinline to prevent gcc from warning about dereferencing constant fixaddr */ +static noinline __init bool check_tboot_version(void) +{ +if (memcmp (&tboot_uuid, &tboot->uuid,sizeof (tboot->uuid))) { +pr_warn ("tboot at 0x%llx is invalid\n" , boot_params.tboot_addr); +return false; + } + +if (tboot->version <5 ) { +pr_warn ("tboot version is invalid: %u\n" , tboot->version); +return false; + } + +pr_info ("found shared page at phys addr 0x%llx:\n" , + boot_params.tboot_addr); +pr_debug ("version: %d\n" , tboot->version); +pr_debug ("log_addr: 0x%08x\n" , tboot->log_addr); +pr_debug ("shutdown_entry: 0x%x\n" , tboot->shutdown_entry); +pr_debug ("tboot_base: 0x%08x\n" , tboot->tboot_base); +pr_debug ("tboot_size: 0x%x\n" , tboot->tboot_size); + +return true; +} +void __init tboot_probe (void ) {/* Look for valid page-aligned address for shared page. */ @@ -66,25 +90,9 @@ void __init tboot_probe(void)/* Map and check for tboot UUID. */ set_fixmap (FIX_TBOOT_BASE , boot_params.tboot_addr); - tboot = (struct tboot *)fix_to_virt (FIX_TBOOT_BASE ); -if (memcmp (&tboot_uuid, &tboot->uuid,sizeof (tboot->uuid))) { -pr_warn ("tboot at 0x%llx is invalid\n" , boot_params.tboot_addr); + tboot = (void *)fix_to_virt (FIX_TBOOT_BASE ); +if (!check_tboot_version ()) tboot =NULL ; -return ; - } -if (tboot->version <5 ) { -pr_warn ("tboot version is invalid: %u\n" , tboot->version); - tboot =NULL ;arch/x86/kernel/tboot.c void __init tboot_probe(void) · line 87
Quoted 10 lines
arch/x86/kernel/tboot.c +0
-10-return ; - } - -pr_info ("found shared page at phys addr 0x%llx:\n" , - boot_params.tboot_addr); -pr_debug ("version: %d\n" , tboot->version); -pr_debug ("log_addr: 0x%08x\n" , tboot->log_addr); -pr_debug ("shutdown_entry: 0x%x\n" , tboot->shutdown_entry); -pr_debug ("tboot_base: 0x%08x\n" , tboot->tboot_base); -pr_debug ("tboot_size: 0x%x\n" , tboot->tboot_size);This is indeed rather ugly - and the other patch that removes a debug check seems counterproductive as well.
Quoted 5 lines
Do we know how many genuine bugs -Wstringop-overread-warning has caught or is about to catch?
I.e. the real workaround might be to turn off the -Wstringop-overread-warning, until GCC-11 gets fixed?
In GCC 10 -Wstringop-overread is a subset of -Wstringop-overflow. GCC 11 breaks it out as a separate warning to make it easier to control. Both warnings have caught some real bugs but they both have a nonzero rate of false positives. Other than bug reports we don't have enough data to say what their S/N ratio might be but my sense is that it's fairly high in general.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=wstringop-overread
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=wstringop-overflow
In GCC 11, all access warnings expect objects to be either declared or allocated. Pointers with constant values are taken to point to nothing valid (as Arnd mentioned above, this is to detect invalid accesses to members of structs at address zero).
One possible solution to the known address problem is to extend GCC attributes address and io that pin an object to a hardwired address to all targets (at the moment they're supported on just one or two targets). I'm not sure this can still happen before GCC 11 releases sometime in April or May.
Until then, another workaround is to convert the fixed address to a volatile pointer before using it for the access, along the lines below. It should have only a negligible effect on efficiency.
arch/x86/kernel/tboot.c +3 -1
@@ -67,7 +67,9 @@ void __init tboot_probe(void)/* Map and check for tboot UUID. */ set_fixmap (FIX_TBOOT_BASE , boot_params.tboot_addr); tboot = (struct tboot *)fix_to_virt (FIX_TBOOT_BASE ); -if (memcmp (&tboot_uuid, &tboot->uuid,sizeof (tboot->uuid))) { +if (memcmp (&tboot_uuid, + (*(struct tboot *volatile *)(&tboot))->uuid, +sizeof (tboot->uuid))) { pr_warn("tboot at 0x%llx is invalid\n",
boot_params.tboot_addr);
tboot = NULL;
return;Martin
Quoted 5 lines
Thanks,
Ingo
Re: [PATCH 02/11] x86: tboot: avoid Wstringop-overread-warning
Quoted 13 lines · Martin Sebor
Quoted 4 lines · Ingo Molnar
* Arnd Bergmann <[email protected]> wrote:
I.e. the real workaround might be to turn off the -Wstringop-overread-warning, until GCC-11 gets fixed?
In GCC 10 -Wstringop-overread is a subset of -Wstringop-overflow. GCC 11 breaks it out as a separate warning to make it easier to control. Both warnings have caught some real bugs but they both have a nonzero rate of false positives. Other than bug reports we don't have enough data to say what their S/N ratio might be but my sense is that it's fairly high in general.
Quoted 2 lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=wstringop-overread
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=wstringop-overflow
Unfortunately, stringop-overflow is one of the warnings that is completely disabled in the kernel at the moment, rather than enabled at one of the user-selectable higher warning levels.
I have a patch series to change that and to pull some of these into the lower W=1 or W=2 levels or even enable them by default.
To do this though, I first need to ensure that the actual output is empty for the normal builds. I added -Wstringop-overflow to the list of warnings I wanted to address because it is a new warning and only has a dozen or so occurrences throughout the kernel.
Quoted 20 lines
In GCC 11, all access warnings expect objects to be either declared or allocated. Pointers with constant values are taken to point to nothing valid (as Arnd mentioned above, this is to detect invalid accesses to members of structs at address zero).
One possible solution to the known address problem is to extend GCC attributes address and io that pin an object to a hardwired address to all targets (at the moment they're supported on just one or two targets). I'm not sure this can still happen before GCC 11 releases sometime in April or May.
Until then, another workaround is to convert the fixed address to a volatile pointer before using it for the access, along the lines below. It should have only a negligible effect on efficiency.
arch/x86/kernel/tboot.c +0
-0
arch/x86/kernel/tboot.c void __init tboot_probe(void) · line 73
Quoted 8 lines
arch/x86/kernel/tboot.c +3
-1@@ -67,7 +67,9 @@ void __init tboot_probe(void)/* Map and check for tboot UUID. */ set_fixmap (FIX_TBOOT_BASE , boot_params.tboot_addr); tboot = (struct tboot *)fix_to_virt (FIX_TBOOT_BASE ); -if (memcmp (&tboot_uuid, &tboot->uuid,sizeof (tboot->uuid))) { +if (memcmp (&tboot_uuid, + (*(struct tboot *volatile *)(&tboot))->uuid, +sizeof (tboot->uuid))) { pr_warn("tboot at 0x%llx is invalid\n",
I think a stray 'volatile' would raise too many red flags here, but I checked that the RELOC_HIDE() macro has the same effect, e.g.
@@ -66,7 +67,8 @@ void __init tboot_probe(void)
/* Map and check for tboot UUID. */
set_fixmap(FIX_TBOOT_BASE, boot_params.tboot_addr);
- tboot = (struct tboot *)fix_to_virt(FIX_TBOOT_BASE);
+ /* RELOC_HIDE to prevent gcc warnings about NULL pointer */
+ tboot = RELOC_HIDE(NULL, fix_to_virt(FIX_TBOOT_BASE));
if (memcmp(&tboot_uuid, &tboot->uuid, sizeof(tboot->uuid))) {
pr_warn("tboot at 0x%llx is invalid\n", boot_params.tboot_addr);
tboot = NULL;
ArndRe: [PATCH 02/11] x86: tboot: avoid Wstringop-overread-warning
In reply to Martin SeborQuoted 24 lines · Martin Sebor
Quoted 2 lines
I.e. the real workaround might be to turn off the -Wstringop-overread-warning, until GCC-11 gets fixed?
In GCC 10 -Wstringop-overread is a subset of -Wstringop-overflow. GCC 11 breaks it out as a separate warning to make it easier to control. Both warnings have caught some real bugs but they both have a nonzero rate of false positives. Other than bug reports we don't have enough data to say what their S/N ratio might be but my sense is that it's fairly high in general.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=wstringop-overread
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=wstringop-overflowIn GCC 11, all access warnings expect objects to be either declared or allocated. Pointers with constant values are taken to point to nothing valid (as Arnd mentioned above, this is to detect invalid accesses to members of structs at address zero).
One possible solution to the known address problem is to extend GCC attributes address and io that pin an object to a hardwired address to all targets (at the moment they're supported on just one or two targets). I'm not sure this can still happen before GCC 11 releases sometime in April or May.
Quoted 3 lines
Until then, another workaround is to convert the fixed address to a volatile pointer before using it for the access, along the lines below. It should have only a negligible effect on efficiency.
Thank you for the detailed answer!
I think I'll go with Arnd's original patch - which makes the code a slightly bit cleaner by separating out the check_tboot_version() check into a standalone function.
The only ugly aspect is the global nature of the 'tboot' pointer - but that's a self-inflicted wound.
I'd also guess that the S/N ratio somewhat unfairly penalizes this warning right now, because the kernel had a decade of growing real fixes via other efforts such as static and dynamic instrumentation as well.
So the probability of false positive remaining is in fact higher, and going forward we should see a better S/N ratio of this warning. Most of which will never be seen by upstream maintainers, as the mishaps will stay at the individual developer level. :-)
Thanks,
Ingo
[tip: x86/boot] x86/boot/compressed: Avoid gcc-11 -Wstringop-overread warning
In reply to Arnd BergmannThe following commit has been merged into the x86/boot branch of tip:
The following commit has been merged into the x86/boot branch of tip:
Commit-ID: e14cfb3bdd0f82147d09e9f46bedda6302f28ee1 Gitweb: https://git.kernel.org/tip/e14cfb3bdd0f82147d09e9f46bedda6302f28ee1 Author: Arnd Bergmann <[email protected]> AuthorDate: Mon, 22 Mar 2021 17:02:39 +01:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 23 Mar 2021 00:16:25 +01:00
x86/boot/compressed: Avoid gcc-11 -Wstringop-overread warning
GCC gets confused by the comparison of a pointer to an integer literal, with the assumption that this is an offset from a NULL pointer and that dereferencing it is invalid:
In file included from arch/x86/boot/compressed/misc.c:18:
In function ‘parse_elf’,
inlined from ‘extract_kernel’ at arch/x86/boot/compressed/misc.c:442:2:
arch/x86/boot/compressed/../string.h:15:23: error: ‘__builtin_memcpy’ reading 64 bytes from a region of size 0 [-Werror=stringop-overread]
15 | #define memcpy(d,s,l) __builtin_memcpy(d,s,l)
| ^~~~~~~~~~~~~~~~~~~~~~~
arch/x86/boot/compressed/misc.c:283:9: note: in expansion of macro ‘memcpy’
283 | memcpy(&ehdr, output, sizeof(ehdr));
| ^~~~~~I could not find any good workaround for this, but as this is only a warning for a failure during early boot, removing the line entirely works around the warning.
--- arch/x86/boot/compressed/misc.c | 2 -- 1 file changed, 2 deletions(-)
arch/x86/boot/compressed/misc.c +0 -2
@@ -430,8 +430,6 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,error ("Destination address too large" );#endif #ifndef CONFIG_RELOCATABLE -if ((unsigned long )output !=LOAD_PHYSICAL_ADDR ) -error ("Destination address does not match LOAD_PHYSICAL_ADDR" );if (virt_addr !=LOAD_PHYSICAL_ADDR )error ("Destination virtual address changed when not relocatable" );#endif
[tip: x86/boot] x86/boot/tboot: Avoid Wstringop-overread-warning
In reply to Arnd BergmannThe following commit has been merged into the x86/boot branch of tip:
The following commit has been merged into the x86/boot branch of tip:
Commit-ID: cdc34cb8f25d3125d30868376b8eae6fe690119b Gitweb: https://git.kernel.org/tip/cdc34cb8f25d3125d30868376b8eae6fe690119b Author: Arnd Bergmann <[email protected]> AuthorDate: Mon, 22 Mar 2021 17:02:40 +01:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 23 Mar 2021 00:16:13 +01:00
x86/boot/tboot: Avoid Wstringop-overread-warning
gcc-11 warns about using string operations on pointers that are defined at compile time as offsets from a NULL pointer. Unfortunately that also happens on the result of fix_to_virt(), which is a compile-time constant for a constant input:
arch/x86/kernel/tboot.c: In function 'tboot_probe':
arch/x86/kernel/tboot.c:70:13: error: '__builtin_memcmp_eq' specified bound 16 exceeds source size 0 [-Werror=stringop-overread]
70 | if (memcmp(&tboot_uuid, &tboot->uuid, sizeof(tboot->uuid))) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~I hope this can get addressed in gcc-11 before the release.
As a workaround, split up the tboot_probe() function in two halves to separate the pointer generation from the usage. This is a bit ugly, and hopefully gcc understands that the code is actually correct before it learns to peek into the noinline function.
--- arch/x86/kernel/tboot.c | 44 +++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 18 deletions(-)
arch/x86/kernel/tboot.c +26 -18
@@ -49,6 +49,30 @@ bool tboot_enabled(void)return tboot !=NULL ; } +/* noinline to prevent gcc from warning about dereferencing constant fixaddr */ +static noinline __init bool check_tboot_version(void) +{ +if (memcmp (&tboot_uuid, &tboot->uuid,sizeof (tboot->uuid))) { +pr_warn ("tboot at 0x%llx is invalid\n" , boot_params.tboot_addr); +return false; + } + +if (tboot->version <5 ) { +pr_warn ("tboot version is invalid: %u\n" , tboot->version); +return false; + } + +pr_info ("found shared page at phys addr 0x%llx:\n" , + boot_params.tboot_addr); +pr_debug ("version: %d\n" , tboot->version); +pr_debug ("log_addr: 0x%08x\n" , tboot->log_addr); +pr_debug ("shutdown_entry: 0x%x\n" , tboot->shutdown_entry); +pr_debug ("tboot_base: 0x%08x\n" , tboot->tboot_base); +pr_debug ("tboot_size: 0x%x\n" , tboot->tboot_size); + +return true; +} +void __init tboot_probe (void ) {/* Look for valid page-aligned address for shared page. */
@@ -66,25 +90,9 @@ void __init tboot_probe(void)/* Map and check for tboot UUID. */ set_fixmap (FIX_TBOOT_BASE , boot_params.tboot_addr); - tboot = (struct tboot *)fix_to_virt (FIX_TBOOT_BASE ); -if (memcmp (&tboot_uuid, &tboot->uuid,sizeof (tboot->uuid))) { -pr_warn ("tboot at 0x%llx is invalid\n" , boot_params.tboot_addr); + tboot = (void *)fix_to_virt (FIX_TBOOT_BASE ); +if (!check_tboot_version ()) tboot =NULL ; -return ; - } -if (tboot->version <5 ) { -pr_warn ("tboot version is invalid: %u\n" , tboot->version); - tboot =NULL ; -return ; - } - -pr_info ("found shared page at phys addr 0x%llx:\n" , - boot_params.tboot_addr); -pr_debug ("version: %d\n" , tboot->version); -pr_debug ("log_addr: 0x%08x\n" , tboot->log_addr); -pr_debug ("shutdown_entry: 0x%x\n" , tboot->shutdown_entry); -pr_debug ("tboot_base: 0x%08x\n" , tboot->tboot_base); -pr_debug ("tboot_size: 0x%x\n" , tboot->tboot_size); }static pgd_t *tboot_pg_dir;
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BUILD: failure for treewide: address gcc-11 -Wstringop-overread warnings (rev2)
In reply to Arnd Bergmann== Series Details ==
== Series Details ==
Series: treewide: address gcc-11 -Wstringop-overread warnings (rev2)
URL : https://patchwork.freedesktop.org/series/88295/
State : failure
== Summary ==
Applying: x86: compressed: avoid gcc-11 -Wstringop-overread warning
Applying: x86: tboot: avoid Wstringop-overread-warning
error: corrupt patch at line 14
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0002 x86: tboot: avoid Wstringop-overread-warning When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RE: [PATCH 02/11] x86: tboot: avoid Wstringop-overread-warning
In reply to Martin SeborFrom: Martin Sebor
Quoted 1 line
Sent: 22 March 2021 22:08
...
Quoted 10 lines
In GCC 11, all access warnings expect objects to be either declared or allocated. Pointers with constant values are taken to point to nothing valid (as Arnd mentioned above, this is to detect invalid accesses to members of structs at address zero).
One possible solution to the known address problem is to extend GCC attributes address and io that pin an object to a hardwired address to all targets (at the moment they're supported on just one or two targets). I'm not sure this can still happen before GCC 11 releases sometime in April or May.
A different solution is to define a normal C external data item and then assign a fixed address with an asm statement or in the linker script.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
RE: [PATCH 02/11] x86: tboot: avoid Wstringop-overread-warning
From: David Laight
Quoted 16 lines
Sent: 24 March 2021 09:12
From: Martin Sebor
Quoted 1 line
Sent: 22 March 2021 22:08
...
Quoted 10 lines
In GCC 11, all access warnings expect objects to be either declared or allocated. Pointers with constant values are taken to point to nothing valid (as Arnd mentioned above, this is to detect invalid accesses to members of structs at address zero).
One possible solution to the known address problem is to extend GCC attributes address and io that pin an object to a hardwired address to all targets (at the moment they're supported on just one or two targets). I'm not sure this can still happen before GCC 11 releases sometime in April or May.
Quoted 3 lines
A different solution is to define a normal C external data item and then assign a fixed address with an asm statement or in the linker script.
Or stop gcc tracking the value by using:
struct foo *foo = (void *)xxxxx;
asm ("", "+r" (foo));If the address is used more than once forcing it into a register is also likely to generate better code.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Re: [PATCH 10/11] drm/i915: avoid stringop-overread warning on pri_latency
In reply to Arnd BergmannQuoted 13 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
gcc-11 warns about what appears to be an out-of-range array access:
In function ‘snb_wm_latency_quirk’,
inlined from ‘ilk_setup_wm_latency’ atdrivers/gpu/drm/i915/intel_pm.c:3108:3:drivers/gpu/drm/i915/intel_pm.c:3057:9: error: ‘intel_print_wm_latency’ reading 16 bytes from a region of size 10 [-Werror=stringop-overread]3057 | intel_print_wm_latency(dev_priv, "Primary", dev_priv->wm.pri_latency); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/i915/intel_pm.c: In function ‘ilk_setup_wm_latency’:drivers/gpu/drm/i915/intel_pm.c:3057:9: note: referencing argument 3 of type ‘const u16 *’ {aka ‘const short unsigned int *’}drivers/gpu/drm/i915/intel_pm.c:2994:13: note: in a call to function ‘intel_print_wm_latency’
2994 | static void intel_print_wm_latency(structdrm_i915_private*dev_priv,
Quoted 7 lines
| ^~~~~~~~~~~~~~~~~~~~~~My guess is that this code is actually safe because the size of the array depends on the hardware generation, and the function checks for that, but at the same time I would not expect the compiler to work it out correctly, and the code seems a little fragile with regards to future changes. Simply increasing the size of the array should help.
Agreed, I don't think there's an issue, but the code could use a bunch of improvements.
Like, we have intel_print_wm_latency() for debug logging and wm_latency_show() for debugfs, and there's a bunch of duplication and ugh.
But this seems like the easiest fix for the warning.
Quoted 24 lines
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/i915_drv.h +3
-3@@ -1095,11 +1095,11 @@ struct drm_i915_private {* in 0.5us units for WM1+. */ /* primary */ -u16 pri_latency[5 ]; +u16 pri_latency[8 ];/* sprite */ -u16 spr_latency[5 ]; +u16 spr_latency[8 ];/* cursor */ -u16 cur_latency[5 ]; +u16 cur_latency[8 ];/* * Raw watermark memory latency values * for SKL for all 8 levels
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 10/11] drm/i915: avoid stringop-overread warning on pri_latency
Quoted 22 lines · Jani Nikula
Quoted 13 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
gcc-11 warns about what appears to be an out-of-range array access:
In function ‘snb_wm_latency_quirk’,
inlined from ‘ilk_setup_wm_latency’ atdrivers/gpu/drm/i915/intel_pm.c:3108:3:drivers/gpu/drm/i915/intel_pm.c:3057:9: error: ‘intel_print_wm_latency’ reading 16 bytes from a region of size 10 [-Werror=stringop-overread]3057 | intel_print_wm_latency(dev_priv, "Primary", dev_priv->wm.pri_latency); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/i915/intel_pm.c: In function ‘ilk_setup_wm_latency’:drivers/gpu/drm/i915/intel_pm.c:3057:9: note: referencing argument 3 of type ‘const u16 *’ {aka ‘const short unsigned int *’}drivers/gpu/drm/i915/intel_pm.c:2994:13: note: in a call to function ‘intel_print_wm_latency’
2994 | static void intel_print_wm_latency(structdrm_i915_private*dev_priv,Quoted 7 lines
| ^~~~~~~~~~~~~~~~~~~~~~My guess is that this code is actually safe because the size of the array depends on the hardware generation, and the function checks for that, but at the same time I would not expect the compiler to work it out correctly, and the code seems a little fragile with regards to future changes. Simply increasing the size of the array should help.
Quoted 6 lines
Agreed, I don't think there's an issue, but the code could use a bunch of improvements.
Like, we have
intel_print_wm_latency()for debug logging andwm_latency_show()for debugfs, and there's a bunch of duplication and ugh.
There is all this ancient stuff in review limbo...
https://patchwork.freedesktop.org/series/50802/
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
James Morris
maintainerRe: [PATCH 03/11] security: commoncap: fix -Wstringop-overread warning
In reply to Arnd BergmannQuoted 9 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
gcc-11 introdces a harmless warning for
cap_inode_getsecurity:
security/commoncap.c: In function ‘cap_inode_getsecurity’:security/commoncap.c:440:33: error: ‘memcpy’ reading 16 bytes from a region of size 0 [-Werror=stringop-overread]440 | memcpy(&nscap->data, &cap->data, sizeof(__le32) * 2 * VFS_CAP_U32); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 8 lines
The problem here is that tmpbuf is initialized to NULL, so gcc assumes it is not accessible unless it gets set by
vfs_getxattr_alloc(). This is a legitimate warning as far as I can tell, but the code is correct since it correctly handles the error when that function fails.Add a separate NULL check to tell gcc about it as well.
Signed-off-by Arnd Bergmann <[email protected]>
Applied togit://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git fixes-v5.12
Signature · 2 lines
James Morris <jmorris-gx6/[email protected]>
Jani Nikula
maintainerRe: [PATCH 11/11] [RFC] drm/i915/dp: fix array overflow warning
In reply to Arnd BergmannQuoted 14 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
gcc-11 warns that
intel_dp_check_mst_status()has a local array of fourteen bytes and passes the last four bytes into a function that expects a six-byte array:
drivers/gpu/drm/i915/display/intel_dp.c: In function ‘intel_dp_check_mst_status’:drivers/gpu/drm/i915/display/intel_dp.c:4556:22: error: ‘drm_dp_channel_eq_ok’ reading 6 bytes from a region of size 4 [-Werror=stringop-overread]4556 | !drm_dp_channel_eq_ok(&esi[10], intel_dp->lane_count)) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/i915/display/intel_dp.c:4556:22: note: referencing argument 1 of type ‘const u8 *’ {aka ‘const unsigned char *’} In file included fromdrivers/gpu/drm/i915/display/intel_dp.c:38:include/drm/drm_dp_helper.h:1459:6: note: in a call to function ‘drm_dp_channel_eq_ok’
1459 | bool drm_dp_channel_eq_ok(const u8 link_status[DP_LINK_STATUS_SIZE],
Quoted 5 lines
| ^~~~~~~~~~~~~~~~~~~~Clearly something is wrong here, but I can't quite figure out what. Changing the array size to 16 bytes avoids the warning, but is probably the wrong solution here.
Ugh. drm_dp_channel_eq_ok() does not actually require more than DP_LINK_STATUS_SIZE - 2 elements in the link_status. It's some other related functions that do, and in most cases it's convenient to read all those DP_LINK_STATUS_SIZE bytes.
However, here the case is slightly different for DP MST, and the change causes reserved DPCD addresses to be read. Not sure it matters, but really I think the problem is what drm_dp_channel_eq_ok() advertizes.
I also don't like the array notation with sizes in function parameters in general, because I think it's misleading. Would gcc-11 warn if a function actually accesses the memory out of bounds of the size?
Anyway. I don't think we're going to get rid of the array notation anytime soon, if ever, no matter how much I dislike it, so I think the right fix would be to at least state the correct required size in drm_dp_channel_eq_ok().
BR,
Jani.
Quoted 19 lines
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/gpu/drm/i915/display/intel_dp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/i915/display/intel_dp.c +1
-1@@ -65,7 +65,7 @@#include "intel_vdsc.h" #include "intel_vrr.h" -#define DP_DPRX_ESI_LEN 14 +#define DP_DPRX_ESI_LEN 16/* DP DSC throughput values used for slice count calculations KPixels/s */ #define DP_DSC_PEAK_PIXEL_RATE 2720000
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 11/11] [RFC] drm/i915/dp: fix array overflow warning
Quoted 9 lines · Jani Nikula
Quoted 3 lines
Clearly something is wrong here, but I can't quite figure out what. Changing the array size to 16 bytes avoids the warning, but is probably the wrong solution here.
Ugh.
drm_dp_channel_eq_ok()does not actually require more thanDP_LINK_STATUS_SIZE- 2 elements in thelink_status. It's some other related functions that do, and in most cases it's convenient to read all thoseDP_LINK_STATUS_SIZEbytes.
Quoted 7 lines
However, here the case is slightly different for DP MST, and the change causes reserved DPCD addresses to be read. Not sure it matters, but really I think the problem is what
drm_dp_channel_eq_ok()advertizes.I also don't like the array notation with sizes in function parameters in general, because I think it's misleading. Would gcc-11 warn if a function actually accesses the memory out of bounds of the size?
Yes, that is the point of the warning. Using an explicit length in an array argument type tells gcc that the function will never access beyond the end of that bound, and that passing a short array is a bug.
I don't know if this /only/ means triggering a warning, or if gcc is also able to make optimizations after classifying this as undefined behavior that it would not make for an unspecified length.
Quoted 4 lines
Anyway. I don't think we're going to get rid of the array notation anytime soon, if ever, no matter how much I dislike it, so I think the right fix would be to at least state the correct required size in
drm_dp_channel_eq_ok().
Ok. Just to confirm: Changing the declaration to an unspecified length avoids the warnings, as does the patch below:
drivers/gpu/drm/drm_dp_helper.c +2 -2
@@ -46,12 +46,12 @@*/ /* Helpers for DP link training */ -static u8 dp_link_status (const u8 link_status[DP_LINK_STATUS_SIZE ],int r) +static u8 dp_link_status (const u8 link_status[DP_LINK_STATUS_SIZE -2 ],int r) {return link_status[r -DP_LANE0_1_STATUS ]; } -static u8 dp_get_lane_status (const u8 link_status[DP_LINK_STATUS_SIZE ], +static u8 dp_get_lane_status (const u8 link_status[DP_LINK_STATUS_SIZE -2 ],int lane) {int i =DP_LANE0_1_STATUS + (lane >>1 );
@@ -61,7 +61,7 @@ static u8 dp_get_lane_status(const u8
link_status[DP_LINK_STATUS_SIZE],
return (l >> s) & 0xf;
}
-bool drm_dp_channel_eq_ok(const u8 link_status[DP_LINK_STATUS_SIZE], +bool drm_dp_channel_eq_ok(const u8 link_status[DP_LINK_STATUS_SIZE - 2],
int lane_count)
{
u8 lane_align;include/drm/drm_dp_helper.h +1 -1
@@ -1456,7 +1456,7 @@ enum drm_dp_phy {#define DP_LINK_CONSTANT_N_VALUE 0x8000#define DP_LINK_STATUS_SIZE 6 -bool drm_dp_channel_eq_ok (const u8 link_status[DP_LINK_STATUS_SIZE ], +bool drm_dp_channel_eq_ok (const u8 link_status[DP_LINK_STATUS_SIZE -2 ],int lane_count);bool drm_dp_clock_recovery_ok (const u8 link_status[DP_LINK_STATUS_SIZE ],int lane_count);
This obviously needs a good explanation in the code and the changelog text, which I don't have, but if the above is what you had in mind, please take that and add Reported-by/Tested-by: Arnd Bergmann <[email protected]>.
Arnd
Re: [PATCH 11/11] [RFC] drm/i915/dp: fix array overflow warning
Quoted 18 lines · Arnd Bergmann
Quoted 9 lines · Jani Nikula
Quoted 3 lines
Clearly something is wrong here, but I can't quite figure out what. Changing the array size to 16 bytes avoids the warning, but is probably the wrong solution here.
Ugh.
drm_dp_channel_eq_ok()does not actually require more thanDP_LINK_STATUS_SIZE- 2 elements in thelink_status. It's some other related functions that do, and in most cases it's convenient to read all thoseDP_LINK_STATUS_SIZEbytes.Quoted 7 lines
However, here the case is slightly different for DP MST, and the change causes reserved DPCD addresses to be read. Not sure it matters, but really I think the problem is what
drm_dp_channel_eq_ok()advertizes.I also don't like the array notation with sizes in function parameters in general, because I think it's misleading. Would gcc-11 warn if a function actually accesses the memory out of bounds of the size?
Quoted 8 lines
Yes, that is the point of the warning. Using an explicit length in an array argument type tells gcc that the function will never access beyond the end of that bound, and that passing a short array is a bug.
I don't know if this /only/ means triggering a warning, or if gcc is also able to make optimizations after classifying this as undefined behavior that it would not make for an unspecified length.
GCC uses the array parameter notation as a hint for warnings but it doesn't optimize on this basis and never will be able to because code that accesses more elements from the array isn't invalid. Adding static to the bound, as in void f (int[static N]) does imply that the function won't access more than N elements and C intends for optimizers to rely on it, although GCC doesn't yet.
The warning for the array notation is a more portable alternative to explicitly annotating functions with attribute access, and to -Wvla-parameter for VLA parameters. The latter seem to be used relatively rarely, sometimes deliberately because of the bad rap of VLA objects, even though VLA parameters don't suffer from the same problems.
Martin
Quoted 59 lines
Quoted 5 lines
Anyway. I don't think we're going to get rid of the array notation anytime soon, if ever, no matter how much I dislike it, so I think the right fix would be to at least state the correct required size in
drm_dp_channel_eq_ok().Ok. Just to confirm: Changing the declaration to an unspecified length avoids the warnings, as does the patch below:
drivers/gpu/drm/drm_dp_helper.c +3
-3@@ -46,12 +46,12 @@*/ /* Helpers for DP link training */ -static u8 dp_link_status (const u8 link_status[DP_LINK_STATUS_SIZE ],int r) +static u8 dp_link_status (const u8 link_status[DP_LINK_STATUS_SIZE -2 ],int r) {return link_status[r -DP_LANE0_1_STATUS ]; } -static u8 dp_get_lane_status (const u8 link_status[DP_LINK_STATUS_SIZE ], +static u8 dp_get_lane_status (const u8 link_status[DP_LINK_STATUS_SIZE -2 ],int lane) {int i =DP_LANE0_1_STATUS + (lane >>1 );@@ -61,7 +61,7 @@ static u8 dp_get_lane_status(const u8 link_status[DP_LINK_STATUS_SIZE ], return (l >> s) & 0xf; } -bool drm_dp_channel_eq_ok (const u8 link_status[DP_LINK_STATUS_SIZE ], +bool drm_dp_channel_eq_ok (const u8 link_status[DP_LINK_STATUS_SIZE -2 ],int lane_count) {u8 lane_align;include/drm/drm_dp_helper.h +1
-1@@ -1456,7 +1456,7 @@ enum drm_dp_phy {#define DP_LINK_CONSTANT_N_VALUE 0x8000#define DP_LINK_STATUS_SIZE 6 -bool drm_dp_channel_eq_ok (const u8 link_status[DP_LINK_STATUS_SIZE ], +bool drm_dp_channel_eq_ok (const u8 link_status[DP_LINK_STATUS_SIZE -2 ],int lane_count);bool drm_dp_clock_recovery_ok (const u8 link_status[DP_LINK_STATUS_SIZE ],int lane_count);This obviously needs a good explanation in the code and the changelog text, which I don't have, but if the above is what you had in mind, please take that and add Reported-by/Tested-by: Arnd Bergmann <[email protected]>.
Arnd
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BUILD: failure for treewide: address gcc-11 -Wstringop-overread warnings (rev3)
In reply to Arnd Bergmann== Series Details ==
== Series Details ==
Series: treewide: address gcc-11 -Wstringop-overread warnings (rev3)
URL : https://patchwork.freedesktop.org/series/88295/
State : failure
== Summary ==
Applying: x86: compressed: avoid gcc-11 -Wstringop-overread warning
Applying: x86: tboot: avoid Wstringop-overread-warning
error: corrupt patch at line 14
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0002 x86: tboot: avoid Wstringop-overread-warning When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 06/11] cgroup: fix -Wzero-length-bounds warnings
In reply to Arnd BergmannQuoted 2 lines · Arnd Bergmann
I'm not sure what is expected to happen for such a configuration, presumably these functions are never calls in that case.
Yes, the functions you patched would only be called from subsystems or there should be no way to obtain a struct cgroup_subsys reference anyway (hence it's ok to always branch as if ss==NULL).
I'd prefer a variant that wouldn't compile the affected codepaths when there are no subsystems registered, however, I couldn't come up with a way how to do it without some preprocessor ugliness.
Re: [PATCH 06/11] cgroup: fix -Wzero-length-bounds warnings
Quoted 11 lines · Michal Koutný
Quoted 2 lines · Arnd Bergmann
I'm not sure what is expected to happen for such a configuration, presumably these functions are never calls in that case.
Yes, the functions you patched would only be called from subsystems or there should be no way to obtain a struct
cgroup_subsysreference anyway (hence it's ok to always branch as if ss==NULL).I'd prefer a variant that wouldn't compile the affected codepaths when there are no subsystems registered, however, I couldn't come up with a way how to do it without some preprocessor ugliness.
Would it be possible to enclose most or all of kernel/cgroup/cgroup.c in an #ifdef CGROUP_SUBSYS_COUNT block? I didn't try that myself, but this might be a way to guarantee that there cannot be any callers (it would cause a link error).
Quoted 1 line
Reviewed-by Michal Koutný <mkoutny-IBi9RG/[email protected]>
Thanks
Arnd
Re: [PATCH 11/11] [RFC] drm/i915/dp: fix array overflow warning
In reply to Arnd BergmannHi,
Quoted 14 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
gcc-11 warns that
intel_dp_check_mst_status()has a local array of fourteen bytes and passes the last four bytes into a function that expects a six-byte array:
drivers/gpu/drm/i915/display/intel_dp.c: In function ‘intel_dp_check_mst_status’:drivers/gpu/drm/i915/display/intel_dp.c:4556:22: error: ‘drm_dp_channel_eq_ok’ reading 6 bytes from a region of size 4 [-Werror=stringop-overread]4556 | !drm_dp_channel_eq_ok(&esi[10], intel_dp->lane_count)) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/i915/display/intel_dp.c:4556:22: note: referencing argument 1 of type ‘const u8 *’ {aka ‘const unsigned char *’} In file included fromdrivers/gpu/drm/i915/display/intel_dp.c:38:include/drm/drm_dp_helper.h:1459:6: note: in a call to function ‘drm_dp_channel_eq_ok’
1459 | bool drm_dp_channel_eq_ok(const u8 link_status[DP_LINK_STATUS_SIZE],
Quoted 5 lines
| ^~~~~~~~~~~~~~~~~~~~Clearly something is wrong here, but I can't quite figure out what. Changing the array size to 16 bytes avoids the warning, but is probably the wrong solution here.
The drm displayport-helpers indeed expect a 6 bytes buffer, but they usually only consume 4 bytes.
I don't think that changing the DP_DPRX_ESI_LEN is a good fix here, since it is used in multiple places, but the esi array already gets zero-ed out by its initializer, so we can just pass 2 extra 0 bytes to give drm_dp_channel_eq_ok() call the 6 byte buffer its prototype specifies by doing this:
drivers/gpu/drm/i915/display/intel_dp.c +5 -1
@@ -4538,7 +4538,11 @@ intel_dp_check_mst_status(struct intel_dp *intel_dp)drm_WARN_ON_ONCE (&i915->drm, intel_dp->active_mst_links <0 );for (;;) { -u8 esi[DP_DPRX_ESI_LEN ] = {}; +/* +* drm_dp_channel_eq_ok() expects a 6 byte large buffer, but +* the ESI info only contains 4 bytes, pass 2 extra 0 bytes. +*/ +u8 esi[DP_DPRX_ESI_LEN +2 ] = {};bool handled;int retry;
So i915 devs, would such a fix be acceptable ?
Regards,
Hans
Quoted 12 lines
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/gpu/drm/i915/display/intel_dp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/i915/display/intel_dp.c +0
-0
drivers/gpu/drm/i915/display/intel_dp.c line 71
Quoted 8 lines
drivers/gpu/drm/i915/display/intel_dp.c +1
-1@@ -65,7 +65,7 @@#include "intel_vdsc.h" #include "intel_vrr.h" -#define DP_DPRX_ESI_LEN 14 +#define DP_DPRX_ESI_LEN 16/* DP DSC throughput values used for slice count calculations KPixels/s */ #define DP_DSC_PEAK_PIXEL_RATE 2720000
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BUILD: failure for treewide: address gcc-11 -Wstringop-overread warnings (rev4)
In reply to Arnd Bergmann== Series Details ==
== Series Details ==
Series: treewide: address gcc-11 -Wstringop-overread warnings (rev4)
URL : https://patchwork.freedesktop.org/series/88295/
State : failure
== Summary ==
Applying: x86: compressed: avoid gcc-11 -Wstringop-overread warning
Applying: x86: tboot: avoid Wstringop-overread-warning
error: corrupt patch at line 14
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0002 x86: tboot: avoid Wstringop-overread-warning When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Michal Koutný
maintainerRe: [PATCH 06/11] cgroup: fix -Wzero-length-bounds warnings
In reply to Arnd BergmannQuoted 2 lines · Arnd Bergmann
Would it be possible to enclose most or all of
kernel/cgroup/cgroup.cin an #ifdefCGROUP_SUBSYS_COUNTblock?
Even without any controllers, there can still be named hierarchies (v1) or the default hierarchy (v2) (for instance) for process tracking purposes. So only parts of kernel/cgroup/cgroup.c could be ifdef'd.
Beware that CGROUP_SUBSYS_COUNT is not known at preprocessing stage (you could have a macro alternative though).
Quoted 2 lines
I didn't try that myself, but this might be a way to guarantee that there cannot be any callers (it would cause a link error).
Such a guarantee would be nicer, I agree. I tried a bit but anandoned it when I saw macros proliferate (which I found less readable than your current variant). But YMMV.
Michal
Martin K. Petersen
AppliedQuoted 10 lines · Arnd Bergmann
The coming gcc release introduces a new warning for string operations reading beyond the end of a fixed-length object. After testing randconfig kernels for a while, think I have patches for any such warnings that came up on x86, arm and arm64.
Most of these warnings are false-positive ones, either gcc warning about something that is entirely correct, or about something that looks suspicious but turns out to be correct after all.
[...]
Applied to 5.13/scsi-queue, thanks!
[09/11] scsi: lpfc: fix gcc -Wstringop-overread warning
https://git.kernel.org/mkp/scsi/c/ada48ba70f6b
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Re: [PATCH 04/11] ath11: Wstringop-overread warning
In reply to Arnd BergmannQuoted 20 lines · Arnd Bergmann
gcc-11 with the kernel address sanitizer prints a warning for this driver:
In function '
ath11k_peer_assoc_h_vht',inlined from 'ath11k_peer_assoc_prepare' at drivers/net/wireless/ath/ath11k/mac.c:1632:2: drivers/net/wireless/ath/ath11k/mac.c:1164:13: error: 'ath11k_peer_assoc_h_vht_masked' reading 16 bytes from a region of size 4 [-Werror=stringop-overread] 1164 | if (ath11k_peer_assoc_h_vht_masked(vht_mcs_mask)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/ath/ath11k/mac.c: In function 'ath11k_peer_assoc_prepare':drivers/net/wireless/ath/ath11k/mac.c:1164:13: note: referencing argument 1 of type 'const u16 *' {aka 'const short unsigned int *'}drivers/net/wireless/ath/ath11k/mac.c:969:1: note: in a call to function 'ath11k_peer_assoc_h_vht_masked'
969 |ath11k_peer_assoc_h_vht_masked(const u16 vht_mcs_mask[NL80211_VHT_NSS_MAX])| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~According to analysis from gcc developers, this is a glitch in the way gcc tracks the size of struct members. This should really get fixed in gcc, but it's also easy to work around this instance by changing the function prototype to no include the length of the array.
Quoted 3 lines
Signed-off-by Arnd Bergmann <[email protected]>Signed-off-by Kalle Valo <[email protected]>
Patch applied to ath-next branch of ath.git, thanks.
eb19efed836a ath11k: Wstringop-overread warning
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Re: [PATCH 04/11] ath11: Wstringop-overread warning
In reply to Arnd BergmannQuoted 20 lines · Arnd Bergmann
gcc-11 with the kernel address sanitizer prints a warning for this driver:
In function '
ath11k_peer_assoc_h_vht',inlined from 'ath11k_peer_assoc_prepare' at drivers/net/wireless/ath/ath11k/mac.c:1632:2: drivers/net/wireless/ath/ath11k/mac.c:1164:13: error: 'ath11k_peer_assoc_h_vht_masked' reading 16 bytes from a region of size 4 [-Werror=stringop-overread] 1164 | if (ath11k_peer_assoc_h_vht_masked(vht_mcs_mask)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/ath/ath11k/mac.c: In function 'ath11k_peer_assoc_prepare':drivers/net/wireless/ath/ath11k/mac.c:1164:13: note: referencing argument 1 of type 'const u16 *' {aka 'const short unsigned int *'}drivers/net/wireless/ath/ath11k/mac.c:969:1: note: in a call to function 'ath11k_peer_assoc_h_vht_masked'
969 |ath11k_peer_assoc_h_vht_masked(const u16 vht_mcs_mask[NL80211_VHT_NSS_MAX])| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~According to analysis from gcc developers, this is a glitch in the way gcc tracks the size of struct members. This should really get fixed in gcc, but it's also easy to work around this instance by changing the function prototype to no include the length of the array.
Quoted 3 lines
Signed-off-by Arnd Bergmann <[email protected]>Signed-off-by Kalle Valo <[email protected]>
Patch applied to ath-next branch of ath.git, thanks.
eb19efed836a ath11k: Wstringop-overread warning
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Re: [PATCH 04/11] ath11: Wstringop-overread warning
In reply to Arnd BergmannQuoted 20 lines · Arnd Bergmann
gcc-11 with the kernel address sanitizer prints a warning for this driver:
In function '
ath11k_peer_assoc_h_vht',inlined from 'ath11k_peer_assoc_prepare' at drivers/net/wireless/ath/ath11k/mac.c:1632:2: drivers/net/wireless/ath/ath11k/mac.c:1164:13: error: 'ath11k_peer_assoc_h_vht_masked' reading 16 bytes from a region of size 4 [-Werror=stringop-overread] 1164 | if (ath11k_peer_assoc_h_vht_masked(vht_mcs_mask)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/ath/ath11k/mac.c: In function 'ath11k_peer_assoc_prepare':drivers/net/wireless/ath/ath11k/mac.c:1164:13: note: referencing argument 1 of type 'const u16 *' {aka 'const short unsigned int *'}drivers/net/wireless/ath/ath11k/mac.c:969:1: note: in a call to function 'ath11k_peer_assoc_h_vht_masked'
969 |ath11k_peer_assoc_h_vht_masked(const u16 vht_mcs_mask[NL80211_VHT_NSS_MAX])| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~According to analysis from gcc developers, this is a glitch in the way gcc tracks the size of struct members. This should really get fixed in gcc, but it's also easy to work around this instance by changing the function prototype to no include the length of the array.
Quoted 3 lines
Signed-off-by Arnd Bergmann <[email protected]>Signed-off-by Kalle Valo <[email protected]>
Patch applied to ath-next branch of ath.git, thanks.
eb19efed836a ath11k: Wstringop-overread warning
Signature · 9 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches -- ath11k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath11k