From nobody Sat Feb 17 21:33:03 2024 X-Original-To: dev-commits-src-branches@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 4TchqM5hkpz59lDr; Sat, 17 Feb 2024 21:33:03 +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 4TchqM1jFKz4hbK; Sat, 17 Feb 2024 21:33:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708205583; 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=M+oblKR6/psqzGWgqaWh4E4o0b+s/Cx3vdU4Yp7DRVs=; b=g5jwnNvOC5aDkVydmbKEEfe9z39Sg9aOfcnYmDsFjooORyvEGYwCytmk9YeGDxiSAyplKo RrXIP1/ec6lM+wJS5gHpplPF6hAplxOsZ3yr8icxi9fDv0i6hdhBUj/rsIsGjzgsCGl/C6 Bdjuzo70daXqwwkvI5I9oKDTVErxZutLt2G4zNRoKXXqw2f148VUlfFu7geNwt4BZvls2z 7WeDO+wT/tfk5h9JZw7ffWuHBazeOn3/SG2Z0S3L8tpXRUTU2RBgbnunF8JX4vDxhziBkY utbyS8f+kqJzLNMa1iVgg53iHjpbv/0EqotIqSAiNO2dgaHQSJfTrREcgHhZkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708205583; 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=M+oblKR6/psqzGWgqaWh4E4o0b+s/Cx3vdU4Yp7DRVs=; b=J5QD6bV3kqHhEDl8qcjo9ea1Yx2+SMGRtH3ofhnMjtHN2GUZ0KGgbPo3jcNAMsC+1JG4aZ wkhg7Oo1ThCxE8S0FraGOnmoQLqNdMs9mBvf0CjFgkgS86udGKPkZ6FvWXpdfErI/vJWtd 4+uOZDGM2ZnZUviu9yD0Gz9xTB7ZKQU0g+c6rQ0DiKvKz/zMLx5jqoHPijTTme+9jFsMsi ad3XFNryqlc/CkovL3eMU/10iusdAs3OdGk+Siw9eYSudIkrN0eoVftoyMdDxDaYAPRXCM fDdmDlvSvGKUQYWpzAc5rvgv5rkb7DD+polj4JTc4U2XDMGahWdwsu6U6Nl9jQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708205583; a=rsa-sha256; cv=none; b=S8ee9mRGPoAMJ4V5wkkzmd7uXHhAxQIz3DrntqgT2NSgPw8euAYgPY4XDrG0PHr/wGqibf tUPlIOZNBPvdd5/8/7W/t6GZdwJX46pZ8DfVkcBT1XdMIyG9jAI/GGwBJNA884m6HTub5X hXEaPHRM4lOvOIHR12r2duJOj0TwfUaMJO/4VZ8LsStHM1jWC6z8VQrFx+KeFsD11RWcwI ipX//FHg+KgkwqTyVhp/7uczMGVq/n7xGuuW9618nQso8sZayWshdxJB2aMXOVH785/gbk zFKfOh6ziManFGdX0ZIbQnSvbp41Tib9qL86VaBQ0bF//OsMAUvg3Xq9j6ALFg== 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 4TchqM0mfkzP87; Sat, 17 Feb 2024 21:33:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41HLX3AK020908; Sat, 17 Feb 2024 21:33:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41HLX3tH020905; Sat, 17 Feb 2024 21:33:03 GMT (envelope-from git) Date: Sat, 17 Feb 2024 21:33:03 GMT Message-Id: <202402172133.41HLX3tH020905@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: fcfc3fe00d32 - stable/14 - LinuxKPI: Add ida_alloc_min() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: fcfc3fe00d32c6beb228a13294c8e8288a776ad0 Auto-Submitted: auto-generated The branch stable/14 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=fcfc3fe00d32c6beb228a13294c8e8288a776ad0 commit fcfc3fe00d32c6beb228a13294c8e8288a776ad0 Author: Vladimir Kondratyev AuthorDate: 2023-12-24 08:19:59 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-02-17 20:58:38 +0000 LinuxKPI: Add ida_alloc_min() ida_alloc_min() allocates an unused ID. between min and INT_MAX. While here allow end parameter of ida_simple_get() be larger than INT_MAX. Linux caps the value to INT_MAX. Sponsored by: Serenity Cyber Security, LLC Reviewers: manu, bz MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D42806 (cherry picked from commit c7312643b7e5f01adc2a3094c5139f5dcab5f0a4) --- sys/compat/linuxkpi/common/include/linux/idr.h | 7 +++++++ sys/compat/linuxkpi/common/src/linux_idr.c | 5 ++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/idr.h b/sys/compat/linuxkpi/common/include/linux/idr.h index 2fb2e1734878..ca3f8171ff44 100644 --- a/sys/compat/linuxkpi/common/include/linux/idr.h +++ b/sys/compat/linuxkpi/common/include/linux/idr.h @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -131,6 +132,12 @@ ida_get_new(struct ida *ida, int *p_id) return (ida_get_new_above(ida, 0, p_id)); } +static inline int +ida_alloc_min(struct ida *ida, unsigned int min, gfp_t gfp) +{ + return (ida_simple_get(ida, min, UINT_MAX, gfp)); +} + static inline int ida_alloc_max(struct ida *ida, unsigned int max, gfp_t gfp) { diff --git a/sys/compat/linuxkpi/common/src/linux_idr.c b/sys/compat/linuxkpi/common/src/linux_idr.c index a484a16e2862..657d85606f50 100644 --- a/sys/compat/linuxkpi/common/src/linux_idr.c +++ b/sys/compat/linuxkpi/common/src/linux_idr.c @@ -755,10 +755,9 @@ ida_simple_get(struct ida *ida, unsigned int start, unsigned int end, unsigned int max; MPASS((int)start >= 0); - MPASS((int)end >= 0); - if (end == 0) - max = 0x80000000; + if ((int)end <= 0) + max = INT_MAX; else { MPASS(end > start); max = end - 1;