Received: by 10.192.165.156 with SMTP id m28csp737267imm; Thu, 19 Apr 2018 06:48:38 -0700 (PDT) X-Google-Smtp-Source: AIpwx48r3eKZ5SPAKfuuLWtPcr8RDpXEIXjwPCJhQtCiRWc+WnMdCL6MqpK9UchOolJifcRNrrxn X-Received: by 10.99.178.83 with SMTP id t19mr5376772pgo.212.1524145717963; Thu, 19 Apr 2018 06:48:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524145717; cv=none; d=google.com; s=arc-20160816; b=WiHClm5jTI7Oe9gsUjTfq9hRsOV6MaU1SF+Se0O3Gw1FV0gB9mlyHaF9OV0hNYIkwJ E994rWTxHioaE98c4Qf0rJ2dxYtJRNZ+yDKKNdeCd4BDbhL/iZNz/rA69DUvXu7yFIL8 BOsI+0VkRd6e3uoiJOPm+XaMsHcKDY2DUTA7QB05uRZJVdrMJL7dS7VLiqwiulxPL9SH g4ncSOUFLqoLuKSGeQd9qVKR3z1DHhJBWnln72QHgNhcjro+slbd1QAt/o1JJbW8kjFZ 8/OYYT7nJU2uu5wpR8MKJmSnIAhklnIZx4Ph7Hr2m+dz4csLpiQAB9Jh8HnyD+DVadVz WSUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=vNf9gFQStpRpAy1uZh6TIl/XluHs8K/mQtZlagBsyHE=; b=ty0cKU6mjp75s2lf6Jd63/t7G3XSKKkKIX8HNSHmlWvLW/QUnrJxjpCddyDtYgrQv/ mPIeAaIaEdtwWAmbbwkQcskRq86F5YS/NG6SNCgkvbkmbO6nCfqyzJOhb2dTyyPDgll5 FJt2/Gwr8Uv+YIlbCN8pe7g2Wfi8WGplITNuOZq81m/9lnxDrekwx89rav+FRuUwsC6M bDavC4eAjUY+NvGei1UaBXX13pxYjH7YNufUEzEvqV7I9ODkdKnp9W2SHf0KwrlGDksR jhpODlOLl1eeBBSw10lcVL14H3XpzTsxXahD55Uj9uP9+Lr+bjj7dBODt/RNBZGhXfDE 0cVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f13si2947442pgv.415.2018.04.19.06.48.24; Thu, 19 Apr 2018 06:48:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753164AbeDSNq5 (ORCPT + 99 others); Thu, 19 Apr 2018 09:46:57 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:35656 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753110AbeDSNqu (ORCPT ); Thu, 19 Apr 2018 09:46:50 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 679D18182D16; Thu, 19 Apr 2018 13:46:49 +0000 (UTC) Received: from localhost (unknown [10.18.25.149]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D59BE2026DFD; Thu, 19 Apr 2018 13:46:47 +0000 (UTC) Date: Thu, 19 Apr 2018 09:46:47 -0400 From: Mike Snitzer To: Thomas Gleixner , NeilBrown Cc: LKML , Kees Cook , Segher Boessenkool , Kernel Hardening , Andrew Morton , Boris Brezillon , Richard Weinberger , David Woodhouse , Alasdair Kergon , Anton Vorontsov , Colin Cross , Tony Luck Subject: Re: [patch V2 7/8] dm verity fec: Check result of init_rs() Message-ID: <20180419134647.GA9817@redhat.com> References: <20180419100441.548834519@linutronix.de> <20180419100935.340306831@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180419100935.340306831@linutronix.de> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 19 Apr 2018 13:46:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 19 Apr 2018 13:46:49 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'msnitzer@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 19 2018 at 6:04am -0400, Thomas Gleixner wrote: > From: Thomas Gleixner > > The allocation of the reed solomon control structure can fail, but > fec_alloc_bufs() ignores that and subsequent operations in dm verity use > the potential NULL pointer unconditionally. > > Add a proper check and abort if init_rs() fails. This changelog makes little sense: init_rs() isn't in play relative to this patch. And it runs counter to this commit's changelog: commit 34c96507e8f6be497c15497be05f489fb34c5880 Author: NeilBrown Date: Mon Apr 10 12:13:00 2017 +1000 dm verity fec: fix GFP flags used with mempool_alloc() mempool_alloc() cannot fail for GFP_NOIO allocation, so there is no point testing for failure. One place the code tested for failure was passing "0" as the GFP flags. This is most unusual and is probably meant to be GFP_NOIO, so that is changed. Also, allocation from ->extra_pool and ->prealloc_pool are repeated before releasing the previous allocation. This can deadlock if the code is servicing a write under high memory pressure. To avoid deadlocks, change these to use GFP_NOWAIT and leave the error handling in place. Signed-off-by: NeilBrown Signed-off-by: Mike Snitzer Seems there is no real need for this patch. Neil, what do you think? Thanks, Mike > Signed-off-by: Thomas Gleixner > Cc: Boris Brezillon > Cc: Tony Luck > Cc: Kees Cook > Cc: Segher Boessenkool > Cc: Kernel Hardening > Cc: Richard Weinberger > Cc: Mike Snitzer > Cc: Anton Vorontsov > Cc: Colin Cross > Cc: Andrew Morton > Cc: David Woodhouse > Cc: Alasdair Kergon > > --- > drivers/md/dm-verity-fec.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > --- a/drivers/md/dm-verity-fec.c > +++ b/drivers/md/dm-verity-fec.c > @@ -308,8 +308,13 @@ static int fec_alloc_bufs(struct dm_veri > { > unsigned n; > > - if (!fio->rs) > + if (!fio->rs) { > fio->rs = mempool_alloc(v->fec->rs_pool, GFP_NOIO); > + if (!fio->rs) { > + DMERR("failed to allocate RS control structure"); > + return -ENOMEM; > + } > + } > > fec_for_each_prealloc_buffer(n) { > if (fio->bufs[n]) > > > > >