Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp556680imw; Wed, 13 Jul 2022 03:52:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tf83M1NS5+3C0h9CLQ4Yeozc5YMAHZMl2nMQAfJq+cczjwmCQnhtTnl9xp6CtXzkuJy4Z/ X-Received: by 2002:a17:902:eb8e:b0:16c:29dc:f1f3 with SMTP id q14-20020a170902eb8e00b0016c29dcf1f3mr2663419plg.22.1657709526060; Wed, 13 Jul 2022 03:52:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657709526; cv=none; d=google.com; s=arc-20160816; b=guDNJCXUL8MDmlndCYuO6iVCdn93GMwL0y7JVeVh6Pmhf01Cmaf59rwhqY4Y4zBplJ pChKGNMCIdtiLjC44uqDGZiSMotJfg76BMLrqwDw2EUok9k6LL/ZvPw5u9A517Gg2pbH utrgjw51MLs0wODOceSYlU3VQNTvSAp8qolFP+TUiHw8Z+YeinUDTnGXdStNRM8zqm3u XX0lwT4El+UDcQX2wUAWrNJglvRt1UKg9WJRE3thMYsKZ5PXs4iqZlKMXTfsMe8kV5IR 3gRZvOT+H1kOWFleoq867zgxbIYrMJCKjlEzJd9KAZqm5eCRPaSqvhIK87whRdosta0l un5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=V6txJ8kJFqlTavM48Tri7b4ZlEseDN4jP6+HK4Ak3BQ=; b=LxpNNebbinXLIimq36yWPO9FFkk8j5rWl9G8vIJbSxpZjvJtGpGTesoinS9X7dYY5J n2ImE0t4ttJAjcg+44JG418axCVY1YpHQOGR8SOmUypS2CRLhoDEpH5wl7bfU68exNHq /M1vUAEf0B2AnBpPdc7SGFSkuAJyQLL2NSE63XAbBJNYnb8L6wYetcy65chWdCM3TXOe seY6XMC7nxKtTpzkQ87NnLvKvCc//sTEJWIlOjSxgM75n7uqWJwCcC2dqvTH8v0HxRKl NuQtMAXm7ucdFh1TYeygW7kZnKrfia46iG+MoOLD9RmYoXpPVsn5rXtB+do1MzdBPoJA 84Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gentwo.de header.s=default header.b=KfjqqhlJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gentwo.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020a6549c8000000b0040986ef2410si2025829pgs.493.2022.07.13.03.51.53; Wed, 13 Jul 2022 03:52:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gentwo.de header.s=default header.b=KfjqqhlJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gentwo.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234772AbiGMKHz (ORCPT + 99 others); Wed, 13 Jul 2022 06:07:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235507AbiGMKHo (ORCPT ); Wed, 13 Jul 2022 06:07:44 -0400 X-Greylist: delayed 68035 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 13 Jul 2022 03:07:41 PDT Received: from gentwo.de (gentwo.de [161.97.139.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABCC3EF23D for ; Wed, 13 Jul 2022 03:07:41 -0700 (PDT) Received: by gentwo.de (Postfix, from userid 1001) id CB054B00418; Wed, 13 Jul 2022 12:07:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gentwo.de; s=default; t=1657706859; bh=SeRKe3yf26MO72QyT8L5XOyRs4a5maEIynSyHOtqHmI=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=KfjqqhlJ+qL4z2DVAzkCyK3gUGScWGTsPAWcs3B+248mSEHsLroKOpBYT58vskshA HhDD8TPqp5LgUL7hh9w0lxfU6BdzJiaLFQuGF/Uk8dvqVPKr++46gU1OwJ8X6+9+8o 3llasYq85WgGUZZaprYp0qBiYZ5Vt8Blt+AWJKK5Wuhd3AGRiEh2D2tOOGc6POyAFg JJPvvxUmvPWLo0Cp7ZFMTMvzzwdSsPrmtUW7HIQ/y+999X5Arba1dZZQlmHcDXmCEY oBbRbph2PYTXaaVhIZRjem5Jil5RUErOMQFc5CH0LOZkSlDgtQKYeiImI6nKf7HDtQ UbwnKwniLgl8g== Received: from localhost (localhost [127.0.0.1]) by gentwo.de (Postfix) with ESMTP id C88D1B00149; Wed, 13 Jul 2022 12:07:39 +0200 (CEST) Date: Wed, 13 Jul 2022 12:07:39 +0200 (CEST) From: Christoph Lameter To: Hyeonggon Yoo <42.hyeyoo@gmail.com> cc: Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , Joe Perches , Vasily Averin , Matthew WilCox , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Marco Elver Subject: Re: [PATCH 16/16] mm/sl[au]b: check if large object is valid in __ksize() In-Reply-To: Message-ID: References: <20220712133946.307181-1-42.hyeyoo@gmail.com> <20220712133946.307181-17-42.hyeyoo@gmail.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 13 Jul 2022, Hyeonggon Yoo wrote: > > Why return 0 if there is an error and why bother the callers with these > > checks. BUG()? > > I thought BUG should be used when there is no other solution. Spurios returns of 0 that the caller has to check for is a solution? > > I guess this is an error since the order-0 page cannot come from slab > > allocations. > > comment in ksize() says: > "The caller must guarantee that objp points to a valid object > previously allocated with either kmalloc() or kmem_cache_alloc()." > > It should not be used on order-0 page that is not allocated from slab. No? I guess we would need to check. Code could exist that does this. Getting a 0 size would be surprising too here. BUG()? Or WARN() and return PAGE_SIZE.