Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Aug 2023 14:24:22 GMT
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 520891109c09 - stable/13 - linux(4): Fix control message size calculation
Message-ID:  <202308071424.377EOMl2025957@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=520891109c096084774165015529e18de5a93cf1

commit 520891109c096084774165015529e18de5a93cf1
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-07-29 08:21:35 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-08-07 14:22:59 +0000

    linux(4): Fix control message size calculation
    
    To determine the size in bytes needed to hold a control message
    and its contents of length len, CMSG_SPACE should be used.
    
    Reviewed by:
    Differential Revision:  https://reviews.freebsd.org/D41224
    MFC after:              1 week
    
    (cherry picked from commit 67116c69052d27dbd6d6c066104850d4d53f0041)
---
 sys/compat/linux/linux_socket.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
index 0bcba7167f2f..393faa5429ce 100644
--- a/sys/compat/linux/linux_socket.c
+++ b/sys/compat/linux/linux_socket.c
@@ -1847,7 +1847,7 @@ cont:
 		if (error != 0)
 			goto bad;
 
-		if (outlen + LINUX_CMSG_LEN(datalen) > maxlen) {
+		if (outlen + LINUX_CMSG_SPACE(datalen) > maxlen) {
 			if (outlen == 0) {
 				error = EMSGSIZE;
 				goto err;
@@ -1866,7 +1866,7 @@ cont:
 			error = copyout(data, outbuf, datalen);
 			if (error == 0) {
 				outbuf += LINUX_CMSG_ALIGN(datalen);
-				outlen += LINUX_CMSG_LEN(datalen);
+				outlen += LINUX_CMSG_SPACE(datalen);
 			}
 		}
 err:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202308071424.377EOMl2025957>