Skip to contentSkip to conversation

net/scm: Fix typo in SCM_RIGHTS compat refactoring

PATCH In review Kees Cook 3 participants 3 messages Aug 7, 2020 Networking

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 net/scm: Fix typo in SCM_RIGHTS compat refactoring

When refactoring the SCM_RIGHTS code, I accidentally mis-merged my native/compat diffs, which entirely broke using SCM_RIGHTS in compat mode. Use the correct helper.

---
 net/compat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/compat.c +1 -1
index 703acb51c698..95ce707a30a3 100644
@@ -294,7 +294,7 @@ void scm_detach_fds_compat(struct msghdr *msg, struct scm_cookie *scm)
 		(struct compat_cmsghdr __user *)msg->msg_control;
 	unsigned int o_flags = (msg->msg_flags & MSG_CMSG_CLOEXEC) ? O_CLOEXEC : 0;
 	int fdmax = min_t(int, scm_max_fds_compat(msg), scm->fp->count);
-	int __user *cmsg_data = CMSG_USER_DATA(cm);
+	int __user *cmsg_data = CMSG_COMPAT_DATA(cm);
 	int err = 0, i;
 
 	for (i = 0; i < fdmax; i++) {
Signature · 5 lines
2.25.1


-- 
Kees Cook
#1 lore raw
Quoted 11 lines · Kees Cook

When refactoring the SCM_RIGHTS code, I accidentally mis-merged my native/compat diffs, which entirely broke using SCM_RIGHTS in compat mode. Use the correct helper.

Hi, Kees.

You might want to add the Teste-by line that Alex Xu sent. And if my ack adds any value on top of Suggested-by, here it goes:

Thanks.
Cascardo.

Quoted 23 lines
---
 net/compat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/compat.c +1 -1
index 703acb51c698..95ce707a30a3 100644
@@ -294,7 +294,7 @@ void scm_detach_fds_compat(struct msghdr *msg, struct scm_cookie *scm)
 		(struct compat_cmsghdr __user *)msg->msg_control;
 	unsigned int o_flags = (msg->msg_flags & MSG_CMSG_CLOEXEC) ? O_CLOEXEC : 0;
 	int fdmax = min_t(int, scm_max_fds_compat(msg), scm->fp->count);
-	int __user *cmsg_data = CMSG_USER_DATA(cm);
+	int __user *cmsg_data = CMSG_COMPAT_DATA(cm);
 	int err = 0, i;
 
 	for (i = 0; i < fdmax; i++) {
Signature · 5 lines
2.25.1


-- 
Kees Cook
Acked-by on v1 1/1
#2 lore raw
In reply to Kees Cook
Quoted 4 lines · Kees Cook

When refactoring the SCM_RIGHTS code, I accidentally mis-merged my native/compat diffs, which entirely broke using SCM_RIGHTS in compat mode. Use the correct helper.

Quoted 8 lines

---

Oh fun,

Thanks for fixing this quickly, Kees! I already built stuff on top of the notifier fd injection work we did this cycle so it's great that we don't have to revert this!

Quoted 22 lines
 net/compat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/compat.c +1 -1
index 703acb51c698..95ce707a30a3 100644
@@ -294,7 +294,7 @@ void scm_detach_fds_compat(struct msghdr *msg, struct scm_cookie *scm)
 		(struct compat_cmsghdr __user *)msg->msg_control;
 	unsigned int o_flags = (msg->msg_flags & MSG_CMSG_CLOEXEC) ? O_CLOEXEC : 0;
 	int fdmax = min_t(int, scm_max_fds_compat(msg), scm->fp->count);
-	int __user *cmsg_data = CMSG_USER_DATA(cm);
+	int __user *cmsg_data = CMSG_COMPAT_DATA(cm);
 	int err = 0, i;
 
 	for (i = 0; i < fdmax; i++) {
Signature · 5 lines
2.25.1


-- 
Kees Cook