Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp2407225rdg; Mon, 14 Aug 2023 01:07:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG4EnJ9pS0iHs8nWUM0g2wDGyFE5isb3RkaQwkKcTveJ5xUGcya/oxK5EZ+2UgB0vl/z54z X-Received: by 2002:a17:90a:ba84:b0:269:3cdb:4edf with SMTP id t4-20020a17090aba8400b002693cdb4edfmr6179965pjr.16.1692000477899; Mon, 14 Aug 2023 01:07:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692000477; cv=none; d=google.com; s=arc-20160816; b=YYtKYMmlzMrB3YBgldtp8y8vSNw9D1L7Ty2cfObCPXfvBAwKAnHyki6GUjkPYnYUom xeSOhw0Wb4R5HAcEf8mD8fTXpphaKczscAnb+uLT6gOhHasTsQ/e6VRwYabTi0EFC2hb AVea/b7yKZ37be0RpTdOuk/Zg0jEZmmrC5zV0M4qknfm8lvaH4VFY75JweU4gIs383R3 ESHNPVbrpLCm6bPrVA2B3xN7sEJM5kg85vJ5zQXyjoYVcJvMaWzEflPAjxrwp9DDUiCK yH+ehv4ExIQSQJy01ApwlJLiupeTxpW9VBm7wRDSef5iDgv5qZacjwvgsJAAzPNy/4Ay oiUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=EMMaKjcmf0w6Qeck97k95pB3VR1xSDdwNYw3ZCcMyNg=; fh=PAI56yEu0AiuX8TT+Q3eaKO8S7fFZxUvPBCA6bNffeU=; b=gqkQRNRjdqtMFn7aSGDc5ZyuZRtwDOY/cIOAu3XaQ3lWQJHc1smlqv+yQUec0GokZ0 TUJJ6qy73bb1R9BU9iS2UwikVjDwSxqf7ovHiblIbfqfSumijqCSB/HFb7BYzCsyN5or RSPS2fqR5I7X/+r+Wc0464nhhvhHsXPrwdUdnahouvmhC6Gb3Z+Z/MgPMXzNDVkEK4Yv dOwQj4lV1J15G1xyak+c5M3C7MK+tY8F2QLNhdXemRlD+ruJV51at9btymFF45nXY4MG 75WxaUHt03mFzANPMGijgNdjEyJl2NWmeHU5bFQM1cSGxyPO3SYun21JxbZvg4bYJdQy qACA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Y2um6b59; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x3-20020a170902a38300b001b873b80747si7557440pla.39.2023.08.14.01.07.45; Mon, 14 Aug 2023 01:07:57 -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=@intel.com header.s=Intel header.b=Y2um6b59; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234108AbjHNHnx (ORCPT + 99 others); Mon, 14 Aug 2023 03:43:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234260AbjHNHne (ORCPT ); Mon, 14 Aug 2023 03:43:34 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6A8294 for ; Mon, 14 Aug 2023 00:43:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691999013; x=1723535013; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RReoo07Z8COfyQe4vCo2LnNBVJrUhMSozbnkyWWcdFM=; b=Y2um6b59bFJq2QJ28RbMGjgW5fghkFwKnxV4/IGQ93qnHukybI3wKcJ9 pNtfAfMDH26fb2byq/CsMn0nj8mhp8fMkvBZ9EVX0/Ty8zw7jmycQGa2L U5HdBj1HyshJiw2SEcwF6TY61yW+TZqJxi2HyNFebdpawMNkhbS5G+YlH Vx1n5PLDqAB8uVnZt/SutaZV/2hzuuOp5sl3DHJV5UzM0j3Y9TTLIvXUJ 7MTtP3/WEy0Q3rg8SwblLnE46YYCQ85spJv6rQsivlzrjW1FfE2tKBuMb BH6a0VSvw/vUAabdryqxCDmfbAzmkNmY4OQEAVss5KRIsF7Wi1OKSmIr8 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10801"; a="438314744" X-IronPort-AV: E=Sophos;i="6.01,172,1684825200"; d="scan'208";a="438314744" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2023 00:43:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10801"; a="803372565" X-IronPort-AV: E=Sophos;i="6.01,172,1684825200"; d="scan'208";a="803372565" Received: from navanban-mobl.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.127.25]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2023 00:43:32 -0700 Subject: [PATCH v2 4/5] mm/slab: Add __free() support for kvfree From: Dan Williams To: linux-coco@lists.linux.dev Cc: Andrew Morton , Peter Zijlstra , Greg Kroah-Hartman , x86@kernel.org, linux-kernel@vger.kernel.org Date: Mon, 14 Aug 2023 00:43:32 -0700 Message-ID: <169199901230.1782217.9803098171993981037.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <169199898909.1782217.10899362240465838600.stgit@dwillia2-xfh.jf.intel.com> References: <169199898909.1782217.10899362240465838600.stgit@dwillia2-xfh.jf.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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 Allow for the declaration of variables that trigger kvfree() when they go out of scope. Cc: Andrew Morton Cc: Peter Zijlstra Cc: Greg Kroah-Hartman Signed-off-by: Dan Williams --- include/linux/slab.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/slab.h b/include/linux/slab.h index 848c7c82ad5a..241025367943 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -746,6 +746,8 @@ static inline __alloc_size(1, 2) void *kvcalloc(size_t n, size_t size, gfp_t fla extern void *kvrealloc(const void *p, size_t oldsize, size_t newsize, gfp_t flags) __realloc_size(3); extern void kvfree(const void *addr); +DEFINE_FREE(kvfree, void *, if (_T) kvfree(_T)) + extern void kvfree_sensitive(const void *addr, size_t len); unsigned int kmem_cache_size(struct kmem_cache *s);