public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Young Xiao <92siuyang@gmail.com>
To: davem@davemloft.net, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Young Xiao <92siuyang@gmail.com>
Subject: [PATCH] net: compat: fix msg_controllen overflow in scm_detach_fds_compat()
Date: Tue,  4 Jun 2019 20:31:45 +0800	[thread overview]
Message-ID: <1559651505-18137-1-git-send-email-92siuyang@gmail.com> (raw)

There is a missing check between kmsg->msg_controllen and cmlen,
which can possibly lead to overflow.

This bug is similar to vulnerability that was fixed in commit 6900317f5eff
("net, scm: fix PaX detected msg_controllen overflow in scm_detach_fds").

Signed-off-by: Young Xiao <92siuyang@gmail.com>
---
 net/compat.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/compat.c b/net/compat.c
index a031bd3..8e74dfb 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -301,6 +301,8 @@ void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
 			err = put_user(cmlen, &cm->cmsg_len);
 		if (!err) {
 			cmlen = CMSG_COMPAT_SPACE(i * sizeof(int));
+			if (kmsg->msg_controllen < cmlen)
+				cmlen = kmsg->msg_controllen;
 			kmsg->msg_control += cmlen;
 			kmsg->msg_controllen -= cmlen;
 		}
-- 
2.7.4


             reply	other threads:[~2019-06-04 12:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-04 12:31 Young Xiao [this message]
2019-06-04 12:46 ` [PATCH] net: compat: fix msg_controllen overflow in scm_detach_fds_compat() Daniel Borkmann
2019-06-04 12:54   ` Yang Xiao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1559651505-18137-1-git-send-email-92siuyang@gmail.com \
    --to=92siuyang@gmail.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox