From nobody Sun Dec 24 08:23:08 2023 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 4SyYvK31Dqz54HQ4; Sun, 24 Dec 2023 08:23:09 +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 4SyYvK1HPtz4XsW; Sun, 24 Dec 2023 08:23:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703406189; 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=Fo5Tuw0tMuSYxKCqjvDUMKWFrvqtCtPOV2N3fhQUfUk=; b=ID49PFKsdHwWxGKOi9VIu4AjWY1R/kMPgj2mJ3DlKuLd2UPIQ2SzzGmvaaOK+jOixiBcUz GNNiTXnEI9DslYqhjMVFGgeY4kD+JHWVy+JxL5AMUAOSWbx4ZDKwyfMh+Fbq+cI+A61SrF HYXSzFWFoqxXWGBdnAe1kmxXK/2qpPo9ECUXSeAB57kShYOGRmxqA7m/YrRkulu5s2TgAx kUPtUS74+ab2YTqD8vXrNXJsDmtooLEZbGLj2z+3f4u+kjJvuXMMb2crMOU46NLCx7WHss mjndL/4VhFzxFsOzfhTzMv8cljEknMxSjUe3FTOqcVQl3R5wARNnhd4px7UlQQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703406189; a=rsa-sha256; cv=none; b=PRCi1RX80wu6agf3D+lsGYghIW52K+5FO7avsXKjQ7yH87H+kUpQ2AAJ0X5XhE2HrGzD4Y kOTPAdIRlvxwuVIgaxoru81pe1J4dm1RTTvru3Q+hczU19kgxdcponDXu1egcjFkRzhGm6 1cfLkKqmkgaiuFEQ/3oSNHs7BDSLmCj4KlYryPLRnCR261swdTH4LEfcFWAbIVl1RcQqTg bnA/zI9VAT6mkatf/uI1VUV2oGXiUNnSRQ41EyNhaF4gA5F1e+KN2p9g5xTNMRwhArVxVq fB/AMKX9zNVeg+UN/PMxhCEeHlIxQZBZGQyxuQ/YB2Rm27WEunDP+Rz8kvF2yQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703406189; 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=Fo5Tuw0tMuSYxKCqjvDUMKWFrvqtCtPOV2N3fhQUfUk=; b=ABijYs0kSrlPlvK8efo/F/ZIEcf8lWFoWN5NSWv3Hjvx0ENybdjdb/UfD/TtZllDfKFIka s4WShSPMFkuvtbuS6n3KYCjWHpivJO9gmP3dHx5rPXTCnYqzQTgnB1E+wlDFg8dqvpoO8w A8ARMeWPHI3KNxGphrZKZYWS8skEp90bwIqPUtqA17KyfPqXkBsl6G346gd5x0MwYuZOaV z063Wu3ljA3beMBfkfOrVTKxyEqoseT9PPr5CzrBfnehUxhtwHFj6W5cEN6nJAZ4sJvdNq QqZ45ujzE2VWNfWHncf2CJLACtd4u7qaA1DufHIpezmyc4c9p77dX/FnNAQxgA== 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 4SyYvK0P0yz5sl; Sun, 24 Dec 2023 08:23:09 +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 3BO8N8Mw087164; Sun, 24 Dec 2023 08:23:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BO8N8fO087161; Sun, 24 Dec 2023 08:23:08 GMT (envelope-from git) Date: Sun, 24 Dec 2023 08:23:08 GMT Message-Id: <202312240823.3BO8N8fO087161@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: c7312643b7e5 - main - LinuxKPI: Add ida_alloc_min() 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: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c7312643b7e5f01adc2a3094c5139f5dcab5f0a4 Auto-Submitted: auto-generated The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=c7312643b7e5f01adc2a3094c5139f5dcab5f0a4 commit c7312643b7e5f01adc2a3094c5139f5dcab5f0a4 Author: Vladimir Kondratyev AuthorDate: 2023-12-24 08:19:59 +0000 Commit: Vladimir Kondratyev CommitDate: 2023-12-24 08:19:59 +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 --- 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 3be106150513..dc64da0d7cf5 100644 --- a/sys/compat/linuxkpi/common/src/linux_idr.c +++ b/sys/compat/linuxkpi/common/src/linux_idr.c @@ -754,10 +754,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;