Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp231106yba; Tue, 14 May 2019 23:47:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqzF25PU0H8sDwgA37pS0IyijRlDmJQ8adkC0END22heskIV5U9OFBrLCC8HF6hVqrkIkfdG X-Received: by 2002:a63:2d41:: with SMTP id t62mr42893755pgt.113.1557902830361; Tue, 14 May 2019 23:47:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557902830; cv=none; d=google.com; s=arc-20160816; b=mfGl/Com/udltFyzeT3i89lDSk72vjkv9SJ1wFHCuAP64zFgxhUXqiVm8XHIlxDV1e AfkNjEVAqtWfLBwS475d/ft2KZWc1B4T6EIXkwqDNFLklm3UcwpM9KYkiyI9gB77b4Rg 9N1xFamsRh5eUr3TNy5Hfa5hoMlkDe+OInfiLXpRfilWKGZ+Ftk2iTr6W+4SjWf3OpDW 3BeqcGBiOPHasR/2u207JYA1td0pG5SkFgPv71b8Pq9fx6V9VRjOOBU1hbrjNfTTXwcJ K1k4Kc3xPyGP6jnz2FHMVGrA02giLUYb1VjhMT9sDrq3k902IiECSvYJW9YXQPlSuwho 6+SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=awWr7CqE/VI7koIkZm/vLnS/8LIohJ8DzEhbOAp8yVw=; b=VdslPMWEQ162O7JHwdIxFCh4gmBy2BYXWST0oPbRB9VhUv0ELbpvoKAatVkesAPJdM JvibpMm0ZOuE3KWG1omX/Wt7EwfW5ah4N/C6Fo7Ys+0YjcV6pISFvgFE8GVYaq1xLSBQ DYMuENX4lHPjpCyEyOIw5MWUFd1kGsbPSVReMXExAe/yni4hgxziTlAD5apEd5C+pU75 0LX7Wgsx6jNl20MZAMKwhJy6gCYfLsXpv2dyQRgOD9/U7iQvJhiVkCQPCg7pqfj809y8 xmZfuScKvoKEXVo1hNsMyFnAGX3zf85nASLS/VZP/BVMhNk7Ol+/SqNX0k6+/wsvpcYk /xCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KW5wjEpp; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t125si1053291pgc.528.2019.05.14.23.46.55; Tue, 14 May 2019 23:47:10 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KW5wjEpp; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726424AbfEOGpM (ORCPT + 99 others); Wed, 15 May 2019 02:45:12 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:40417 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbfEOGpL (ORCPT ); Wed, 15 May 2019 02:45:11 -0400 Received: by mail-pf1-f194.google.com with SMTP id u17so835707pfn.7 for ; Tue, 14 May 2019 23:45:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=awWr7CqE/VI7koIkZm/vLnS/8LIohJ8DzEhbOAp8yVw=; b=KW5wjEppeN2Y8sAfrlgDf5wT5zp95JTjyJZv4Ti5fRz7+AKXFFuvLvkkxAonwZ5IE1 aPgDoMEgXfMN6MrC8UdZnpZkchtLnD6PMFYfXDPskBEv9kAqj4VmoAoHXd4FRSwGmkEy BADG/NCWU75fvwFdNtTKlKMKvUmvF/NodtMOzlf59yOonbUgGmP07xNRp30pK68KumuE MgGzDYpD67mLxy7RYFiSlCzRZetbS9G2iyXg5C4bIK1Vz11cgj5SwtqXPq2Zry6eOdnB 6zO1o6LCuz9mb6sWc46rMrN8y/dvWrDYFEgmTAMOPp6Yw84X4sCRsvyIMd4iFht++7f0 muEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=awWr7CqE/VI7koIkZm/vLnS/8LIohJ8DzEhbOAp8yVw=; b=rt2tIwhlN8CbdN7Owks0dLtXp4AwZU2pBoQI9bopqejClo7k2JoRYAp0j+isuj/7lC 8T3vttm5FH4ul+KIyrFf6NGrhcWARgFybFrLgQHopsEbZbLOyDgjRq/VIsoCUgWEuq/+ DKk06FbjSH9chJfTrDma+1Ghov8A8b68KchkbPqqFu7Qu/EGm9IdLEOXj+U970lz0R4i DIa7j9qTrmDA0uUBCCxlveCcyoeDcTdpU/gJO7OYQJMxp7c781wFZu+QHY6/MLTwLy5R Nj4GFnFZF8nJxACw7FcmbhTMEm+x2PqXnfkMpytGOVLqQn+wEJumUSss10TubTS4LhNy CxnQ== X-Gm-Message-State: APjAAAV6+g392NciXvqoQxumBLiDePpQmvywxbZuUnl7xQeeiaN8mDI3 0dqyLxMhb1oY8vCjhec/zR0zxUpSFFM= X-Received: by 2002:aa7:8683:: with SMTP id d3mr629082pfo.145.1557902711325; Tue, 14 May 2019 23:45:11 -0700 (PDT) Received: from zhanggen-UX430UQ ([66.42.35.75]) by smtp.gmail.com with ESMTPSA id u8sm2002289pgl.91.2019.05.14.23.45.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 23:45:10 -0700 (PDT) Date: Wed, 15 May 2019 14:44:57 +0800 From: Gen Zhang To: rientjes@google.com, iamjoonsoo.kim@lge.com Cc: linux-kernel@vger.kernel.org Subject: [Patch] slub: Fix a missing-check bug in mm/slub.c file of Linux 5.1.1 Message-ID: <20190515064457.GA29939@zhanggen-UX430UQ> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Pointer s is allocated with kmem_cache_zalloc(). And s is used in the follwoing codes. However, when kmem_cache_zalloc fails, using s will cause null pointer dereference and the kernel will go wrong. Thus we check whether the kmem_cache_zalloc fails. Signed-off-by: Gen Zhang --- --- mm/slub.c +++ mm/slub.c @@ -4201,6 +4201,8 @@ static struct kmem_cache * __init bootst { int node; struct kmem_cache *s = kmem_cache_zalloc(kmem_cache, GFP_NOWAIT); + if (!s) + return ERR_PTR(-ENOMEM); struct kmem_cache_node *n; memcpy(s, static_cache, kmem_cache->object_size); ---