Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp995806rwd; Wed, 7 Jun 2023 09:30:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7sUwwdHvUurwK8wR79gjVnW3exTSqLvGtVl0TR2gkkvcuBJtYTunwwb+RAAZ0Jhtja0ES6 X-Received: by 2002:a17:90a:654c:b0:258:e023:7073 with SMTP id f12-20020a17090a654c00b00258e0237073mr2122792pjs.31.1686155432355; Wed, 07 Jun 2023 09:30:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686155432; cv=none; d=google.com; s=arc-20160816; b=LWxYWOVb2C+DKCdGoOuPxz0hZm1RBexH5S2/RZY68+esah8fq50cPaLiXLSLBO63VZ 1mZ4uafHxV0ac4owI0vCeAP0aLFtrln0kft4V00ltjNMFfQRKOkqV0UlMttXXeXEvzkn /K+uMGN1Lc8alg/WbriczVhBTFw48Z/Hjitg/ZS+1eVXxFeC4kKytgiqwlTuDgj0Wpvt RaHTaZzLImuvbbKNDGxsevq0UMarld4eKA3p6D65ddtFrzq8IdGZqdEI1tUA6Pj6EW/D kj7ZEFNL3KzIlQSWjL8m9tSgYCoGo1TlxoxErKE7wd0vOhSJawmYSX6KC5fSKqpmtmdV nRWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=5028jVPHP9PdFYdLuVCSXCH9vrAc5KtFszGWksMpGUc=; b=R93VhMZhTuygVUhm6qiYp0zBvYiOhBYos/OXGZJziz+0fd+XBtxJHqpWDOXLNdv0A1 pLl/OB+I5lcw3FL6I6TyFKxfc5+yY57ApvNjVt/PEC/lZ4gXkm3JQ21P0WH6JMS8jVE/ //BoktYzxxEFkWwNX8W6SNvB72SpIJjdU2UWSxKl0DaA2pyfzAYc1wMfuZxm6xqu8nV/ 1m2K8UstxqKHTh344k5xGpkt2yYRVXDRuojuos2S81oIAS/VSho7xL1FrcS5zUxXSQZ9 +PtMemKL1k9P/x0ovzYYmf9Q85xqJeconsRNbJQiwDCWq9EMC6QZwdZgou41wvRfX1l4 I3MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@invisiblethingslab.com header.s=fm1 header.b=C1cAy4eG; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=vHwfFTGT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w15-20020a17090a15cf00b00258d8f6eabdsi1350419pjd.66.2023.06.07.09.30.17; Wed, 07 Jun 2023 09:30:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@invisiblethingslab.com header.s=fm1 header.b=C1cAy4eG; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=vHwfFTGT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238399AbjFGQAk (ORCPT + 99 others); Wed, 7 Jun 2023 12:00:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235978AbjFGQAi (ORCPT ); Wed, 7 Jun 2023 12:00:38 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B2BBE4; Wed, 7 Jun 2023 09:00:37 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 869505C0135; Wed, 7 Jun 2023 12:00:36 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 07 Jun 2023 12:00:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= invisiblethingslab.com; h=cc:cc:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm1; t= 1686153636; x=1686240036; bh=5028jVPHP9PdFYdLuVCSXCH9vrAc5KtFszG WksMpGUc=; b=C1cAy4eG464IqwFzu5xeP8gAE0QO3dLhTabsmagrE6+5R6TBxmH pvqIWi2MhW7XF++PVFirKmt/IhrFVF9S4TlHsMzlUbCfYF9odjPncT8XMrzJosos kPB0xE/usXX0McDFIiZUqyZ7fKbpxkvofxzL4XBtKGAO9fYDVczXLbBHhy4LuCjk EuRo9k9bs1b4Q/LufMkRTlvH6+agpSy+sBSlG1Oqxhaf17gJR8Xy87qMkxpecZSD BXSK2SDOOZmSi0H/BVWOX4TlJaywLxpCysr+/V8LCGmaJ3INEaYiGf5k6z8uhUDC cSkvagZov6MfRIgGYo+ic5Pv5TdHMImHh5w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1686153636; x=1686240036; bh=5028jVPHP9PdF YdLuVCSXCH9vrAc5KtFszGWksMpGUc=; b=vHwfFTGT/5ssYIxdP7wETLuuxk6eC ARgxzVUapDh+HCKJJ8iHh24XSq02KTaPS6M0Wt9XlqjMnO59fEC0q+Myz3byIQ+r 4eH+at1xsN5LoszpsLl4kMETWuXanw/kSXECpBBmoe2fFdFqqDccXU4Qc/ulqjxr /UfuPuhs66RaE8mbOYgAkPq17kIAw2UbmlfFlJvqptPtot5Vk6cELU1U8T2iU/m2 WzMqVGJgdxCYjhiK6Ug/dB1dJelA/OiMIF6wxslWBXtkTvyRNfLF+FCZH9yVY1FV Bpi/5dcOovMKPvtCy+Bs8MqZGv3pamgiWbyisiytKLVkgKCK3rZmDumgA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrgedtgedgleehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepffgvmhhi ucforghrihgvucfqsggvnhhouhhruceouggvmhhisehinhhvihhsihgslhgvthhhihhngh hslhgrsgdrtghomheqnecuggftrfgrthhtvghrnhepudeileefueetvdelheeuteffjeeg jeegffekleevueelueekjeejudffteejkeetnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepuggvmhhisehinhhvihhsihgslhgvthhhihhnghhs lhgrsgdrtghomh X-ME-Proxy: Feedback-ID: iac594737:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Jun 2023 12:00:35 -0400 (EDT) Date: Wed, 7 Jun 2023 12:00:29 -0400 From: Demi Marie Obenour To: Christoph Hellwig Cc: Roger Pau =?utf-8?B?TW9ubsOp?= , Jens Axboe , Marek =?utf-8?Q?Marczykowski-G=C3=B3recki?= , xen-devel@lists.xenproject.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] xen-blkback: Implement diskseq checks Message-ID: References: <20230601214823.1701-1-demi@invisiblethingslab.com> <20230601214823.1701-2-demi@invisiblethingslab.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="CTS34Y4jd0AZd9RG" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --CTS34Y4jd0AZd9RG Content-Type: text/plain; protected-headers=v1; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Date: Wed, 7 Jun 2023 12:00:29 -0400 From: Demi Marie Obenour To: Christoph Hellwig Cc: Roger Pau =?utf-8?B?TW9ubsOp?= , Jens Axboe , Marek =?utf-8?Q?Marczykowski-G=C3=B3recki?= , xen-devel@lists.xenproject.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] xen-blkback: Implement diskseq checks On Wed, Jun 07, 2023 at 12:44:22AM -0700, Christoph Hellwig wrote: > On Thu, Jun 01, 2023 at 05:48:22PM -0400, Demi Marie Obenour wrote: > > + if (diskseq) { > > + struct gendisk *disk =3D bdev->bd_disk; > > + > > + if (unlikely(disk =3D=3D NULL)) { > > + pr_err("%s: device %08x has no gendisk\n", > > + __func__, vbd->pdevice); > > + xen_vbd_free(vbd); > > + return -EFAULT; > > + } >=20 > bdev->bd_disk is never NULL. Fixed in v3. > > + diskseq_str =3D xenbus_read(XBT_NIL, dev->nodename, "diskseq", &disks= eq_len); >=20 > Please avoid the overly long line. Fixed in v3. > > + if (IS_ERR(diskseq_str)) { > > + int err =3D PTR_ERR(diskseq_str); > > + diskseq_str =3D NULL; > > + > > + /* > > + * If this does not exist, it means legacy userspace that does not >=20 > .. even more so in comments. Fixed in v3. > > + * support diskseq. > > + */ > > + if (unlikely(!XENBUS_EXIST_ERR(err))) { > > + xenbus_dev_fatal(dev, err, "reading diskseq"); > > + return; > > + } > > + diskseq =3D 0; > > + } else if (diskseq_len <=3D 0) { > > + xenbus_dev_fatal(dev, -EFAULT, "diskseq must not be empty"); > > + goto fail; > > + } else if (diskseq_len > 16) { >=20 > No need for a else after a return. Fixed in v3. > > + xenbus_dev_fatal(dev, -ERANGE, "diskseq too long: got %d but limit i= s 16", > > + diskseq_len); > > + goto fail; > > + } else if (diskseq_str[0] =3D=3D '0') { > > + xenbus_dev_fatal(dev, -ERANGE, "diskseq must not start with '0'"); > > + goto fail; > > + } else { > > + char *diskseq_end; > > + diskseq =3D simple_strtoull(diskseq_str, &diskseq_end, 16); > > + if (diskseq_end !=3D diskseq_str + diskseq_len) { > > + xenbus_dev_fatal(dev, -EINVAL, "invalid diskseq"); > > + goto fail; > > + } > > + kfree(diskseq_str); > > + diskseq_str =3D NULL; > > + } >=20 > And I suspect the code will be a lot easier to follow if you move > the diskseq validation into a separate helper. Fixed in v3. --=20 Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab --CTS34Y4jd0AZd9RG Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEdodNnxM2uiJZBxxxsoi1X/+cIsEFAmSAqaEACgkQsoi1X/+c IsH5yhAAnK+FHobE4EaJLu/MXl1mYHrYhpZKqUOIopKg1xODd1RlWyQI95qq3vHX AnwOhHN+Wv/PbJ0vhvL+/DtuC56AIaCxzhShuZmqZjvLDPwdvi73nSf4xiV7SLWG 6GfMhn9Mo8MGoj+ek88P10z9bIwrfdCWnvnuns6bcGlHsMkrx/B3Jzk5ZOD1QWWj W6jzKRmUDCv+RKHcajLUB3iM2JTTYOLcljqldvSyRv1SySytToLRtTWfZrOJS7Z2 Tjf9heSRPhvHPvcaHyidiaZ87xQjcmI4LRzOXEybxFd6uxIf4QpDD4rschFu25NL TTEFPRIocqwHQgyVcG8aIu86nizNf7f/O/iLfQhNTuYQ1mbq6l8QNyAcJ6sXMz0A fms3iMGiH2LF/pi8vEprOfiC1+0L+whpAqEEogIWh4zYp/tM0raENGZNJL6ZTwXI BPkVkAmsrZAQljrzecbtjRWPZJUDmi+u9XGFCjY9MX7oHtnRH22hLdVeYqd1NljD bgleEMTPiV/ZhPhOPi/Fyccze9VneSOjQ7QoKii0JaiECzatJFr3ZoIgwpIJsv17 KSglgXTjzQpGPURe+RK+rQWMAlb6V2gT3mNC36txOv8j+Y6CuL3xfwGIdfP5nLh+ qTO2n1i40TxJ0VEZa9kD67tyqrLuOS7kru2hQbdhvW9f92eOPo4= =m1I6 -----END PGP SIGNATURE----- --CTS34Y4jd0AZd9RG--