Skip to contentSkip to conversation

ionic: return -EFAULT if copy_to_user() fails

PATCH Applied Dan Carpenter 3 participants 3 messages Apr 13, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ionic: return -EFAULT if copy_to_user() fails

The copy_to_user() function returns the number of bytes that it wasn't able to copy. We want to return -EFAULT to the user.

Fixes fee6efce565d ("ionic: add hw timestamp support files")
---
 drivers/net/ethernet/pensando/ionic/ionic_phc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/pensando/ionic/ionic_phc.c +3 -1
index 86ae5011ac9b..d7d8d5e81ea0 100644
@@ -225,7 +225,9 @@ int ionic_lif_hwstamp_get(struct ionic_lif *lif, struct ifreq *ifr)
 	memcpy(&config, &lif->phc->ts_config, sizeof(config));
 	mutex_unlock(&lif->phc->config_lock);
 
-	return copy_to_user(ifr->ifr_data, &config, sizeof(config));
+	if (copy_to_user(ifr->ifr_data, &config, sizeof(config)))
+		return -EFAULT;
+	return 0;
 }
 
 static u64 ionic_hwstamp_read(struct ionic *ionic,
Signature · 1 line
2.30.2
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Dan Carpenter

The copy_to_user() function returns the number of bytes that it wasn't able to copy. We want to return -EFAULT to the user.

Fixes fee6efce565d ("ionic: add hw timestamp support files")
Quoted 19 lines
---
  drivers/net/ethernet/pensando/ionic/ionic_phc.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/pensando/ionic/ionic_phc.c +3 -1
index 86ae5011ac9b..d7d8d5e81ea0 100644
@@ -225,7 +225,9 @@ int ionic_lif_hwstamp_get(struct ionic_lif *lif, struct ifreq *ifr)
  	memcpy(&config, &lif->phc->ts_config, sizeof(config));
  	mutex_unlock(&lif->phc->config_lock);
 
-	return copy_to_user(ifr->ifr_data, &config, sizeof(config));
+	if (copy_to_user(ifr->ifr_data, &config, sizeof(config)))
+		return -EFAULT;
+	return 0;
  }
 
  static u64 ionic_hwstamp_read(struct ionic *ionic,
#2 lore raw
In reply to Dan Carpenter
This patch was applied to netdev/net-next.git (refs/heads/master):

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

Quoted 8 lines · On Tue, 13 Apr 2021 13:47:59 +0300 you wrote:

The copy_to_user() function returns the number of bytes that it wasn't able to copy. We want to return -EFAULT to the user.

Fixes fee6efce565d ("ionic: add hw timestamp support files")
---
 drivers/net/ethernet/pensando/ionic/ionic_phc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Here is the summary with links:
- [net-next] ionic: return -EFAULT if copy_to_user() fails

    https://git.kernel.org/netdev/net-next/c/5871d0c6b8ea

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html