From patchwork Thu Apr 19 10:04:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 10349491 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 A156960365 for ; Thu, 19 Apr 2018 10:11:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9320628925 for ; Thu, 19 Apr 2018 10:11:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9196B2898B; Thu, 19 Apr 2018 10:11:47 +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=-5.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 0240D28925 for ; Thu, 19 Apr 2018 10:11:45 +0000 (UTC) Received: (qmail 15920 invoked by uid 550); 19 Apr 2018 10:10:28 -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 15739 invoked from network); 19 Apr 2018 10:10:21 -0000 Message-Id: <20180419100935.340306831@linutronix.de> User-Agent: quilt/0.63-1 Date: Thu, 19 Apr 2018 12:04:48 +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 V2 7/8] dm verity fec: Check result of init_rs() References: <20180419100441.548834519@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 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. 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])