Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36917055rwd; Tue, 11 Jul 2023 07:17:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlGOZ++oUazOjsY5JrkkZRkBu7HzY/cMFBt+h6pfQDxeX0aYtry5XP85cUacd9Erhn5D3gXt X-Received: by 2002:a17:906:2319:b0:98e:1a0c:12c0 with SMTP id l25-20020a170906231900b0098e1a0c12c0mr18485689eja.7.1689085038626; Tue, 11 Jul 2023 07:17:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689085038; cv=none; d=google.com; s=arc-20160816; b=VM/FJY5EQde4mWGmIyoDG3ADLHjRpJ+oOCGwADtYa+9H9+KX35eM8fGIEm80eBB0VT +OWvRDRHEgnzUcERC1eofnuayFn9H4BYcbZXoPArYLf/noKAvLFpbDkFP4zDtc6vE59D 8VWAHY7242jaYaJaZoEoYJ204ikpB3W8H2gSaAyi7ojYPH4dw55EjPydi8xnqid8mP/2 jl0EjEsFf3pJFYdfdyNxsTwEmVjvnRl5bmJ6rKcqbIu45ASBEblB3ctC7tCf9pYS3B7E 8J1RSWi5gYyNwlkTwoNfnwd5s/LvtS1r8fZwa421DeeVpgW09w5HDzizS/zwNxQW107D BRXA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=tmUBux5e1ki7qsINZJpfH2z48bDyzUotuR1CpySUCaQ=; fh=5wkMzutboah3mIJLA2vngQ+rKosaYb0XpIOjNELWSA0=; b=ijEfSnzlOhkShrLG8iHHiNfky5PchxM/sO20gco9oausgybXGsNDDSZEu8bxvXGj/p WJWEDNKzijShA9ua7pTmwigyJQgJqCCqic8BAn1gOTk1MGiyOpoKOPV8i4oQIfJ9aubq 1gsgjazMWN0VMXosQ0COMlssT4iFb2NU8EBQesB/Cv/QJj+J/hwUxIst2QT+Gx5Vk1/l TrN0oSIECxiB2WIYeMBSUpMeB7xXLtCw9EEB8LtYhzg+S53cZHQ22KAdufoDLdEydPe3 /Y1fgjJ6MIBDXuVFgvjJEG7/i5H0NRZs/LVHd9WIfw2i5AJHb5WSzNqjGq66PL1UUIWz 2hfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=acou4bQD; dkim=neutral (no key) header.i=@suse.cz; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ja12-20020a170907988c00b00992a8a54f2fsi2244522ejc.368.2023.07.11.07.16.53; Tue, 11 Jul 2023 07:17:18 -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=@suse.cz header.s=susede2_rsa header.b=acou4bQD; dkim=neutral (no key) header.i=@suse.cz; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232960AbjGKNqp (ORCPT + 99 others); Tue, 11 Jul 2023 09:46:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232487AbjGKNqj (ORCPT ); Tue, 11 Jul 2023 09:46:39 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8C6610C7; Tue, 11 Jul 2023 06:46:36 -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 4C55622194; Tue, 11 Jul 2023 13:46:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1689083195; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tmUBux5e1ki7qsINZJpfH2z48bDyzUotuR1CpySUCaQ=; b=acou4bQDVy0hM/ezQGCbnhuyyCV9OLbnLgbSiZoPMwqDjzfAzSHDOEQJjm6aYd3JfDHlVj r0Fjy37Mqysf4/J2PoT1S7cvQ9QWZfg748Z2/30rFo/RHgBkBJZci40fZkmnVpjUCqi2ny KmklcGac+XrfSY+ck1hbZkSPX3VBgyY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1689083195; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tmUBux5e1ki7qsINZJpfH2z48bDyzUotuR1CpySUCaQ=; b=Zi00M2H/+Fsp5apSaRxx6+D9RGOqEN/LSG9K6C5JqftooNT+gO4g1U1LZpCEJeqiKToo7C UbXejMpQOCshQ7Cw== 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 10FBB13A63; Tue, 11 Jul 2023 13:46:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iPqDAztdrWTSYwAAMHmgww (envelope-from ); Tue, 11 Jul 2023 13:46:35 +0000 From: Vlastimil Babka To: Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, Roman Gushchin , linux-mm@kvack.org, patches@lists.linux.dev, linux-kernel@vger.kernel.org, Matteo Rizzo , Jann Horn , Andrey Konovalov , Marco Elver , Alexander Potapenko , kasan-dev@googlegroups.com, Kees Cook , linux-hardening@vger.kernel.org, Vlastimil Babka Subject: [PATCH 2/2] mm/slub: remove freelist_dereference() Date: Tue, 11 Jul 2023 15:46:25 +0200 Message-ID: <20230711134623.12695-4-vbabka@suse.cz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711134623.12695-3-vbabka@suse.cz> References: <20230711134623.12695-3-vbabka@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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 freelist_dereference() is a one-liner only used from get_freepointer(). Remove it and make get_freepointer() call freelist_ptr_decode() directly to make the code easier to follow. Signed-off-by: Vlastimil Babka --- mm/slub.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 07edad305512..c4556a5dab4b 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -397,18 +397,14 @@ static inline void *freelist_ptr_decode(const struct kmem_cache *s, return decoded; } -/* Returns the freelist pointer recorded at location ptr_addr. */ -static inline void *freelist_dereference(const struct kmem_cache *s, - void *ptr_addr) -{ - return freelist_ptr_decode(s, *(freeptr_t *)(ptr_addr), - (unsigned long)ptr_addr); -} - static inline void *get_freepointer(struct kmem_cache *s, void *object) { - object = kasan_reset_tag(object); - return freelist_dereference(s, (freeptr_t *)(object + s->offset)); + unsigned long ptr_addr; + freeptr_t p; + + ptr_addr = ((unsigned long)kasan_reset_tag(object)) + s->offset; + p = *(freeptr_t *)(ptr_addr); + return freelist_ptr_decode(s, p, ptr_addr); } #ifndef CONFIG_SLUB_TINY -- 2.41.0