Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp43794lqj; Sat, 1 Jun 2024 07:24:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXG0uG0PsdkwZ01LFB6AycgmwPe2gPtMD9CJpqwlIyFb7PGpkDTpXomXYzKBPw5SAUL33F0j6IsD6GZctcbH268dmXka6NZEkKuqqCIGA== X-Google-Smtp-Source: AGHT+IHpcrpuldzMZegLooNg2dwQcGuNctjMS4hpubXC4QB0oX03L6AG60PP1s8gkMom/8OXu6G6 X-Received: by 2002:a05:6a00:14c3:b0:6f3:ead3:c287 with SMTP id d2e1a72fcca58-70247666e64mr5439736b3a.0.1717251885518; Sat, 01 Jun 2024 07:24:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717251885; cv=pass; d=google.com; s=arc-20160816; b=NbKgaiPmILsVeLnJLlhECFRz72lXUVzR2u7wDTycbyf9bzmP/3phzFYw02PQRxTnYc l+8itFLURvK3+7t58H6DN3gpUycKOLZSY5HJJk2mn5wNkngLAkUTecHXl529UxSkNid4 ogBu+xhUzY0UURQVIcud87QFyR9HGzi6Dwwo+gPKG57H3dtNRKCUnTpM+DUIfqHFz/7d MESIyMoy36emInSen5MEmMb9sec+n2oWfBq5D3A0k1cbM6wG3jeCGQyv9QvnBTLQdR23 LAaZ7Ycti6LD64tZxVpluMLP/tHw4uNVRZ0eOkaZqq8V3IQPVj+HICW/pFN4muxrp2yP d+Xw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=5WqXzPKtJXti3jTMDWhiZHEgOQ4+h0SXg2Ekbefh8hY=; fh=mLtYmnvi8N1qilcpx6hbUXqdVJe/uI94G/pc9OmZLmk=; b=EnuzZ5g4trtV4uTT9TutiDH35Qp2tp0D8ecgz1XmS5mkuf81FPofS/pNnQ2a08LdC7 q2k7bb3Z2Mn/6J+Pppgu4C6iFYmziAjR2QRy7gM4TysvKSzjs6//0nsQ1t03sKdrY9Fi ikoM5gTlurld9PzI8V5J3HrAzGUdop0lahJGWGBrs/ZXWt90zY4RDT2ui76ltU3c1Vmq 2Pa9YHFoSRuAQ04+FNuAW4hytcYyWqShI6xcySeLNY/IEq1ay6bd+LIST3Wtbv9RuZ/b HEXRIF/5KPRsRlCOLJNumJmKYSqhRoFbTvx389boq/xp773CeqrEmduhyC54YkHD4V0t W9dA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AJyxFB3o; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-197891-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197891-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-70242b07c46si3493876b3a.222.2024.06.01.07.24.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jun 2024 07:24:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197891-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AJyxFB3o; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-197891-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197891-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EB55E2837E5 for ; Sat, 1 Jun 2024 14:24:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58A0B14F9CD; Sat, 1 Jun 2024 14:24:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AJyxFB3o" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7589B10949; Sat, 1 Jun 2024 14:24:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717251873; cv=none; b=KXv0EccHTffBTkOoSizopTpIR5o8TGocatKto2ANfDpEgGe4jZX97TxpiCLbTBRzXRDjO4aiheQ1PynSgf3sundvcYvKWfgbvg2UqAWWndEvIri7hG66WUfBv+U3W1M5/sKh2veE70n3UAjpRp4k/ZQyvq2QLhyFbq3a2Q/WFsk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717251873; c=relaxed/simple; bh=3hpQGG0DXNOz5SDZzCSta1IGiF02qt2SWM+gfOhfF/w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=T1S/EZKTMJ0hNEzr2/IBrxrh9cSgFIX44SetWT75hinXYyLjPC1LWT1TofLOaIGtTNVF/zkH8nVHzzSXe+VT0E7Uzmm41o4xGXUswcMnrFBbaKAAkZauuWJGsGnfo8lUg3tXTvaPYlUc3w2ePSPp7dxTAma4PpVJgbS3NObjS8k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AJyxFB3o; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF01EC116B1; Sat, 1 Jun 2024 14:24:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717251873; bh=3hpQGG0DXNOz5SDZzCSta1IGiF02qt2SWM+gfOhfF/w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AJyxFB3otjuYJSZT9fWb84TQMFrA2DG/52s5pD4j4oi/54cIya+Zufr0luSztLMbF ElRL0+vsQ0oDJIbOJ7NoBLGhYiZjquTcvcig2Cr7YnpR25alKPPYPLqdnlmA7Aivyz GAgwl9B0FSwxiA2lZLlgUuZqjyTJVmCsmIa5ynLP9SGKhjUQzi6OcwSmonDP3IQoeF klkp8ZxDNqMv+ZDZDGG3DgEsUptU1RBcKProhdwf9b36Es+TvYlMkGSmqI8dCmAzeC 5zj8CdYaJZVk+DxxVuxZ9GvZFT/1tZ2LNZnZtqkddgafQ55TuE+mzYqwl1gImTqq78 bPZNWoyiX+2mg== Date: Sat, 1 Jun 2024 08:24:29 -0600 From: Keith Busch To: Andreas Hindborg Cc: Jens Axboe , Christoph Hellwig , Damien Le Moal , Bart Van Assche , Hannes Reinecke , Ming Lei , "linux-block@vger.kernel.org" , Andreas Hindborg , Greg KH , Matthew Wilcox , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Alice Ryhl , Chaitanya Kulkarni , Luis Chamberlain , Yexuan Yang <1182282462@bupt.edu.cn>, Sergio =?iso-8859-1?Q?Gonz=E1lez?= Collado , Joel Granados , "Pankaj Raghav (Samsung)" , Daniel Gomez , Niklas Cassel , Philipp Stanner , Conor Dooley , Johannes Thumshirn , Matias =?iso-8859-1?Q?Bj=F8rling?= , open list , "rust-for-linux@vger.kernel.org" , "lsf-pc@lists.linux-foundation.org" , "gost.dev@samsung.com" Subject: Re: [PATCH v4 2/3] rust: block: add rnull, Rust null_blk implementation Message-ID: References: <20240601134005.621714-1-nmi@metaspace.dk> <20240601134005.621714-3-nmi@metaspace.dk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240601134005.621714-3-nmi@metaspace.dk> On Sat, Jun 01, 2024 at 03:40:04PM +0200, Andreas Hindborg wrote: > +impl kernel::Module for NullBlkModule { > + fn init(_module: &'static ThisModule) -> Result { > + pr_info!("Rust null_blk loaded\n"); > + let tagset = Arc::pin_init(TagSet::try_new(1, 256, 1), flags::GFP_KERNEL)?; > + > + let disk = { > + let block_size: u16 = 4096; > + if block_size % 512 != 0 || !(512..=4096).contains(&block_size) { > + return Err(kernel::error::code::EINVAL); > + } You've set block_size to the literal 4096, then validate its value immediately after? Am I missing some way this could ever be invalid?