From patchwork Thu Oct 12 15:05:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13419359 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A65C0CDB46E for ; Thu, 12 Oct 2023 15:06:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379171AbjJLPGX (ORCPT ); Thu, 12 Oct 2023 11:06:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347171AbjJLPGW (ORCPT ); Thu, 12 Oct 2023 11:06:22 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA147C9 for ; Thu, 12 Oct 2023 08:06:19 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39CEOJs9026501; Thu, 12 Oct 2023 15:06:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=LJ614RvCf/FvT4jGQ5fUFNXsyGNxdBPHPUsVoq5rgZg=; b=rs9ew1YeOnwq5B/4ZsMwiy2EYh6Z9/ErScufCQJgqVs8QlrzQ+WyYr8NPgBzbTTb2xUO CFxb36zvBr9ZexJ8P+JXgkOt+n3m4PY4MsNyr+Z0PJJOnM7soTgfYVlJWn3DcuonIxBo itZpjiLck0vG33ZfoeFtKRSP9EymjR7IjKZXorebVgzn9+Qkw8wGw/MBR9ckNplbJlvb 67wIPdXa1bCaOBtM407y+uPeGY/A3hCagCOaP7k2JYq+xsFwbAl7OEtXUTZ6qhqde79s 1xY3zsni8QEYfHEMk0AtLFUEtFP43nNJ6swjGqXkzm5sU4iSGqc8L3hAIcNhL1+IIZ4I WQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tjwx2b3d5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Oct 2023 15:06:07 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 39CEXlJQ010600; Thu, 12 Oct 2023 15:06:07 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3tjwsahd7g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Oct 2023 15:06:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BQQmHG+ufiFbt5lfBl81oAoPuiOXNHj+rxVVp5BnZoKORi/WCSWdUV8EhbnZ78rQNLzz7memDzUOhe89aJBcIg0jBNykq1KeXIeoorfno9rMTqVXusboAZ2q7j1pJuDhfuKt2qUqQTFFESaEKLDA9tx7PoEr6wmyyo9HQ/+QHwBAb/gXt/XSHZQXXvcxpwXzCbrs8xnON9OeHpeQ12lveKKjYoSUJzMLO7bwfTzeoyrbQoi5lGeFynp5/gEvvgKg0xExxP5rOpSxR8kHrzVGx/+z9+DThHRvBGKyrbBIXnbcJElexnfaq3DwvHNXrluofTyOtM3yrA09BHufsP/sgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LJ614RvCf/FvT4jGQ5fUFNXsyGNxdBPHPUsVoq5rgZg=; b=E1NSR6gBQiG1fW8UhdedQYG3ZW7PhBaNlGhq1uWVXXl023CuxQvWkDVbBSa0hzXFU6kQGil6p48Epi6e2Bp5E8ShP1QNM00VdfGElGInaJ003f76ErcpQWK10u80bjhbm5rkyHg4EJ7LR3NYKLcvhEW1k9pmJqD1YAjpVbJGupeSUobnvOXSquKP52zDkp3K6W60i3pvlUyMstxs1ENd9JpQB8ACeU+8LKMPFZhHf5sY/3lmy7gkCOPFUtA5VXtHgo9FNWI6xtYg8jM6pS6b91J8t5JMmTQRcmvlTSVlaKsPPpVVOfyvHMYxGvooarzeYAt/9ACZ5oNUA4/EW8BXNw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LJ614RvCf/FvT4jGQ5fUFNXsyGNxdBPHPUsVoq5rgZg=; b=yv6Dr2pbfgfCqPb3WK48DrDr9QsdO4g3WtLtSDoOarmxu1vuBiiwuMOH+k8xAJigrjf2s/0w2WxdvGw7ydS8et1MXWxU8FsDuzlEGLDN0ZQnAXTu4rXs476jrKeDWTtvh85b3Mvq1TMauDWVivs0tEEPIKqo7Mgq23BgC8aT6BM= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by PH0PR10MB5820.namprd10.prod.outlook.com (2603:10b6:510:146::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.37; Thu, 12 Oct 2023 15:06:04 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8%7]) with mapi id 15.20.6863.043; Thu, 12 Oct 2023 15:06:04 +0000 From: Mike Christie To: linux-block@vger.kernel.org, ming.lei@redhat.com, axboe@kernel.dk Cc: Mike Christie Subject: [PATCH v2 1/2] ublk: Limit dev_id/ub_number values Date: Thu, 12 Oct 2023 10:05:59 -0500 Message-Id: <20231012150600.6198-2-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012150600.6198-1-michael.christie@oracle.com> References: <20231012150600.6198-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0314.namprd03.prod.outlook.com (2603:10b6:8:2b::26) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|PH0PR10MB5820:EE_ X-MS-Office365-Filtering-Correlation-Id: a0d16493-4ea6-41c9-11f4-08dbcb34c171 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dq54hWrCUedssjES+Mlz9YkjJGeRoAxF17RBm0EgR0ig3X+uh3E3Suf3qNwXA784IlX0zFEGD5YjM/pBpeKfHHhCtJ7lsWLzkiYZZ3bYgn2AH5WTsjTb5Gl48RoyZfiAkOj1qdie31LHEHzQgcE8sHnYQIw26TYTEzlGgQs4IxaKDXxGFvnw3HRa5IB/vX0IbQjChEnmt9OIUO8XvCC1HdVhLpakQPuh35xI3D4jQyMTKV4Qy7D8jiSM1oa1EirdE5Ku+TitwrEUxC5QGh4d9Bi8XXaEbOxrvK1uVNTjLhvq79mZpdb7/aa4rfxpcL8y8nh88D5oBtZtbu8fWE7bxNbnr4TsxHzH7Y4hav1w9g7lPw91wk9ohPEd6Q4Io0NDMHI8aI2m/b34Mmzj2bnXSFO3G4Fqs5CAdcqET4UlYK7PvT9kJkkEzY7wa72nCgI6NKPu5ibVzmEUd7fmeYQs77asLGgEOzFxK+hN4xqhDIxYLYD7HdiuAt8IyUDU4/4VN/4e+H60+kq7iKJaYKcFugEBkBUE/vAm23KEoEhKbgTP4Vtu/29mPpzF5X2+QyuA X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(376002)(366004)(346002)(396003)(136003)(230922051799003)(451199024)(1800799009)(64100799003)(186009)(6512007)(2616005)(1076003)(107886003)(6506007)(41300700001)(316002)(478600001)(2906002)(5660300002)(8676002)(66556008)(6486002)(66946007)(4326008)(8936002)(26005)(83380400001)(36756003)(66476007)(38100700002)(86362001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FZQRe+GSPKfifwPENbjjWKOGvkapJt1UvRVJb4Tg4lrUW0AsTz60GkV+YaXz6J60dSmROeEKTESNjusbxKZjgMb3cakT9+GDpC0Jf+RjqHkBaKnkQ9Y8jj3/B9BVycAZ0F1x14mdgmIHlwP9V6Bpqz5Tn/3PE8u2axZTaHQDMFUm/7ppYljFVHdUGmzw/e4gy4pxUhYV+Y51Nbpv0wcgOCOmrLPygDZ1I7ujx/uYs9GMHx6RyshUWLhWOxAZnK6APe5L3V5rr8n3y9HAkAchElNJ/k+JgrcasYDu96dOFI347GBMtmDpj5mevErao41i4vC+q+qS1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zYlimfStuJjfwzhHz4V7yymI8xpivnqzTNGmORUC4cRa X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0d16493-4ea6-41c9-11f4-08dbcb34c171 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2023 15:06:04.8660 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rqiKXRvvXVzcyG8ejdbWO1NYnY23/5SPu648Nkq+cn6haX5rCg50/y+hKzx/l2Dp5d7XEhB8FN8SIMkQBvqjT4lnanIBeiK5YUOOcMZrgOg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5820 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-12_05,2023-10-12_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 phishscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310120124 X-Proofpoint-GUID: j7FgstRGiVh0HfdTkdxlikBkLDApj4Os X-Proofpoint-ORIG-GUID: j7FgstRGiVh0HfdTkdxlikBkLDApj4Os Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The dev_id/ub_number is used for the ublk dev's char device's minor number so it has to fit into MINORMASK. This patch adds checks to prevent userspace from passing a number that's too large and limits what can be allocated by the ublk_index_idr for the case where userspace has the kernel allocate the dev_id/ub_number. Signed-off-by: Mike Christie Reviewed-by: Ming Lei --- drivers/block/ublk_drv.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c index 630ddfe6657b..ba7c6f9ee136 100644 --- a/drivers/block/ublk_drv.c +++ b/drivers/block/ublk_drv.c @@ -470,6 +470,7 @@ static DEFINE_MUTEX(ublk_ctl_mutex); * It can be extended to one per-user limit in future or even controlled * by cgroup. */ +#define UBLK_MAX_UBLKS UBLK_MINORS static unsigned int ublks_max = 64; static unsigned int ublks_added; /* protected by ublk_ctl_mutex */ @@ -2026,7 +2027,8 @@ static int ublk_alloc_dev_number(struct ublk_device *ub, int idx) if (err == -ENOSPC) err = -EEXIST; } else { - err = idr_alloc(&ublk_index_idr, ub, 0, 0, GFP_NOWAIT); + err = idr_alloc(&ublk_index_idr, ub, 0, UBLK_MAX_UBLKS, + GFP_NOWAIT); } spin_unlock(&ublk_idr_lock); @@ -2305,6 +2307,12 @@ static int ublk_ctrl_add_dev(struct io_uring_cmd *cmd) return -EINVAL; } + if (header->dev_id != U32_MAX && header->dev_id >= UBLK_MAX_UBLKS) { + pr_warn("%s: dev id is too large. Max supported is %d\n", + __func__, UBLK_MAX_UBLKS - 1); + return -EINVAL; + } + ublk_dump_dev_info(&info); ret = mutex_lock_killable(&ublk_ctl_mutex); From patchwork Thu Oct 12 15:06:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13419358 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AC06CDB46E for ; Thu, 12 Oct 2023 15:06:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235265AbjJLPGT (ORCPT ); Thu, 12 Oct 2023 11:06:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235668AbjJLPGS (ORCPT ); Thu, 12 Oct 2023 11:06:18 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACA26B8 for ; Thu, 12 Oct 2023 08:06:16 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39CEOMRH026240; Thu, 12 Oct 2023 15:06:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=8pOhU4tmYaBLjQIur6IGw0wgZqSDYPDzuUIoCZdW1ik=; b=njaLATdUQZaMWonnJGRj9f8WjhTk9/uV8V7urE6N7icuZ/0vJnAXqGWvtcE/8SAPZUrR 1/qs6565QTUuRgUJAQ+QhDN2XYSudhhLZA9SzYfHf7QE2bctcFxlg2XPVaQo7jhp4X7E /xUa4AOJb7TtvNl4p9hH+wMqz5BqcUu0ypXMIO5HjDjeduA0XtLDPBEhZXdoGAga73nl T/Xio/LMSQ8GKIT+bqaQ59eAFAioEaBKIB9wNOBpgvhj0jn/QRGVcQgKkZNzGY5t7ycU 2FhYUKAJ6EBGBBjdctyJH8UXhGjT0u5MdSv2uZUnXmDEmIoJeMoliGUHbYOoHAMOXQJn sw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tjyvuu1ah-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Oct 2023 15:06:10 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 39CEXm6R037425; Thu, 12 Oct 2023 15:06:08 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3tmfhtk7d3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Oct 2023 15:06:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VA5k1ZSArvQqnTTg1o9sQIWwMuYxtg6qbaOABJ17OoPamXxvzWc906z9PuT8/AuvX8iQoxKxKpqpXR9TZE2gpLKvtxUc+PGBHj6iGARWQfQGQcCAy11hH6xjBqEbRkzuJPnhe7v179VAwqBc9MxNjOboqC28bV+znQN0jBNY5KbDdwb2RkbkNn/2UG6WejrBmi/vmC6sojaBm9Ip2zk4g19CcRbwAQQBZQO/GYNgf7U2nEB4O8AucqTgIo2p3TtBjM3Q3W6ged3pvKpF1/spuHu0fnJn+uWLhcRNawK4pduNfbjHZVsYaf1jJwV0MljFxA0Tv3TY9w9U8zpmTQys0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8pOhU4tmYaBLjQIur6IGw0wgZqSDYPDzuUIoCZdW1ik=; b=ZLACb8B1PrHROtjlyMJzdda1bxEz27mqkEozxloQI0iJporz/BEBhNMvxef5qWforSW0Hkio6hkSbnXBEWC6fgF4f0eRB0aRHbxaxqAPBbrxL2HvHIN8aVS3sGTqA2VhreCAQn9rzbnDVs4Z5yvy5KwXPNuZqFDmYAuRXPr5aHYm9UkSR6YE6PoIbJrJJsQnpmb+tHBxXQPwsX7ODNUOxvbft53HyhAODyRtnBBfanGAo6raovUt29Ha94PV6T7iXBEXv9hzVoshz+EshMLV4K2/Glp4gLk7RsULfz22T9j6y7hglBxfbqjjqMeMYoKZ1bJWATX4eq+svrEwg5U2Ug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8pOhU4tmYaBLjQIur6IGw0wgZqSDYPDzuUIoCZdW1ik=; b=dI+9q+tmrQTnAdguVCq05smU67R9vIS5i8vvs8JcWhzqHEmPpbF5FgfWh5dH0GOmoTHgCzL/2YRdTmDlBgXYvuprWjJPX6xgVjds+cd8riB6HBAvxusfWaoKQ9Z4+0VhEtNkIdiaufZ5VYbQCxnN1UvVp3yD9OBMsV3ZLW0KgKc= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by PH0PR10MB5820.namprd10.prod.outlook.com (2603:10b6:510:146::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.37; Thu, 12 Oct 2023 15:06:06 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8%7]) with mapi id 15.20.6863.043; Thu, 12 Oct 2023 15:06:06 +0000 From: Mike Christie To: linux-block@vger.kernel.org, ming.lei@redhat.com, axboe@kernel.dk Cc: Mike Christie Subject: [PATCH v2 2/2] ublk: Make ublks_max configurable Date: Thu, 12 Oct 2023 10:06:00 -0500 Message-Id: <20231012150600.6198-3-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012150600.6198-1-michael.christie@oracle.com> References: <20231012150600.6198-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0311.namprd03.prod.outlook.com (2603:10b6:8:2b::23) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|PH0PR10MB5820:EE_ X-MS-Office365-Filtering-Correlation-Id: e081ff78-60b2-41ed-5ce1-08dbcb34c258 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JbLbhups03vcZ9qz0EYaWu6D6LC89PK1J66nqUQKFsloa0PHQz5a62CFligWA/TcphrlYnM1aBtbmBzJOyceSfpXUBS/KNMH3QeLor3tOlLTuB5LpDNIbXNb0k5SABOJp6kZjWEXezSAkeIl3WP7n7pn3pc9JSFuEW7LTQAFeVKLa4zqT8F7QN8mP5WWwnwyNUWuWy+yCoZRyIMw1B+pZE+mNOzSJNFR/MjltC7X9JjTbx/FpLupVkynp62+1RvVCTdJT0hujbA7ABplhlBfqeIYSkM6KnwBaEvZjfB+syWMIZpWy5IpGKM62I/I4W20fbaRCaC26j9gduRJ5vedfoSgaW7JjakIS9Jy+sn9dtBm1VOQ4pQKXKHPz4HaqxpuFDjb9Kj1RQtE7ElBkLuyNK/eu3IFM2ta7ZZpVWScwQklJWAEkq6Upx4aewGEh7BnWx5bTzAi0enwsIHbo/JqE62OxrKtLvxmrbVauIA3LtEEtDvo0CZ6O2sie7biynI9UGseNT2tXcojc6kUGNJGpRxcYEQ6U9H7ywGXJZF8uGUY7037TnpuShrCKmQYLbEz X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(376002)(366004)(346002)(396003)(136003)(230922051799003)(451199024)(1800799009)(64100799003)(186009)(6512007)(2616005)(1076003)(107886003)(6506007)(41300700001)(316002)(478600001)(2906002)(5660300002)(8676002)(66556008)(6486002)(66946007)(4326008)(8936002)(26005)(83380400001)(36756003)(66476007)(38100700002)(86362001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cYqdFJqZWEwqtuFJTarPv+Ujka384Mi1anbvbFoLVyoL4s4OhNZRWpCHoRvh2SAexteBUfwzvYZQhbzfdXVmDe53EDzEy9OWjgLvXxwqLCJjz1oPMUOTNBBHXLz5OVwON4Qw0MiujuZwmggw6PE/yEdE9DKmca3JmFfHey9V+x5C2IyDkHxzlHGqgaEUiHjecMn3v0sagqVWwQttVqIjMaRRiXlA/YRQP8ESTZTVxyGj8VCKAMHxc6jM2ehPyx1KwCIMiKUfPdT7aQ/sBxnZfAuwyt0BuUUjSuSj+7yuk7KlkF3y30zBks+EGLxTdaYDB4euOWyaWT58ylLmcdxx15CLi8js7soV+iCyf+bDJ8Fd/OjOUgSlVMQnu4ydlJPpaFNE0Qnv2Ri7JBqPEAfSbP4F8Rm6QMFQamgT/sLyl6iaiTvn2ipRhXdQZIgrQ4SsnfwFmyRpATfdAtTg03j5gkcAfc4/oC9xUu7QFaLti0lWIsrcktBSLW3kyoYOuQsw8BZSbTatJ6erC4f2KFxcIJQ4qHqp0sAdqoh5X1PaY9cn/2GCSZMn/1EWkuN4efaylhcHzJ3O2ezM3fokI+pCDy3jPwyTUINXo/9m3TEOrVeaY+DUx05xjhUiFN3BFRVRiwUh4H1hPmbRSSxoQwXbKoWnjd7sThsNswKksU/SWOrD+o+oz3NyC/cMedUoB/LNL2axOyC1IBZ9clzft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821sdH4CuyhiZ3J3AhvlzYXgt7OFs3dHOwqccqn5RZHpEQaKubInsGr9OkZhOhBRA1y39KFS/UQAQw8B4jem9qqWWw+Q5+rfyQgcNk4XxIPwJuzbo/y7AJJfF1rrWEFW4gQHYC/VYARelbRQkaIuDwL46FeYwSUCtkAkoIVYhISgXrdDMY/Yef2UFF3uLwRv+k34KTkgJSOHe33b7wIIWwEN+/lUC2UJNt7dxNYGJuMBRnu+fQ6fe/uDSPWVOfaXgn2h5l8jeW8+sd8x4zZRAEWWQfw7vQKsHhVn6lhdOOiWNpWr2KdIdT4CHTAkP3AJ3XTk67h5SNleo1cxwIESyZlzRBuE3aJDKcpAw4KiadsAJkAca8qkBLEkG04bquwhiOOAdc7NQD5LKWyi9pwCwk09t88/oeuQ60hXzI7ijeMCAwlnhBN/WOaJF9H0RN2EeLlOdtBFm4My5PbG4E+I5njDe08itgSExEJWU87cTGEUCfAzkBtviuU0XXfnBLpb4CX6Y8H4TAEXB2y3CcNIkRGrETxqNWMIfkZfm8hrXaw2wSmoXay3AhfoDXwa/vhuLmnda99myUYmkOqAqairR1Bzq/yC+1ud0Wx9pXJ41Z9LTkicYayIvzhJVCb2pUDzAFXnYbaTI0EyB7vDW7gndvVDpOsCFUXo6RGlfywJR7XNwwMFeyUQTdb61Om1tx2rComQtYP9UIroYHITgibM6m X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e081ff78-60b2-41ed-5ce1-08dbcb34c258 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2023 15:06:06.4010 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4/2UkbdePbA2PV7qO/a4+tx7aIpwXMaaMiLOOxLwL1xUZyvwYXzRq3YvlGvt764dFw9ZQ9EGtiM3KA2TkDkIuT0kKiGqwSH8lMYh6Jcl3UE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5820 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-12_05,2023-10-12_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310120124 X-Proofpoint-ORIG-GUID: 0pKo924kb4np08T9aruUhHVHK7tr6Qzf X-Proofpoint-GUID: 0pKo924kb4np08T9aruUhHVHK7tr6Qzf Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org We are converting tcmu applications to ublk, but have systems with up to 1k devices. This patch allows us to configure the ublks_max from userspace with the ublks_max modparam. Signed-off-by: Mike Christie Reviewed-by: Ming Lei --- drivers/block/ublk_drv.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c index ba7c6f9ee136..b0bbda08ad45 100644 --- a/drivers/block/ublk_drv.c +++ b/drivers/block/ublk_drv.c @@ -2940,7 +2940,22 @@ static void __exit ublk_exit(void) module_init(ublk_init); module_exit(ublk_exit); -module_param(ublks_max, int, 0444); +static int ublk_set_max_ublks(const char *buf, const struct kernel_param *kp) +{ + return param_set_uint_minmax(buf, kp, 0, UBLK_MAX_UBLKS); +} + +static int ublk_get_max_ublks(char *buf, const struct kernel_param *kp) +{ + return sysfs_emit(buf, "%u\n", ublks_max); +} + +static const struct kernel_param_ops ublk_max_ublks_ops = { + .set = ublk_set_max_ublks, + .get = ublk_get_max_ublks, +}; + +module_param_cb(ublks_max, &ublk_max_ublks_ops, &ublks_max, 0644); MODULE_PARM_DESC(ublks_max, "max number of ublk devices allowed to add(default: 64)"); MODULE_AUTHOR("Ming Lei ");