Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Sep 2022 18:13:56 GMT
From:      Emmanuel Vadot <manu@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: a11195df34f7 - main - linuxkpi: Add strndup_user
Message-ID:  <202209201813.28KIDueC022793@gitrepo.freebsd.org>

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

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

commit a11195df34f7b14740447869263d3acf8d72af42
Author:     Jake Freeland <jfree@FreeBSD.org>
AuthorDate: 2022-09-20 17:38:37 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2022-09-20 17:40:05 +0000

    linuxkpi: Add strndup_user
    
    Reviewed by:    hselasky, markj
    Differential Revision:  https://reviews.freebsd.org/D36350
    Sponsored by:   Google, Inc. (GSoC 2022)
---
 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 7a118bb17c48..52110feda6df 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?202209201813.28KIDueC022793>