FreeBSD Bugzilla – Attachment 200243 Details for
Bug 234104
sysutils/intel-nvmupdate 6.80 causes immediate reboot
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to ixl(4)'s nvmupdate ioctl handling
nvmupd.diff (text/plain), 2.65 KB, created by
Eric Joyner
on 2018-12-18 22:34:27 UTC
(
hide
)
Description:
Patch to ixl(4)'s nvmupdate ioctl handling
Filename:
MIME Type:
Creator:
Eric Joyner
Created:
2018-12-18 22:34:27 UTC
Size:
2.65 KB
patch
obsolete
>diff --git a/sys/dev/ixl/ixl_pf_main.c b/sys/dev/ixl/ixl_pf_main.c >index f775947fdc4c..e30dcf415a5d 100644 >--- a/sys/dev/ixl/ixl_pf_main.c >+++ b/sys/dev/ixl/ixl_pf_main.c >@@ -3663,12 +3663,21 @@ ixl_handle_nvmupd_cmd(struct ixl_pf *pf, struct ifdrv *ifd) > struct i40e_nvm_access *nvma; > device_t dev = pf->dev; > enum i40e_status_code status = 0; >+ u32 max_data_len; >+ int error = 0; > int perrno; > > DEBUGFUNC("ixl_handle_nvmupd_cmd"); > >- /* Sanity checks */ >+ /* >+ * The maximum length of the ioctl data is the size of the struct i40e_nvm_access >+ * and the max of 4096 bytes in the data field contained in that struct. >+ */ >+ max_data_len = (sizeof(struct i40e_nvm_access) - 1) + 4096; >+ >+ /* Sanity checks on ifdrv struct fields */ > if (ifd->ifd_len < sizeof(struct i40e_nvm_access) || >+ ifd->ifd_len > max_data_len || > ifd->ifd_data == NULL) { > device_printf(dev, "%s: incorrect ifdrv length or data pointer\n", > __func__); >@@ -3679,7 +3688,21 @@ ixl_handle_nvmupd_cmd(struct ixl_pf *pf, struct ifdrv *ifd) > return (EINVAL); > } > >- nvma = (struct i40e_nvm_access *)ifd->ifd_data; >+ /* Copy in ioctl data to kernel space */ >+ nvma = malloc(max_data_len, M_IXL, M_NOWAIT); >+ if (nvma == NULL) { >+ device_printf(dev, "%s: failed to allocate kernel buffer for ioctl data\n", >+ __func__); >+ return (ENOMEM); >+ } >+ >+ error = copyin(ifd->ifd_data, nvma, max_data_len); >+ if (error != 0) { >+ device_printf(dev, "%s: failed to copyin ioctl data\n", >+ __func__); >+ free(nvma, M_IXL); >+ return (error); >+ } > > if (pf->dbg_mask & IXL_DBG_NVMUPD) > ixl_print_nvm_cmd(dev, nvma); >@@ -3693,20 +3716,29 @@ ixl_handle_nvmupd_cmd(struct ixl_pf *pf, struct ifdrv *ifd) > } > } > >- if (!(pf->state & IXL_PF_STATE_ADAPTER_RESETTING)) { >- // TODO: Might need a different lock here >- // IXL_PF_LOCK(pf); >+ if (!(pf->state & IXL_PF_STATE_ADAPTER_RESETTING)) > status = i40e_nvmupd_command(hw, nvma, nvma->data, &perrno); >- // IXL_PF_UNLOCK(pf); >- } else { >+ else > perrno = -EBUSY; >- } > > /* Let the nvmupdate report errors, show them only when debug is enabled */ > if (status != 0 && (pf->dbg_mask & IXL_DBG_NVMUPD) != 0) > device_printf(dev, "i40e_nvmupd_command status %s, perrno %d\n", > i40e_stat_str(hw, status), perrno); > >+ /* Copy out ioctl data to user space */ >+ if (perrno == 0) { >+ error = copyout(nvma, ifd->ifd_data, max_data_len); >+ if (error != 0) { >+ device_printf(dev, "%s: failed to copyout ioctl data\n", >+ __func__); >+ free(nvma, M_IXL); >+ return (error); >+ } >+ } >+ >+ free(nvma, M_IXL); >+ > /* > * -EPERM is actually ERESTART, which the kernel interprets as it needing > * to run this ioctl again. So use -EACCES for -EPERM instead.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 234104
: 200243