From nobody Mon Feb 14 00:21:43 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 39438195704B; Mon, 14 Feb 2022 00:21:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JxlJm0yPsz4gRv; Mon, 14 Feb 2022 00:21:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644798104; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cUSp+8b/FFG5fpW1/jQMX3/aBbfhJXZJUvAFh0yitew=; b=I8Eh09Oph4UqBNQ3tNsQFS9XAdpLIUsnLBnISLpitQUDHFA02IrKQMXpNT0gWk5UlXr5/Q Y573DTm+a44BQxao+gjm4M4/E4Zbf6RNP/EWak/ECihSbCe3ZgWWe5bPF6h4XmIjpGRZDN qrKRBCbbnyJ1N3lqnM+EV6Di/kUW1/z8fwp9RhgLROgNk99NIwKgNDMU8EnWgt+kqfxbXD baR+9kodRwW+FE5D/bq7pDb1AuSMrny5wKt+vvsRtAV8WkpdN0XO/u/aIBlJiW47s4mifu D0Krtu8CZ81dCfLVqtxdYhmnfHHSSpM2EQj2PXYE+SsfYkkDMRZ2fem3V9uBTg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 01F9425085; Mon, 14 Feb 2022 00:21:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21E0LhAt080027; Mon, 14 Feb 2022 00:21:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21E0LhSi080026; Mon, 14 Feb 2022 00:21:43 GMT (envelope-from git) Date: Mon, 14 Feb 2022 00:21:43 GMT Message-Id: <202202140021.21E0LhSi080026@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: c840d5cec260 - main - LinuxKPI: add kstrtoint_from_user() and DECLARE_FLEX_ARRAY() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c840d5cec2607932d077ffcfee7ccf0a6b50cdf3 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644798104; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cUSp+8b/FFG5fpW1/jQMX3/aBbfhJXZJUvAFh0yitew=; b=I3JBydPj8xUlvcYY+asW5H6glAW+QhLqvwZkP/Q3kZFuVLLtyRZS6GyfWsMp7hq+sAKL6a VZH01VNBVKSiI6BFGBO4qtjDoSVOl0wTQxCGkXXfXbdKAcdxPrIurvHDRc1WPvqHQUkOQq jgV1F12L90lI4WY97Z4VpLIGhPAvXnacD3a/6lPs2Y25TAPUFtf+kQ/mf0/zfdu3xuJk4X HYDzydNMG7y+ZRpQ4WZ3cCJOr6Ba+7t5/aZSE/C1W1JEdsdSi+lVW4z+cHMoX9cFXreyYl IlvrCoPlvj7BCl4YkQ/fKip2f4Wm2vRDI5g67vJu/gxx9gaza5aeOHHRgzpFlg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644798104; a=rsa-sha256; cv=none; b=oCKTZDRq8Hbja2ujN/q4fWHymhAWpw6jMQf8h1D3L8zbo49avvjJWwMiJgKMRebVrwhCcE 5ud8Z1LOBK2trZy5yOCeatO1igQsVv2/RmJfEwop6XFaeMmcnoihjlAJActeOyvaGLLuMv ft1+pD56VE7ExAPt6Ecff7sAZ4P/l+fZ5C/SL8pBnNhbgRLuv6ocM5IcqNpU5dRRYZPlaB KOxC0rueFb5ByEeuPpHKARG0tVgGH1zjnktNdsfQjUDHTVWcoURZApN03D3+wAuxYySQzV b4GGlV9yZtfxbW5qiNgXPfQni/ak37SO0DsbFZaQPPDb/d6d6KeBHilL9SCBxg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=c840d5cec2607932d077ffcfee7ccf0a6b50cdf3 commit c840d5cec2607932d077ffcfee7ccf0a6b50cdf3 Author: Bjoern A. Zeeb AuthorDate: 2022-02-09 11:58:40 +0000 Commit: Bjoern A. Zeeb CommitDate: 2022-02-14 00:20:41 +0000 LinuxKPI: add kstrtoint_from_user() and DECLARE_FLEX_ARRAY() Add an implementation of kstrtoint_from_user() based on the other implementations and an attempt at DECLARE_FLEX_ARRAY() which works for the driver needing it. MFC after: 3 days Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D34231 --- sys/compat/linuxkpi/common/include/linux/kernel.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h index a84f577dd912..39520cd271ac 100644 --- a/sys/compat/linuxkpi/common/include/linux/kernel.h +++ b/sys/compat/linuxkpi/common/include/linux/kernel.h @@ -509,6 +509,21 @@ kstrtobool_from_user(const char __user *s, size_t count, bool *res) return (kstrtobool(buf, res)); } +static inline int +kstrtoint_from_user(const char __user *s, size_t count, unsigned int base, + int *p) +{ + char buf[36] = {}; + + if (count > (sizeof(buf) - 1)) + count = (sizeof(buf) - 1); + + if (copy_from_user(buf, s, count)) + return (-EFAULT); + + return (kstrtoint(buf, base, p)); +} + static inline int kstrtou8_from_user(const char __user *s, size_t count, unsigned int base, u8 *p) @@ -684,6 +699,9 @@ hex2bin(uint8_t *bindst, const char *hexsrc, size_t binlen) return (0); } +#define DECLARE_FLEX_ARRAY(_t, _n) \ + struct { struct { } __dummy_ ## _n; _t _n[]; } + /* * Checking if an option is defined would be easy if we could do CPP inside CPP. * The defined case whether -Dxxx or -Dxxx=1 are easy to deal with. In either