linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drbd: Fix kernel_sendmsg() usage
@ 2016-11-08 10:43 Richard Weinberger
  2016-11-08 13:55 ` Richard Weinberger
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Richard Weinberger @ 2016-11-08 10:43 UTC (permalink / raw)
  To: drbd-dev
  Cc: linux-kernel, lars.ellenberg, philipp.reisner, Richard Weinberger,
	stable, viro, christoph.lechleitner, wolfgang.glas

Don't pass a size larger than iov_len to kernel_sendmsg().
Otherwise it will cause a NULL pointer deref when kernel_sendmsg()
returns with rv < size.

Although the issue exists since day 0, only on non-ancient kernels
that contain change 57be5bdad759 ("ip: convert tcp_sendmsg() to iov_iter
primitives") it seems to trigger [0][1][2][3][4].

[0] http://lists.linbit.com/pipermail/drbd-user/2016-July/023112.html
[1] http://lists.linbit.com/pipermail/drbd-dev/2016-March/003362.html
[2] https://forums.grsecurity.net/viewtopic.php?f=3&t=4546
[3] https://ubuntuforums.org/showthread.php?t=2336150
[4] http://e2.howsolveproblem.com/i/1175162/

Fixes: b411b3637fa71fc ("The DRBD driver")
Cc: stable@vger.kernel.org
Cc: viro@zeniv.linux.org.uk
Cc: christoph.lechleitner@iteg.at
Cc: wolfgang.glas@iteg.at
Reported-by: Christoph Lechleitner <christoph.lechleitner@iteg.at>
Tested-by: Christoph Lechleitner <christoph.lechleitner@iteg.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
---
 drivers/block/drbd/drbd_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 100be556e613..cbec781c2b57 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -1871,7 +1871,7 @@ int drbd_send(struct drbd_connection *connection, struct socket *sock,
 		drbd_update_congested(connection);
 	}
 	do {
-		rv = kernel_sendmsg(sock, &msg, &iov, 1, size);
+		rv = kernel_sendmsg(sock, &msg, &iov, 1, size - sent);
 		if (rv == -EAGAIN) {
 			if (we_should_drop_the_connection(connection, sock))
 				break;
-- 
2.7.3

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-11-09 23:41 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-08 10:43 [PATCH] drbd: Fix kernel_sendmsg() usage Richard Weinberger
2016-11-08 13:55 ` Richard Weinberger
2016-11-08 16:52   ` Jens Axboe
2016-11-09 15:32     ` Lars Ellenberg
2016-11-09 15:47       ` Richard Weinberger
2016-11-09 16:51         ` [Drbd-dev] " Lars Ellenberg
2016-11-09 16:55       ` Jens Axboe
2016-11-09 21:52         ` [PATCH v2] drbd: Fix kernel_sendmsg() usage - potential NULL deref Lars Ellenberg
2016-11-09 23:41           ` Al Viro
2016-11-08 14:03 ` [PATCH] drbd: Fix kernel_sendmsg() usage Christoph Lechleitner
2016-11-08 15:49 ` Christoph Hellwig
2016-11-08 16:02   ` Richard Weinberger
2016-11-08 16:13   ` Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).