Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5171551imu; Tue, 15 Jan 2019 12:30:42 -0800 (PST) X-Google-Smtp-Source: ALg8bN7xCnsdc8SnCeDDnJhWOyEkkj6CeVOcjRpPymDOMg+NoWB7hkPYAU5ihk3ZR0kdYMcech+Z X-Received: by 2002:a63:6a05:: with SMTP id f5mr5387341pgc.72.1547584242818; Tue, 15 Jan 2019 12:30:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547584242; cv=none; d=google.com; s=arc-20160816; b=CLkvP8z5/ET/WQtGZuUVky0q0DOLdV9tPF+g28ZDdmTB+WV7x1inVzzD/cr26FAvdh ouNmpg9SQBVQlLEPZax1Abtyydk71xRqU5jtxkO+1ocDOYEPSdV1lYWbzXHxnBE1Bxbb 4RWyVmCuGypUzLL4CBuX+ZlhUctSka0ICZDT0zhNoEuXj0y9BBquNL2soIUdgczYl04O mh0fKVmVX+8vjXc1Jt7YOzjoSJzfftlFwas77D003BbQbLrlld935OJVgofbks1kl9bs 4uJAFcL72lnTO+QS2cdp61VBsalSXgCevqM23W9FpYGnliUgb2tiu6Iv/CCjK5SMZj6r UuDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qit9V1U1wonyC+TbLMxhPP85ZYSCtH4hm6o9IfN19IU=; b=mRRvdT3xxONL0Xjk0OK+GfHPtslXv+QcYjZAk8de+YBnDS1Xs0Ix+QXtEafR7XmRjL SumWvaVhKWYwDlsa3+4uQcMPkJ0KtaIOGWc0bwgntfrNg515B2TLHdVawtTPvJ+58/+E cBO3ctoqquX+SH1oBRxMn3PeGwgwYQQVn7xToJIQ4MK2lYr9cRaVy+rUxvw1SbN0WS0L R6tadoNS48/HMPh1cW85bGuqciBOoHhh3jPTcW9lHM3w/TsDBsFfG2U1f8qZDKk7zzVN HTUycvvni2dtD+8r/FOBHQq4zFZYg9kvFSTPRQ1z7uaoT+xpr0aBPzbCEJpojLoaQz9c SVTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fN7PBu1D; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w24si3960074plp.304.2019.01.15.12.30.25; Tue, 15 Jan 2019 12:30:42 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=fN7PBu1D; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732449AbfAOQjx (ORCPT + 99 others); Tue, 15 Jan 2019 11:39:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:56046 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732430AbfAOQju (ORCPT ); Tue, 15 Jan 2019 11:39:50 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7463A2054F; Tue, 15 Jan 2019 16:39:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547570389; bh=MO4pH0sckvsnoHk6DHZbqm9zsGlofh2fbGsMxrnYXR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fN7PBu1D7NwJViqRGFHKx/yz6322ARm7ILvwcLxkhxRuMlUgIkpr65ekY2P7SWerh W3w84VdmRzor9mEXUrLRH/jRlwCYGSyTEAYYZNDU92otqn80evmi2Eyhif4WJv/Cep +qj7ndbjQOYl3BaLdiUZz5dgEXVmZ8Pfoxq8iecQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Lameter , syzbot+d6ed4ec679652b4fd4e4@syzkaller.appspotmail.com, Andrew Morton , Pekka Enberg , David Rientjes , Joonsoo Kim , Linus Torvalds Subject: [PATCH 4.9 08/16] slab: alien caches must not be initialized if the allocation of the alien cache failed Date: Tue, 15 Jan 2019 17:35:51 +0100 Message-Id: <20190115154849.103768649@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190115154848.164648613@linuxfoundation.org> References: <20190115154848.164648613@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christoph Lameter commit 09c2e76ed734a1d36470d257a778aaba28e86531 upstream. Callers of __alloc_alien() check for NULL. We must do the same check in __alloc_alien_cache to avoid NULL pointer dereferences on allocation failures. Link: http://lkml.kernel.org/r/010001680f42f192-82b4e12e-1565-4ee0-ae1f-1e98974906aa-000000@email.amazonses.com Fixes: 49dfc304ba241 ("slab: use the lock on alien_cache, instead of the lock on array_cache") Fixes: c8522a3a5832b ("Slab: introduce alloc_alien") Signed-off-by: Christoph Lameter Reported-by: syzbot+d6ed4ec679652b4fd4e4@syzkaller.appspotmail.com Reviewed-by: Andrew Morton Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/slab.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/mm/slab.c +++ b/mm/slab.c @@ -682,8 +682,10 @@ static struct alien_cache *__alloc_alien struct alien_cache *alc = NULL; alc = kmalloc_node(memsize, gfp, node); - init_arraycache(&alc->ac, entries, batch); - spin_lock_init(&alc->lock); + if (alc) { + init_arraycache(&alc->ac, entries, batch); + spin_lock_init(&alc->lock); + } return alc; }