Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp660257rwb; Fri, 23 Sep 2022 02:18:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5gPUkcXfdj+lruWLzuhbnGlgsXGHm5KmgC5rbrclmBTk0FuopR8XFoWOmkEJ7xW/WuDxk2 X-Received: by 2002:aa7:9d9a:0:b0:53e:8bc5:afb7 with SMTP id f26-20020aa79d9a000000b0053e8bc5afb7mr8036085pfq.54.1663924717097; Fri, 23 Sep 2022 02:18:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663924717; cv=none; d=google.com; s=arc-20160816; b=tma2W9xK5XV+R6Qupsyhz4NvWShcbZHdVZMx+u9L/UzFUIZuP5ouW3ZUq5vcDtpQox VZFHhFaL3P5bXjAPrMLjPUxeITxzyg6LW0UujUffHtDcwuqyNn8J3UrAkqGtMHx/2hx6 3zBi9yRSfrbHhq7zS0cetNMDv5kLlfrMEG4uLIBoDZud8Msuk6BHOhffoPUCSYflXsH2 i6bQUvrseGRtAJEd2dK1KsydxnSn+wl+G3ZBo+fyQrOik9Z9br7QwFRyhsmcOpddhq1o y4pkVhSjA3q//rSASHa7OtEDQ5RnSUSPka+/6lwUybJoj7WPmqloCZSeNCDGBfEdaWug cP1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=3NmV8dBleohq19FUTGjShv3qNCUcjTHlt1m0s7sWLVk=; b=mWuXD8uB3VqRckyekjKqVFn2ekg9VqZHALToPbp2mARl/4QOBBx/d2hCYpaoCAhhEv x5A1JIVkJtkty+uEyPRLuJ2K+LVu2ZRZkNVq1v8Jw8V9Lr4ovMwoMQgGgkiVVZStjAN9 hnRKf7sxehOOH3EK1AK6sv3IjfYMn2yAGEEIdO0uu+ZqQRxS4yJT3AGPyFObTcS6Q5YO Q49PmC/eiOE39Gs4tnzdnljYfu7QkK06rtoPopWjB+PJ7A53hbIBCX/qevcTm8yRwbXp lKhiLVcVer7QWsEtAD0beCiP/4y4/w0E+T4aecQ6kdpjizzHlpTU+G/yV+haDFVHampL Hikw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=V6wEuumq; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=U7EHAzZM; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v11-20020a17090ad58b00b001f51017553esi2016230pju.47.2022.09.23.02.18.12; Fri, 23 Sep 2022 02:18:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=@suse.cz header.s=susede2_rsa header.b=V6wEuumq; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=U7EHAzZM; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231567AbiIWJIH (ORCPT + 62 others); Fri, 23 Sep 2022 05:08:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230378AbiIWJID (ORCPT ); Fri, 23 Sep 2022 05:08:03 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23F4F12BD80; Fri, 23 Sep 2022 02:08:02 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A0F1B219BA; Fri, 23 Sep 2022 09:08:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1663924080; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3NmV8dBleohq19FUTGjShv3qNCUcjTHlt1m0s7sWLVk=; b=V6wEuumqUBqjySkow4NVfoPBdDcct+QY2sSnA92ZeyPwH38i0NPhxZ2JBFN/nzoZI0qJDc KkeFL/D96aoTs49QcLygaGlMNADNI8AXG8StgjNUceGaiafR2+x2Vnsi6pDhmZ07qrK3n8 Inta8iq5GzYLsx9ExrSXKnUXYR9y3Io= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1663924080; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3NmV8dBleohq19FUTGjShv3qNCUcjTHlt1m0s7sWLVk=; b=U7EHAzZMP7bk2R61PfblSG7IYbc4Ddv8PLRV2h2xeqC20gD9ZFpGn6nKi00zf3zaGPeOWS aSCwMvZR9gmTbODQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 19F9B13AA5; Fri, 23 Sep 2022 09:08:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id e5i3BXB3LWM6HAAAMHmgww (envelope-from ); Fri, 23 Sep 2022 09:08:00 +0000 Message-ID: <6e6a5f86-3080-54ed-82ea-80e57e184fd0@suse.cz> Date: Fri, 23 Sep 2022 11:07:59 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH 00/12] slab: Introduce kmalloc_size_roundup() Content-Language: en-US To: Kees Cook Cc: =?UTF-8?Q?Christian_K=c3=b6nig?= , Pekka Enberg , Feng Tang , David Rientjes , Joonsoo Kim , Andrew Morton , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Greg Kroah-Hartman , Nick Desaulniers , Alex Elder , Josef Bacik , David Sterba , Sumit Semwal , Jesse Brandeburg , Daniel Micay , Yonghong Song , Marco Elver , Miguel Ojeda , linux-kernel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-fsdevel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, dev@openvswitch.org, x86@kernel.org, linux-wireless@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> References: <20220922031013.2150682-1-keescook@chromium.org> <673e425d-1692-ef47-052b-0ff2de0d9c1d@amd.com> <202209220845.2F7A050@keescook> <202209221446.5E90AEED@keescook> From: Vlastimil Babka In-Reply-To: <202209221446.5E90AEED@keescook> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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-wireless@vger.kernel.org On 9/22/22 23:49, Kees Cook wrote: > On Thu, Sep 22, 2022 at 11:05:47PM +0200, Vlastimil Babka wrote: >> On 9/22/22 17:55, Kees Cook wrote: >> > On Thu, Sep 22, 2022 at 09:10:56AM +0200, Christian König wrote: >> > [...] >> > > So when this patch set is about to clean up this use case it should probably >> > > also take care to remove ksize() or at least limit it so that it won't be >> > > used for this use case in the future. >> > >> > Yeah, my goal would be to eliminate ksize(), and it seems possible if >> > other cases are satisfied with tracking their allocation sizes directly. >> >> I think we could leave ksize() to determine the size without a need for >> external tracking, but from now on forbid callers from using that hint to >> overflow the allocation size they actually requested? Once we remove the >> kasan/kfence hooks in ksize() that make the current kinds of usage possible, >> we should be able to catch any offenders of the new semantics that would appear? > > That's correct. I spent the morning working my way through the rest of > the ksize() users I didn't clean up yesterday, and in several places I > just swapped in __ksize(). But that wouldn't even be needed if we just > removed the kasan unpoisoning from ksize(), etc. > > I am tempted to leave it __ksize(), though, just to reinforce that it's > not supposed to be used "normally". What do you think? Sounds good. Note in linux-next there's now a series in slab.git planned for 6.1 that moves __ksize() declaration to mm/slab.h to make it more private. But we don't want random users outside mm and related kasan/kfence subsystems to include mm/slab.h, so we'll have to expose it again instead of ksize().