Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Nov 2022 10:39:09 GMT
From:      Emmanuel Vadot <manu@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 18057f471dc4 - stable/13 - linuxkpi: Add strndup_user
Message-ID:  <202211291039.2ATAd9um045114@gitrepo.freebsd.org>

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

URL: https://cgit.FreeBSD.org/src/commit/?id=18057f471dc46ddb10e18c36cf7f644d38e1dddf

commit 18057f471dc46ddb10e18c36cf7f644d38e1dddf
Author:     Jake Freeland <jfree@FreeBSD.org>
AuthorDate: 2022-09-20 17:38:37 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2022-11-29 10:09:38 +0000

    linuxkpi: Add strndup_user
    
    Reviewed by:    hselasky, markj
    Differential Revision:  https://reviews.freebsd.org/D36350
    Sponsored by:   Google, Inc. (GSoC 2022)
    
    (cherry picked from commit a11195df34f7b14740447869263d3acf8d72af42)
---
 sys/compat/linuxkpi/common/include/linux/string.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/string.h b/sys/compat/linuxkpi/common/include/linux/string.h
index 95a9d5a76594..932bed81d034 100644
--- a/sys/compat/linuxkpi/common/include/linux/string.h
+++ b/sys/compat/linuxkpi/common/include/linux/string.h
@@ -98,6 +98,15 @@ kmemdup(const void *src, size_t len, gfp_t gfp)
 	return (dst);
 }
 
+static inline char *
+strndup_user(const char __user *ustr, long n)
+{
+	if (n < 1)
+		return (ERR_PTR(-EINVAL));
+
+	return (memdup_user_nul(ustr, n - 1));
+}
+
 static inline char *
 kstrdup(const char *string, gfp_t gfp)
 {



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