NFSv4: nfs4_proc_set_acl needs to restore NFS_CAP_UIDGID_NOMAP on error.
Subsystems (4)
Sasha Levin
maintainerPATCH 1/5 NFSv4: nfs4_proc_set_acl needs to restore NFS_CAP_UIDGID_NOMAP on error.
From: Dai Ngo <[email protected]>
[ Upstream commit f8849e206ef52b584cd9227255f4724f0cc900bb ]
Currently if __nfs4_proc_set_acl fails with NFS4ERR_BADOWNER it re-enables the idmapper by clearing NFS_CAP_UIDGID_NOMAP before retrying again. The NFS_CAP_UIDGID_NOMAP remains cleared even if the retry fails. This causes problem for subsequent setattr requests for v4 server that does not have idmapping configured.
This patch modifies nfs4_proc_set_acl to detect NFS4ERR_BADOWNER and NFS4ERR_BADNAME and skips the retry, since the kernel isn't involved in encoding the ACEs, and return -EINVAL.
Steps to reproduce the problem:
# mount -o vers=4.1,sec=sys server:/export/test /tmp/mnt # touch /tmp/mnt/file1 # chown 99 /tmp/mnt/file1 # nfs4_setfacl -a A::[email protected]:wrtncy /tmp/mnt/file1 Failed setxattr operation: Invalid argument # chown 99 /tmp/mnt/file1 chown: changing ownership of ‘/tmp/mnt/file1’: Invalid argument # umount /tmp/mnt # mount -o vers=4.1,sec=sys server:/export/test /tmp/mnt # chown 99 /tmp/mnt/file1 #
v2: detect NFS4ERR_BADOWNER and NFS4ERR_BADNAME and skip retry
in nfs4_proc_set_acl.
--- fs/nfs/nfs4proc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/nfs/nfs4proc.c +8 -0
@@ -5183,6 +5183,14 @@ static int nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t buflendo { err =__nfs4_proc_set_acl (inode, buf, buflen);trace_nfs4_set_acl (inode, err); +if (err == -NFS4ERR_BADOWNER || err == -NFS4ERR_BADNAME ) { +/* +* no need to retry since the kernel +* isn't involved in encoding the ACEs. +*/ + err = -EINVAL ; +break ; + } err =nfs4_handle_exception (NFS_SERVER (inode), err, &exception); }while (exception.retry);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 2/5 scsi: core: Fix error handling of scsi_host_alloc()
From: Ming Lei <[email protected]>
[ Upstream commit 66a834d092930cf41d809c0e989b13cd6f9ca006 ]
After device is initialized via device_initialize(), or its name is set via dev_set_name(), the device has to be freed via put_device(). Otherwise device name will be leaked because it is allocated dynamically in dev_set_name().
Fix the leak by replacing kfree() with put_device(). Since scsi_host_dev_release() properly handles IDA and kthread removal, remove special-casing these from the error handling as well.
--- drivers/scsi/hosts.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/scsi/hosts.c +13 -10
@@ -421,8 +421,10 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)mutex_init (&shost->scan_mutex); index =ida_simple_get (&host_index_ida,0 ,0 ,GFP_KERNEL ); -if (index <0 ) - goto fail_kfree; +if (index <0 ) { +kfree (shost); +return NULL ; + } shost->host_no = index; shost->dma_channel =0xff ;
@@ -509,7 +511,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)shost_printk (KERN_WARNING , shost,"error handler thread failed to spawn, error = %ld\n" ,PTR_ERR (shost->ehandler)); - goto fail_index_remove; + goto fail; } shost->tmf_work_q = alloc_workqueue("scsi_tmf_%d",
@@ -518,17 +520,18 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)if (!shost->tmf_work_q) {shost_printk (KERN_WARNING , shost,"failed to create tmf workq\n" ); - goto fail_kthread; + goto fail; }scsi_proc_hostdir_add (shost->hostt);return shost; + fail: +/* +* Host state is still SHOST_CREATED and that is enough to release +* ->shost_gendev. scsi_host_dev_release() will free +* dev_name(&shost->shost_dev). +*/ +put_device (&shost->shost_gendev); - fail_kthread: -kthread_stop (shost->ehandler); - fail_index_remove: -ida_simple_remove (&host_index_ida, shost->host_no); - fail_kfree: -kfree (shost);return NULL ; }EXPORT_SYMBOL (scsi_host_alloc);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 3/5 scsi: core: Put .shost_dev in failure path if host state changes to RUNNING
In reply to Sasha LevinFrom: Ming Lei <[email protected]>
[ Upstream commit 11714026c02d613c30a149c3f4c4a15047744529 ]
scsi_host_dev_release() only frees dev_name when host state is SHOST_CREATED. After host state has changed to SHOST_RUNNING, scsi_host_dev_release() no longer cleans up.
Fix this by doing a put_device(&shost->shost_dev) in the failure path when host state is SHOST_RUNNING. Move get_device(&shost->shost_gendev) before device_add(&shost->shost_dev) so that scsi_host_cls_release() can do a put on this reference.
--- drivers/scsi/hosts.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/scsi/hosts.c +6 -2
@@ -265,12 +265,11 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev,device_enable_async_suspend (&shost->shost_dev); +get_device (&shost->shost_gendev); error =device_add (&shost->shost_dev);if (error) goto out_del_gendev; -get_device (&shost->shost_gendev); -if (shost->transportt->host_size) { shost->shost_data =kzalloc (shost->transportt->host_size,GFP_KERNEL );
@@ -307,6 +306,11 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, out_del_dev:device_del (&shost->shost_dev); out_del_gendev: +/* +* Host state is SHOST_RUNNING so we have to explicitly release +* ->shost_dev. +*/ +put_device (&shost->shost_dev);device_del (&shost->shost_gendev); out_destroy_freelist:device_disable_async_suspend (&shost->shost_gendev);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 4/5 scsi: core: Only put parent device if host state differs from SHOST_CREATED
In reply to Sasha LevinFrom: Ming Lei <[email protected]>
[ Upstream commit 1e0d4e6225996f05271de1ebcb1a7c9381af0b27 ]
get_device(shost->shost_gendev.parent) is called after host state has switched to SHOST_RUNNING. scsi_host_dev_release() shouldn't release the parent device if host state is still SHOST_CREATED.
--- drivers/scsi/hosts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/hosts.c +1 -1
@@ -372,7 +372,7 @@ static void scsi_host_dev_release(struct device *dev)ida_simple_remove (&host_index_ida, shost->host_no); -if (parent) +if (shost->shost_state !=SHOST_CREATED )put_device (parent);kfree (shost); }
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 5/5 radeon: use memcpy_to/fromio for UVD fw upload
In reply to Sasha LevinFrom: Chen Li <[email protected]>
[ Upstream commit ab8363d3875a83f4901eb1cc00ce8afd24de6c85 ]
I met a gpu addr bug recently and the kernel log tells me the pc is memcpy/memset and link register is radeon_uvd_resume.
As we know, in some architectures, optimized memcpy/memset may not work well on device memory. Trival memcpy_toio/memset_io can fix this problem.
BTW, amdgpu has already done it in:
commit ba0b2275a678 ("drm/amdgpu: use memcpy_to/fromio for UVD fw upload"), that's why it has no this issue on the same gpu and platform.
--- drivers/gpu/drm/radeon/radeon_uvd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_uvd.c +2 -2
@@ -286,7 +286,7 @@ int radeon_uvd_resume(struct radeon_device *rdev)if (rdev->uvd.vcpu_bo ==NULL )return -EINVAL ; -memcpy (rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); +memcpy_toio ((void __iomem *)rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); size =radeon_bo_size (rdev->uvd.vcpu_bo); size -= rdev->uvd_fw->size;
@@ -294,7 +294,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) ptr = rdev->uvd.cpu_addr; ptr += rdev->uvd_fw->size; -memset (ptr,0 , size); +memset_io ((void __iomem *)ptr,0 , size);return 0 ; }
Signature · 6 lines
2.30.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx