From patchwork Fri Aug 18 06:15:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9907661 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7DB5D60382 for ; Fri, 18 Aug 2017 06:15:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FE4D28047 for ; Fri, 18 Aug 2017 06:15:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64CD4281B7; Fri, 18 Aug 2017 06:15:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1229628047 for ; Fri, 18 Aug 2017 06:15:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750847AbdHRGPi (ORCPT ); Fri, 18 Aug 2017 02:15:38 -0400 Received: from mail-yw0-f171.google.com ([209.85.161.171]:34762 "EHLO mail-yw0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750748AbdHRGPi (ORCPT ); Fri, 18 Aug 2017 02:15:38 -0400 Received: by mail-yw0-f171.google.com with SMTP id s143so53530551ywg.1 for ; Thu, 17 Aug 2017 23:15:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=VIFQ5qdcxHIX4nMhSURxZfOqY0YlOeUbqt/FQHLrMIA=; b=otcvuDdEk9Mw7SCCw5O2qkdpM1d6x3LKuFqakuD5/+GZWTCh0erKIHgGa8gc+vW0hK fB29/Qx01cMxXJ9NGNRA9GVvBmt99dAOQ0RhrjfBTRhj023Swe4cM8bvbAULF+havK+n 0ZGwOKTFKKD0rIjs1Fg7n7km+JgoHtcFKH/CTsdwIeGnVjT0O/ZWILWWuAdsZCHSM7VM C//iacZk4KREu7b5KANQ1BZXDsLTvz1+wP7FCVApRxe1wVGVYjLMDmQr2+2QzaH008Gz nO1M6jp9+pEcdaAlUGgALxdtOsp8RE2aiFqnDrpLqgh9liR7GDUpXVQagfxC6Sx1yXxU Yz7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=VIFQ5qdcxHIX4nMhSURxZfOqY0YlOeUbqt/FQHLrMIA=; b=QO7jHJ1ijk7ayN4v4pDVYxohLnSPbeTDBIjIIZ8cH/Pl1m9lZ3bz20qlfffBlEMbg8 /AtJOEpn70wIJl6aBLBfOnZDmDpCLeWMc46pcQ6RnR/DE5S1w8KGDJHHNh82HvxEY4tD 3fVzTj0v8hyRGrja58STxk23eFJM+DN+fUseS6DcQngZevok7+daTU/7eIa183HbQz0V yOpn808P7h7uKHhRJPCsCOnpvCtpw5nOLe7ZZByTU/ByJYsFJFbPwZMFApfIkuXJ1dIV xQ04sELeU1NYMhRuaaGjJtqjbKI/o0mNc7UhNwnsCSfbCuMKJn0Tx8L14Eei5rzkcSyF Y5pQ== X-Gm-Message-State: AHYfb5iZzX4TYKAyVDX7RVDn0GOQrhJVarXNE7aWXGGU1Bappjn0Iz1x bBiV6X76ue0NLETiaZ9jyg== X-Received: by 10.13.192.130 with SMTP id b124mr6225210ywd.126.1503036937349; Thu, 17 Aug 2017 23:15:37 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c091:180::1:1a7]) by smtp.gmail.com with ESMTPSA id j140sm1863257ywg.18.2017.08.17.23.15.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Aug 2017 23:15:36 -0700 (PDT) From: Omar Sandoval To: linux-block@vger.kernel.org Cc: kernel-team@fb.com, Hannes Reinecke , Ming Lei Subject: [PATCH 2/2] loop: fix hang if LOOP_SET_STATUS gets invalid blocksize or encrypt type Date: Thu, 17 Aug 2017 23:15:26 -0700 Message-Id: <1ae3e2efdaf3f16bfdd4cf12b1350d49bb6a9026.1503036471.git.osandov@fb.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval In both of these error cases, we need to make sure to unfreeze the queue before we return. Fixes: ecdd09597a57 ("block/loop: fix race between I/O and set_status") Fixes: f2c6df7dbf9a ("loop: support 4k physical blocksize") Signed-off-by: Omar Sandoval --- drivers/block/loop.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 39fa7f48e0c7..6c7609b3305d 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1125,11 +1125,15 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info) if (info->lo_encrypt_type) { unsigned int type = info->lo_encrypt_type; - if (type >= MAX_LO_CRYPT) - return -EINVAL; + if (type >= MAX_LO_CRYPT) { + err = -EINVAL; + goto exit; + } xfer = xfer_funcs[type]; - if (xfer == NULL) - return -EINVAL; + if (xfer == NULL) { + err = -EINVAL; + goto exit; + } } else xfer = NULL; @@ -1142,10 +1146,14 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info) if (lo_logical_blocksize != 512 && lo_logical_blocksize != 1024 && lo_logical_blocksize != 2048 && - lo_logical_blocksize != 4096) - return -EINVAL; - if (lo_logical_blocksize > lo->lo_blocksize) - return -EINVAL; + lo_logical_blocksize != 4096) { + err = -EINVAL; + goto exit; + } + if (lo_logical_blocksize > lo->lo_blocksize) { + err = -EINVAL; + goto exit; + } } else { lo_logical_blocksize = lo->lo_logical_blocksize; }