Skip to contentSkip to conversation

KVM: s390: return -EFAULT if copy_from_user() fails

PATCH In review Dan Carpenter 2 participants 2 messages May 3, 2014 – May 5, 2014

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

PATCH 1/1 KVM: s390: return -EFAULT if copy_from_user() fails

When copy_from_user() fails, this code returns the number of bytes remaining instead of a negative error code. The positive number is returned to the user but otherwise it is harmless.

---
I am not able to compile this.

arch/s390/kvm/guestdbg.c +3 -2
index 757ccef..3e8d409 100644
@@ -223,9 +223,10 @@ int kvm_s390_import_bp_data(struct kvm_vcpu *vcpu,
 		goto error;
 	}
 
-	ret = copy_from_user(bp_data, dbg->arch.hw_bp, size);
-	if (ret)
+	if (copy_from_user(bp_data, dbg->arch.hw_bp, size)) {
+		ret = -EFAULT;
 		goto error;
+	}
 
 	for (i = 0; i < dbg->arch.nr_hw_bp; i++) {
 		switch (bp_data[i].type) {
#1 lore raw
Quoted 5 lines · Dan Carpenter

When copy_from_user() fails, this code returns the number of bytes remaining instead of a negative error code. The positive number is returned to the user but otherwise it is harmless.

Thanks. Applied to KVM/s390 fix queue.

Quoted 25 lines

---
I am not able to compile this.

arch/s390/kvm/guestdbg.c +3 -3
index 757ccef..3e8d409 100644
@@ -223,9 +223,10 @@ int kvm_s390_import_bp_data(struct kvm_vcpu *vcpu,
 		goto error;
 	}
 
-	ret = copy_from_user(bp_data, dbg->arch.hw_bp, size);
-	if (ret)
+	if (copy_from_user(bp_data, dbg->arch.hw_bp, size)) {
+		ret = -EFAULT;
 		goto error;
+	}
 
 	for (i = 0; i < dbg->arch.nr_hw_bp; i++) {
 		switch (bp_data[i].type) {
--

To unsubscribe from this list: send the line "unsubscribe linux-s390" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html