Message ID | 20240911064535.557650-3-feng.tang@intel.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 9FFACEE0212 for <linux-mm@archiver.kernel.org>; Wed, 11 Sep 2024 06:46:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F054940008; Wed, 11 Sep 2024 02:46:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 19F2B6B0385; Wed, 11 Sep 2024 02:46:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 04195940008; Wed, 11 Sep 2024 02:46:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D23B06B0383 for <linux-mm@kvack.org>; Wed, 11 Sep 2024 02:46:18 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 435A4160FD1 for <linux-mm@kvack.org>; Wed, 11 Sep 2024 06:46:18 +0000 (UTC) X-FDA: 82551523236.27.CA0C28C Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by imf28.hostedemail.com (Postfix) with ESMTP id 2BE86C0018 for <linux-mm@kvack.org>; Wed, 11 Sep 2024 06:46:15 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=iapW7k+N; spf=pass (imf28.hostedemail.com: domain of feng.tang@intel.com designates 198.175.65.12 as permitted sender) smtp.mailfrom=feng.tang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726037072; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Zm6mEmpihmiTwCFfdHniUQp/gJG3DwrB6e0k4OJohiA=; b=fgtjbxUvAAsoHm5FIxUHbgnO+7fPLBIryvfWk/4xRiMXRDp2WJXnEKODBvW6jH3mr8317j RV516wm6VbQSl6ANGhO7QjE9NjPfkZst5eqqvCbKcjIJE9lDs6WYYM75DeH8rsfX3+etry 6ALrb603KapNyWtnHGBjDtC9YMJ2rFY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726037072; a=rsa-sha256; cv=none; b=N4xURwmtcZtfQpwVwx/y8mS6jRYMEjKinThHjeU5hkY8A0+CjmeH91UqRYTLbnhGN206HK lijTkSrTMLdlYA0/IG6yfiQLL1C1PJv4liVtaCgYsbs+8dUYgKQPHLh0r4KvEzJGerxe3P 0r3kzr0SF/VGbQylkWyr0X9v59xoi3U= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=iapW7k+N; spf=pass (imf28.hostedemail.com: domain of feng.tang@intel.com designates 198.175.65.12 as permitted sender) smtp.mailfrom=feng.tang@intel.com; dmarc=pass (policy=none) header.from=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1726037176; x=1757573176; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Q3PpnMMnKbBe2tGhLr5Y8UQvjMtp65YK3pg5VOQk5Ag=; b=iapW7k+NttK2SdMtxvvZRzfXJ/Q4aRYStPnEDULrkcsgq8deXBQikc9Z Q10Cr+nvFpfSKurkBdL096JQ4ecz+2Lgd1DT20W6TSjkJzvEtoink+0HF LgDMH1ynq/wYzPPoD3C3UXTVpo0CAM/E1KopSVc2O/8MXfC38Nm5yipEd Vbtjr10EfPSjGep2UvEYd4BNVW66LoMn79hsqXTqag7Huvv/nGX2TjOh8 1F+uYOPAw06GMTqlFM3OEbPA+BDGQlXFZpB5wPk6syCIma7BCfQYmEYot nYK9IBSMCSxdr8iuQboZErDRjY8WEYkHQj/Lfo/lTE8Rso1Y08nJu+/qL Q==; X-CSE-ConnectionGUID: GZ7Pal1/Qr+Vbki9wkTEAw== X-CSE-MsgGUID: xZ1okREvRiqilOGubE59GQ== X-IronPort-AV: E=McAfee;i="6700,10204,11191"; a="36173005" X-IronPort-AV: E=Sophos;i="6.10,219,1719903600"; d="scan'208";a="36173005" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Sep 2024 23:46:00 -0700 X-CSE-ConnectionGUID: TlC0q2XjRdmz/RXKu5H2YA== X-CSE-MsgGUID: ouEYEDaZRMK+unGJAsKkGQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,219,1719903600"; d="scan'208";a="67771491" Received: from feng-clx.sh.intel.com ([10.239.159.50]) by orviesa007.jf.intel.com with ESMTP; 10 Sep 2024 23:45:50 -0700 From: Feng Tang <feng.tang@intel.com> To: Vlastimil Babka <vbabka@suse.cz>, Andrew Morton <akpm@linux-foundation.org>, Christoph Lameter <cl@linux.com>, Pekka Enberg <penberg@kernel.org>, David Rientjes <rientjes@google.com>, Joonsoo Kim <iamjoonsoo.kim@lge.com>, Roman Gushchin <roman.gushchin@linux.dev>, Hyeonggon Yoo <42.hyeyoo@gmail.com>, Andrey Konovalov <andreyknvl@gmail.com>, Marco Elver <elver@google.com>, Shuah Khan <skhan@linuxfoundation.org>, David Gow <davidgow@google.com>, Danilo Krummrich <dakr@kernel.org>, Alexander Potapenko <glider@google.com>, Andrey Ryabinin <ryabinin.a.a@gmail.com>, Dmitry Vyukov <dvyukov@google.com>, Vincenzo Frascino <vincenzo.frascino@arm.com> Cc: linux-mm@kvack.org, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, Feng Tang <feng.tang@intel.com> Subject: [PATCH v2 2/5] mm/slub: Consider kfence case for get_orig_size() Date: Wed, 11 Sep 2024 14:45:32 +0800 Message-Id: <20240911064535.557650-3-feng.tang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240911064535.557650-1-feng.tang@intel.com> References: <20240911064535.557650-1-feng.tang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Stat-Signature: x4w8tu96ewnmatan5qziqc3fkwqy6t7f X-Rspamd-Queue-Id: 2BE86C0018 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1726037175-566057 X-HE-Meta: U2FsdGVkX1+N05G0jR+gRs4WXynk+BhjRjnk+4im1VFzAUAdqgVjj3jVs4N5LPflnlnzHTXcDUPHd/hjmvl0sb4MxiZvIjDYewrppjchfuugSytLZOMLIaUrqBFSVk3xPRi/jP1s3QEsDB9aKRuUBvQp5VXb97NIfVMa3C+DTu4WkqlbGZhQXUtVeWFARrjqTCsdZARWcmB8SDdGwAve+Cy//eZDfhjxBPxNFckDNqx6efFWiH1+LQwdV5ec25i+NlC95DZQwv7nelan7zno0nCZfThOls6m8fWJoWabYQfb7SYmvPi0pFox0gb1jeR7xA2tAUupmY43pvxOB0vK37+tB8WwVZkCSRqMT1HAImhB2Zks1nqDD89InyROiaskKr6Xn02V+YGlahpp0M9wbz1msOdTVLWS7XYWmaVKQu5dRD+P64hy9i5Y4ayJFU+mQQrBInQGGL0h+/IHItETnJ1fhcqy6Y+3IcR8agTwNfY7tPQVvQkEFI9QVpByPzvNhrvsS+qRPA4aHYMp7Uq23izCQTAGfrM4ztEnDz1ZVgw8ybFiPPqhs9ra0QPgMCZfx9ke6YiSmlpkCqau8OY+wsJ//PCoXULfKoOtcey1GsMgRi8z5uZGCuupuxEhBBTE3AC8wHDYFd4GdeAaXG7d6/ocLAl6dJfwUPTmWUqEdQKU9lhu0fYpRZSZ0A0g3kiTPdPEPhEn6pBQ58XRv/rb7eue6J/LjzXz2y86BINHFd+ZClnSQDxQkezEXtnx4RTcjs4LM5RXo9PMxr3lOa+gee3usyW3j9XT89k/ax0BwRe0beZR5BQulQBEqO7/OgKrQ51cwB8l9zf47i6wIEzn3KgaQNowRKX6TWXg19lV6oV3WetNiAaV70i92qUwT9xiP9SkJyXM7Y1Ctyr98iSG2ZomXWvQHVBMlE0kvHPtmfmVEiM3Z2yVT8S+fgnJuOK2EOSUqpMNX7GTkDwsEob D7o7pSbI WZ+fz6Zf/sj+BuS3OCK5sa5XNX460wqH5hdh0RwcT5Rb0LlF3E4iIo/ROXYD9IpKK3q94dhisi6GusiwBHFhNdlWHn9n6PCS/EpVRbiiUOZ1ivGThIurUrNcPlg7pLOmlRRIO2IzrjRwsSBx12dL/+XlrjvYnf+rD0ICVBIHDq631Uu4/Rtv8R2M0+VihezwtXE7G2LbF5yowq7cv40upmpTs93lZ4wbLscDDvzQxpMEucJtDO/Zn3FZL77v1aoeO9kgNJJ0MmizOGnwnFo1Wxu5ymOchl+08pMDerJ/9yPRTuQ4= 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
mm/slub: Improve data handling of krealloc() when orig_size is enabled
|
expand
|
diff --git a/mm/slub.c b/mm/slub.c index 87c95f170f13..021991e17287 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -768,7 +768,7 @@ static inline unsigned int get_orig_size(struct kmem_cache *s, void *object) { void *p = kasan_reset_tag(object); - if (!slub_debug_orig_size(s)) + if (!slub_debug_orig_size(s) || is_kfence_address(object)) return s->object_size; p += get_info_end(s);
When 'orig_size' of kmalloc object is enabled by debug option, it should either contains the actual requested size or the cache's 'object_size'. But it's not true if that object is a kfence-allocated one, and its 'orig_size' in metadata could be zero or other values. This is not a big issue for current 'orig_size' usage, as init_object() and check_object() during alloc/free process will be skipped for kfence addresses. As 'orig_size' will be used by some function block like krealloc(), handle it by returning the 'object_size' in get_orig_size() for kfence addresses. Signed-off-by: Feng Tang <feng.tang@intel.com> --- mm/slub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)