Commit 6d4bc344 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Martin K. Petersen

scsi: bfa: try to sanitize vendor netlink events

bfa_aen_entry_s is passed to user space in a netlink message, but is
defined using a 'struct timeval' and an 'enum' that are not only
different between architectures, but also between 32-bit user space and
64-bit kernels they may run on, as well as depending on the particular C
library that defines timeval.

This changes the in-kernel definition to no longer use the timeval type
directly but instead use two open-coded 'unsigned long' members.  This
keeps the existing ABI, but making the variable unsigned also helps make
it work after y2038, until it overflows in 2106.

Since the macro becomes overly complex at this point, I'm changing it to
an inline function for readability.

I'm not changing the 32-bit user-space ABI at this point, to keep the
changes separate, I deally this would be defined using the same binary
layout for all architectures.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarAnil Gurumurthy <Anil.Gurumurthy@cavium.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 0e9680fa
...@@ -1455,7 +1455,8 @@ struct bfa_aen_entry_s { ...@@ -1455,7 +1455,8 @@ struct bfa_aen_entry_s {
enum bfa_aen_category aen_category; enum bfa_aen_category aen_category;
u32 aen_type; u32 aen_type;
union bfa_aen_data_u aen_data; union bfa_aen_data_u aen_data;
struct timeval aen_tv; unsigned long aen_tv_sec;
unsigned long aen_tv_usec;
u32 seq_num; u32 seq_num;
u32 bfad_num; u32 bfad_num;
}; };
......
...@@ -131,16 +131,28 @@ struct bfad_im_s { ...@@ -131,16 +131,28 @@ struct bfad_im_s {
} while (0) } while (0)
/* post fc_host vendor event */ /* post fc_host vendor event */
#define bfad_im_post_vendor_event(_entry, _drv, _cnt, _cat, _evt) do { \ static inline void bfad_im_post_vendor_event(struct bfa_aen_entry_s *entry,
do_gettimeofday(&(_entry)->aen_tv); \ struct bfad_s *drv, int cnt,
(_entry)->bfad_num = (_drv)->inst_no; \ enum bfa_aen_category cat,
(_entry)->seq_num = (_cnt); \ enum bfa_ioc_aen_event evt)
(_entry)->aen_category = (_cat); \ {
(_entry)->aen_type = (_evt); \ struct timespec64 ts;
if ((_drv)->bfad_flags & BFAD_FC4_PROBE_DONE) \
queue_work((_drv)->im->drv_workq, \ ktime_get_real_ts64(&ts);
&(_drv)->im->aen_im_notify_work); \ /*
} while (0) * 'unsigned long aen_tv_sec' overflows in y2106 on 32-bit
* architectures, or in 2038 if user space interprets it
* as 'signed'.
*/
entry->aen_tv_sec = ts.tv_sec;
entry->aen_tv_usec = ts.tv_nsec / NSEC_PER_USEC;
entry->bfad_num = drv->inst_no;
entry->seq_num = cnt;
entry->aen_category = cat;
entry->aen_type = evt;
if (drv->bfad_flags & BFAD_FC4_PROBE_DONE)
queue_work(drv->im->drv_workq, &drv->im->aen_im_notify_work);
}
struct Scsi_Host *bfad_scsi_host_alloc(struct bfad_im_port_s *im_port, struct Scsi_Host *bfad_scsi_host_alloc(struct bfad_im_port_s *im_port,
struct bfad_s *); struct bfad_s *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment