Subject: [powerpc] memcpy warning drivers/scsi/scsi_transport_fc.c:581 (next-20220921)

From: Sachin Sant <[email-masked]>
Date: Wed, 21 Sep 2022 21:21:52 +0530

While booting recent linux-next kernel on a Power server following
warning is seen:

[    6.427054] lpfc 0022:01:00.0: 0:6468 Set host date / time: Status x10:
[    6.471457] lpfc 0022:01:00.0: 0:6448 Dual Dump is enabled
[    7.432161] ------------[ cut here ]------------
[    7.432178] memcpy: detected field-spanning write (size 8) of single field "&event->event_data" at drivers/scsi/scsi_transport_fc.c:581 (size 4)
[    7.432201] WARNING: CPU: 0 PID: 16 at drivers/scsi/scsi_transport_fc.c:581 fc_host_post_fc_event+0x214/0x300 [scsi_transport_fc]
[    7.432228] Modules linked in: sr_mod(E) cdrom(E) sd_mod(E) sg(E) lpfc(E+) nvmet_fc(E) ibmvscsi(E) nvmet(E) scsi_transport_srp(E) ibmveth(E) nvme_fc(E) nvme(E) nvme_fabrics(E) nvme_core(E) t10_pi(E) scsi_transport_fc(E) crc64_rocksoft(E) crc64(E) tg3(E) ipmi_devintf(E) ipmi_msghandler(E) fuse(E)
[    7.432263] CPU: 0 PID: 16 Comm: kworker/0:1 Tainted: G            E      6.0.0-rc6-next-20220921 #38
[    7.432270] Workqueue: events work_for_cpu_fn
[    7.432277] NIP:  c008000001366a2c LR: c008000001366a28 CTR: 00000000007088ec
[    7.432282] REGS: c00000000380b6d0 TRAP: 0700   Tainted: G            E       (6.0.0-rc6-next-20220921)
[    7.432288] MSR:  800000000282b033 <SF,VEC,VSX,EE,FP,ME,IR,DR,RI,LE>  CR: 48002824  XER: 00000005
[    7.432304] CFAR: c0000000001555b4 IRQMASK: 0 
               GPR00: c008000001366a28 c00000000380b970 c008000001388300 0000000000000084 
               GPR04: 00000000ffff7fff c00000000380b730 c00000000380b728 0000000000000027 
               GPR08: c000000db7007f98 0000000000000001 0000000000000027 c000000002947378 
               GPR12: 0000000000002000 c000000002dc0000 c00000000018e3d8 c000000003045740 
               GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 
               GPR20: 0000000000000000 0000000000000030 01000000000010df c00000000380ba90 
               GPR24: 0000000000000001 c0000000030ea000 000000000000ffff c000000002da2a08 
               GPR28: 0000000000000040 c000000073f52400 0000000000000008 c0000000940b9834 
[    7.432365] NIP [c008000001366a2c] fc_host_post_fc_event+0x214/0x300 [scsi_transport_fc]
[    7.432374] LR [c008000001366a28] fc_host_post_fc_event+0x210/0x300 [scsi_transport_fc]
[    7.432383] Call Trace:
[    7.432385] [c00000000380b970] [c008000001366a28] fc_host_post_fc_event+0x210/0x300 [scsi_transport_fc] (unreliable)
[    7.432396] [c00000000380ba30] [c008000001c23028] lpfc_post_init_setup+0xc0/0x1f0 [lpfc]
[    7.432429] [c00000000380bab0] [c008000001c24e00] lpfc_pci_probe_one_s4.isra.59+0x428/0xa10 [lpfc]
[    7.432455] [c00000000380bb40] [c008000001c255a4] lpfc_pci_probe_one+0x1bc/0xb70 [lpfc]
[    7.432480] [c00000000380bbe0] [c0000000007fdc7c] local_pci_probe+0x6c/0x110
[    7.432489] [c00000000380bc60] [c00000000017bdf8] work_for_cpu_fn+0x38/0x60
[    7.432494] [c00000000380bc90] [c0000000001812d4] process_one_work+0x2b4/0x5b0
[    7.432501] [c00000000380bd30] [c000000000181820] worker_thread+0x250/0x600
[    7.432508] [c00000000380bdc0] [c00000000018e4f4] kthread+0x124/0x130
[    7.432514] [c00000000380be10] [c00000000000cdf4] ret_from_kernel_thread+0x5c/0x64
[    7.432521] Instruction dump:
[    7.432524] 2f890000 409eff5c 3ca20000 e8a58170 3c620000 e8638178 39200001 38c00004 
[    7.432535] 7fc4f378 992a0000 4800414d e8410018 <0fe00000> 7fa3eb78 38800001 480044d1 
[    7.432546] ---[ end trace 0000000000000000 ]---
[    7.471075] lpfc 0022:01:00.0: 0:3176 Port Name 0 Physical Link is functional
[    7.471405] lpfc 0022:01:00.1: enabling device (0144 -> 0146)

The warning was added by the following patch
commit 54d9469bc515dc5fcbc20eecbe19cea868b70d68
    fortify: Add run-time WARN for cross-field memcpy()

Should this be fixed in the driver or is this a false warning?

Thanks
- Sachin