Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4245471yba; Sun, 19 May 2019 14:33:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwLUSl8UmSHdglYVyUd0g3r7/5DefRgTFhg/8eut8p8RM9gdVelU3kiTjL5ppZpYgZSKcO X-Received: by 2002:a17:902:4e:: with SMTP id 72mr19384984pla.80.1558301624659; Sun, 19 May 2019 14:33:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558301624; cv=none; d=google.com; s=arc-20160816; b=zx3tF0NEy1RgwiiwnfjC7WkO5bVg7KHNtrJqml7cIT6gh3gpv9YMjVbLR5LHH4xGME jqctdOVo9LQ4FC5IYUY0gkArWojAMFtzdpa4nDhrpufG7Aj9yd/1VhM764u6fohBC72q DDYommYgGcwMTHHg3gIdYPPBCDk9d2MTxUMaY7ZeU/KRYT+rquiCcrhgsZYpdKIdXx/+ UmivS2IV6wMT3Cf4fOaXtkHS7js+x7W+du7pnEQkSUjDHUbjwoB1SXgbrNr5V9V1jEqf AYxzdNL0RX54faX44/6PfjxzSiC+er4zanoBPD19N2bKhvmuj8TkMbjKYjYE8g/wz1Bp 7hCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=0bkKTyKYnhFPDlSX68YGNfeLYH++JQQQW+qUhMyZqg8=; b=ldxh9DaBmXUJ0W8YOkeXBlJyUWjvxkBiQ6jBUcHcKZNVG6q5zLVEAEhs3D3x5wsmOQ jMjfF0I+L2TNKIIRXNG2v5x5hTdr070PNKXsCcpy6Njc7QUerb9cQqaYM5P8Qd2KbMiC YMZHGBuUDIKtcVJzusNhvovjxYJW8vGiq5xvz9LXtBbBTSbDUk0ehI9ysPlo2cd634N+ L2QEVE8jZBi4eAc5zBPoRG4lONWAzExuFJRGWfqYFd6vvW+9paqMMKrIi9jYgpLiiRr1 wAc9Egvl6aYnEOK17jvFedLuTZRfRh9qRKv3OeEv671SYC7Z7ZuZJK8pE7lQvFQ+xcCW 1URg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=vCUyKhRf; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u63si17292612pfu.88.2019.05.19.14.33.29; Sun, 19 May 2019 14:33:44 -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=@google.com header.s=20161025 header.b=vCUyKhRf; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729362AbfESSMD (ORCPT + 99 others); Sun, 19 May 2019 14:12:03 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:45456 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725784AbfESSMD (ORCPT ); Sun, 19 May 2019 14:12:03 -0400 Received: by mail-pl1-f194.google.com with SMTP id a5so5608139pls.12 for ; Sun, 19 May 2019 11:12:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=0bkKTyKYnhFPDlSX68YGNfeLYH++JQQQW+qUhMyZqg8=; b=vCUyKhRfrhRkIsTNCZU7vDPV84pSHhJxo02gsYlUNJlz9lUfP945+vbSGTYFkjmf6O jWnqrrnlwj8y//OcQgtxYCg1iJEzt78GTEXALjPB1ZcR1Tn3hu9Dks+YARGRCl9+GrTE 0eY8eEHfmauSyxMRVxwGmi6KAaZaamP/4Nnc7p0e8Egxvztdtz/3VRuWIOIsBXEZe1t/ NvbfAjXV3/fw6xFDvFNxuNOVMLWIrjejbyzv2kxJkwq328zLOCPXKYV49SuxiEPSoqFC US5DvslcrXyVCFxlcJ6Wh+SV6pHKVUmTQridm1KZLaWWcgvxMMUed3uNOveD6nxtGO2c vueQ== 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:in-reply-to:message-id :references:user-agent:mime-version; bh=0bkKTyKYnhFPDlSX68YGNfeLYH++JQQQW+qUhMyZqg8=; b=pjcw2wrsps0bDD0h6IlRJPs8rRyDQegA6uJ45WLoZatZi5sd/cyCSH7zqCwn3XihfD DfJekFjxeb9su8s3mT/tJU5LL3HOrvJylNUUXAjSh3LAK9A008ckVljDKzAEIpJBRdXY kqc3d8BAJfiXpcjCdNcEMOlpeh+rDEm62gJqwdxIW4EK6ne+KMljXYNz4R+SkjSUnylS eo3SbGF7QIsI2o9M0Kf3Mm+Qxb8u85bTn1jC4owiPZkKeHyHUWwUJsSWkQfW86ayFIM7 dEjTD4v/wcJlF558Wc8pHfGvyubjUI75RMLse5llBCS2hlGjTuD4EzFy0YufsfZHFjHM Sj4g== X-Gm-Message-State: APjAAAW65iStKaC7M4J7sRtgSFHutFmp717trlJqQ7Xm7NAw+DStGLXz FiCv60RQGuTEcx4qJagERYDvHhM/ZMU= X-Received: by 2002:a17:902:6b:: with SMTP id 98mr68384959pla.271.1558240984723; Sat, 18 May 2019 21:43:04 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id j10sm14335787pgk.37.2019.05.18.21.43.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 18 May 2019 21:43:03 -0700 (PDT) Date: Sat, 18 May 2019 21:43:02 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Gen Zhang cc: iamjoonsoo.kim@lge.com, linux-kernel@vger.kernel.org Subject: Re: [Patch] slub: Fix a missing-check bug in mm/slub.c file of Linux 5.1.1 In-Reply-To: <20190515064457.GA29939@zhanggen-UX430UQ> Message-ID: References: <20190515064457.GA29939@zhanggen-UX430UQ> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 15 May 2019, Gen Zhang wrote: > 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 > It's ok if we encounter a NULL pointer dereference here, if we are ENOMEM then there is no way to initialize the slub allocator to be able to perform any future memory allocation. Returning an error code won't help. > --- > --- 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); It's not legal to mix declarations within the C code here.