From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from userp2120.oracle.com ([156.151.31.85]:57338 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231492AbhCJKBb (ORCPT ); Wed, 10 Mar 2021 05:01:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=3hIbAOIIYkWPVyYUNSB6QicuWFCi9clw9fdBmM/IN3M=; b=MPpGgAlZA1h1yR0Ne3suBBQidIp6VCCqMsu4hnBTZIjdpoZvXJ+MSUhJS4iD/1F8QJ98 EtLcw2VjQGrdomtMH2QTOwWhOhvcMtBtBExTlPGcsFsd15zbqEoMYuUgSUIqkFtBUYQX W+f6LGNLMxCf3zwKBHjYxhN0Q6mteZ+IcpYf8b5L+QVG6JejLyck+I8v48hMdM6MrmJr VJwjL9efpAx0yAfnYhVVq0bk0UR5aQbma+vA6pWhmxIm8tmd+cbaxgQuk5BFSMI+3YSl 1eftNe9KGPAfsZvSeU7u1fo6FIGLfGrCq6Tyl+bdzjQ/wIEPxgRD/dvT/PdbNimVuqkb vA== Date: Wed, 10 Mar 2021 13:01:07 +0300 From: Dan Carpenter Subject: Re: smatch and copy_{to,from}_user return values Message-ID: <20210310100107.GI21246@kadam> References: <20210303112046.GB2222@kadam> <20210305101434.GI2222@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210305101434.GI2222@kadam> List-ID: To: Rasmus Villemoes Cc: linux-s390@vger.kernel.org, smatch@vger.kernel.org This turned out way more complicated than I expected... It's working now. Probably I will should filter out the function which return true/false instead of negative error codes. I was surprised it generated so few warnings, which suggests that maybe there is a problem. No real false positives though (one place had multiple errors so I guess the EIO trumped the EFAULT). I'm not sure if it's worth sending emails about these... But I've added a new --pedantic option for reviewing new code so this would definitely qualify for that. regards, dan carpenter kernel/trace/trace_uprobe.c:122 get_user_stack_nth() warn: return -EFAULT instead of '0' arch/x86/kernel/uprobes.c:1070 arch_uretprobe_hijack_return_addr() warn: return -EFAULT instead of '(-1)' arch/x86/kernel/fpu/signal.c:33 check_for_xstate() warn: return -EFAULT instead of '(-1)' arch/x86/kvm/cpuid.c:955 sanity_check_entries() warn: return -EFAULT instead of '1' fs/coda/pioctl.c:62 coda_pioctl() warn: return -EFAULT instead of '-EINVAL' ipc/msgutil.c:157 store_msg() warn: return -EFAULT instead of '(-1)' ipc/msgutil.c:164 store_msg() warn: return -EFAULT instead of '(-1)' drivers/staging/rtl8712/rtl871x_ioctl_linux.c:1966 r871x_get_ap_info() warn: return -EFAULT instead of '-EINVAL' drivers/staging/rtl8712/rtl871x_ioctl_linux.c:2005 r871x_get_ap_info() warn: return -EFAULT instead of '-EINVAL' drivers/staging/rtl8712/rtl871x_ioctl_linux.c:2020 r871x_set_pid() warn: return -EFAULT instead of '-EINVAL' drivers/char/xillybus/xillybus_core.c:1340 xillybus_write() warn: return -EFAULT instead of '-EIO' drivers/usb/mon/mon_bin.c:282 copy_from_buf() warn: return -EFAULT instead of '-EINVAL' drivers/misc/bcm-vk/bcm_vk_dev.c:956 bcm_vk_load_image() warn: return -EFAULT instead of '-EACCES' drivers/misc/sgi-gru/grukdump.c:30 gru_user_copy_handle() warn: return -EFAULT instead of '(-1)' drivers/gpu/drm/amd/amdgpu/amdgpu_fw_attestation.c:108 amdgpu_fw_attestation_debugfs_read() warn: return -EFAULT instead of '-EINVAL' drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:126 amdgpu_ras_debugfs_read() warn: return -EFAULT instead of '-EINVAL' drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:173 amdgpu_ras_debugfs_ctrl_parse_data() warn: return -EFAULT instead of '-EINVAL' drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:215 amdgpu_ras_debugfs_ctrl_parse_data() warn: return -EFAULT instead of '-EINVAL' drivers/scsi/lpfc/lpfc_debugfs.c:2427 lpfc_debugfs_dif_err_write() warn: return -EFAULT instead of '0' drivers/scsi/hisi_sas/hisi_sas_v3_hw.c:3764 debugfs_bist_linkrate_v3_hw_write() warn: return -EFAULT instead of '-EINVAL' drivers/scsi/hisi_sas/hisi_sas_v3_hw.c:3854 debugfs_bist_code_mode_v3_hw_write() warn: return -EFAULT instead of '-EOVERFLOW' drivers/scsi/hisi_sas/hisi_sas_v3_hw.c:3983 debugfs_bist_mode_v3_hw_write() warn: return -EFAULT instead of '-EOVERFLOW' drivers/crypto/qat/qat_common/adf_ctl_drv.c:100 adf_ctl_alloc_resources() warn: return -EFAULT instead of '-EIO' drivers/media/pci/ttpci/av7110_hw.c:889 LoadBitmap() warn: return -EFAULT instead of '-EINVAL' drivers/media/pci/ddbridge/ddbridge-core.c:631 ddb_output_write() warn: return -EFAULT instead of '-EIO' security/tomoyo/common.c:225 tomoyo_flush() warn: return -EFAULT instead of '0'