From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 249B7C433EF for ; Thu, 14 Jul 2022 09:16:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8EC8894019A; Thu, 14 Jul 2022 05:16:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 873D7940134; Thu, 14 Jul 2022 05:16:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7148394019A; Thu, 14 Jul 2022 05:16:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5CF1D940134 for ; Thu, 14 Jul 2022 05:16:03 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 031528115A for ; Thu, 14 Jul 2022 09:16:02 +0000 (UTC) X-FDA: 79685148606.05.7886651 Received: from gentwo.de (gentwo.de [161.97.139.209]) by imf31.hostedemail.com (Postfix) with ESMTP id 2808B20069 for ; Thu, 14 Jul 2022 09:16:02 +0000 (UTC) Received: by gentwo.de (Postfix, from userid 1001) id ED319B0028E; Thu, 14 Jul 2022 11:15:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gentwo.de; s=default; t=1657790159; bh=32hwBy0u3/431+faOWAMGVXWX8xeJyN/BOQ9pzsMuOc=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=xDw5deeaOdaaXyFY5w2uRpXZqhwlePLrMk4hMaLuuhKWpFcjV947IocSt5ERy3Tdx k/XbxvqYbjcn7QgQuWL5mZJoyOmk8BZBDc/FpXsJmyWyZzj+BLH72+eZOK7NkBw0Ty W8RkBVNsoVA07SxBEMUzERVAuK89CxFBVwF7gv+58r3jVa5/cL8pLnQFVS/cYzn1KX CQ3xqb+vCzIAOS7FQksZX7h8PB9PoipmKYvnvLwEDFepUWb2d8Ud4D5/0MTINSBr+u cEuMOLN1xu1E3e0qlX0Mly4sNdgDn4gb0lz7280QQlzc9kePgcgrDx04QAmiFTdWhA x91A2HD/88V+A== Received: from localhost (localhost [127.0.0.1]) by gentwo.de (Postfix) with ESMTP id EBC0AB00266; Thu, 14 Jul 2022 11:15:59 +0200 (CEST) Date: Thu, 14 Jul 2022 11:15:59 +0200 (CEST) From: Christoph Lameter To: Marco Elver cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, 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 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657790162; a=rsa-sha256; cv=none; b=jHYSjFDFzPxJ0gzToLU6IceuZ34+4Y3EJBplGoSi/BxucU0PIELXQAJzeip1j2JllxX0O+ 3k1UHvULDf4nJ0fZqN+SQaIg9FUtYNHuJuVxwrmATlBbu0RXu+6Ih4Qay0uVHZ1/VFJYzp j7wbRlKXyo3hZPU4GIHJeqsfxbHwxCY= ARC-Authentication-Results: i=1; imf31.hostedemail.com; dkim=pass header.d=gentwo.de header.s=default header.b=xDw5deea; dmarc=pass (policy=none) header.from=gentwo.de; spf=pass (imf31.hostedemail.com: domain of cl@gentwo.de designates 161.97.139.209 as permitted sender) smtp.mailfrom=cl@gentwo.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657790162; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=32hwBy0u3/431+faOWAMGVXWX8xeJyN/BOQ9pzsMuOc=; b=GRjNgeKiaKtrLOl+qvCg9UWQBP+Zrz4zps6MeEuUa20YT8UU1Al2BT0LUe3/lcVDjwt0L8 f5neGEYCyhsFYU6jh1Ks+oo+dpkRFe8Gbg+dlkC572xvqwwiIRQczJ87cSbXUZ+2kXQk0F BpC4EpXWH4dHW6s2aY31LnLxrkXU+7U= X-Rspam-User: X-Stat-Signature: 3575thcf1o91g3x8uu9m6u54ar9crr4e X-Rspamd-Queue-Id: 2808B20069 Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=gentwo.de header.s=default header.b=xDw5deea; dmarc=pass (policy=none) header.from=gentwo.de; spf=pass (imf31.hostedemail.com: domain of cl@gentwo.de designates 161.97.139.209 as permitted sender) smtp.mailfrom=cl@gentwo.de X-Rspamd-Server: rspam03 X-HE-Tag: 1657790162-694794 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, 13 Jul 2022, Marco Elver wrote: > We shouldn't crash, so it should be WARN(), but also returning > PAGE_SIZE is bad. The intuition behind returning 0 is to try and make > the buggy code cause less harm to the rest of the kernel. > > >From [1]: > > > Similarly, if you are able to tell if the passed pointer is not a > > valid object some other way, you can do something better - namely, > > return 0. The intuition here is that the caller has a pointer to an > > invalid object, and wants to use ksize() to determine its size, and > > most likely access all those bytes. Arguably, at that point the kernel > > is already in a degrading state. But we can try to not let things get > > worse by having ksize() return 0, in the hopes that it will stop > > corrupting more memory. It won't work in all cases, but should avoid > > things like "s = ksize(obj); touch_all_bytes(obj, s)" where the size > > bounds the memory accessed corrupting random memory. "in the hopes that it will stop corrupting memory"!!!??? Do a BUG() then and definitely stop all chances of memory corruption.