From patchwork Wed Mar 28 20:51:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10314077 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 5301F60353 for ; Wed, 28 Mar 2018 20:58:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 448C128DAB for ; Wed, 28 Mar 2018 20:58:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38D5F2A019; Wed, 28 Mar 2018 20:58:32 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 7332C28DAB for ; Wed, 28 Mar 2018 20:58:31 +0000 (UTC) Received: (qmail 21534 invoked by uid 550); 28 Mar 2018 20:57:23 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 20263 invoked from network); 28 Mar 2018 20:57:09 -0000 Message-Id: <20180328205554.845997973@linutronix.de> User-Agent: quilt/0.63-1 Date: Wed, 28 Mar 2018 22:51:45 +0200 From: Thomas Gleixner To: LKML Cc: Kees Cook , Segher Boessenkool , Kernel Hardening , Andrew Morton , Boris Brezillon , Richard Weinberger , David Woodhouse , Alasdair Kergon , Mike Snitzer , Anton Vorontsov , Colin Cross , Tony Luck Subject: [patch 7/8] dm verity fec: Check result of init_rs() References: <20180328205138.301218351@linutronix.de> MIME-Version: 1.0 Content-Disposition: inline; filename=dm-verity-fec--Check-result-of-init_rs--.patch X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Thomas Gleixner --- 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])