Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp805166rwp; Thu, 13 Jul 2023 00:59:13 -0700 (PDT) X-Google-Smtp-Source: APBJJlGIlMibryB+5UC0urMjhsUecJxaY9yEMw9tiVFs3RipIpDXCBR0edZe4ka5ihnv/Mq0ftBe X-Received: by 2002:a17:902:b18f:b0:1b8:9044:b8ae with SMTP id s15-20020a170902b18f00b001b89044b8aemr385124plr.11.1689235153341; Thu, 13 Jul 2023 00:59:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689235153; cv=none; d=google.com; s=arc-20160816; b=lVWkAyp0C7XYzAKNS2xXvds16kbYSvC8Guvns/84xYqbU1SMpWatK7MP0ouHLxySpW Hj43xaxF0M30VAV1yaDCznw7AfGoEPQcEhiY0dhEraeb5KQYofuHhwXQ976zwIdVroyC x606nC4BhR3NXtxUaqBDuC2jOo0Bop0CwsLWnk4EUu/iEvQ/IcNar4oh1sfNpdfHFNpC pVlcSrTOGMg8pp8RkGmAnESH260jSCeeEX5GTUDZnCuQGwCHR1L8NVOujiGVjWYNoK4X dBJ5Ds+pe1nbLEz7/nI9XT8gNoqtrheTZaVxiPaD5g2tHeiNGD17s7xnolbkSjSGVGds zi4g== 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=DKzxp2+bTU0RvBuftCWUrTE4tMrCxaPuXQY51bUYZiM=; fh=PPWkH+iUfuDwOmlGGtHQPuvY83dV6tgEN0MbVWy+fBg=; b=AzG7wWoYuXIfPZr6LlBcCphevYGlwMCqaoE0EkHxzX9oPHUBaf1MfiJUVHG9NXmZuK WgnLPpYQUTDAV/iRqArlXMHTR8gdJDqYDCgyyiKXBjsVJ0OvJXHijqo0KJOxqMAVBMZ/ xwfhYM13UmRAtMyEl/pNxJwDed8P/HclPKKT1sbE3Ailm2DzFy5mVyaQxHtpHZqSk4/F BcnOeAW1sXUHA0bHg8Uy46/cquDq42BsM7msoavUF97LVml20qK8eby9iRo1bRUAQOfX wu63Dj0nDixqZ9rfjjVTajGt8zycyWK8+JnssORu89myovgSG949TPdaFW8to1h44UuQ tmpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=zBJPqBqy; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=q44zqzJx; 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 p9-20020a170902b08900b001b8b32c5e38si4627408plr.263.2023.07.13.00.59.00; Thu, 13 Jul 2023 00:59:13 -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=zBJPqBqy; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=q44zqzJx; 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 S232342AbjGMHpD (ORCPT + 99 others); Thu, 13 Jul 2023 03:45:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232314AbjGMHo4 (ORCPT ); Thu, 13 Jul 2023 03:44:56 -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 1E3772108; Thu, 13 Jul 2023 00:44:54 -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 D125721E4E; Thu, 13 Jul 2023 07:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1689234292; 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=DKzxp2+bTU0RvBuftCWUrTE4tMrCxaPuXQY51bUYZiM=; b=zBJPqBqyxXjNscb7x/Yf/G4VtsLZ2NVhZG6IOxIVFS2DV/CkumU6+dj1ybx+k18ptW/r0h 3wdAvlJ756/G9Ttcd7jXZWm/faXYgWkwvM5IACm8g3Q/t246HeEn1sXUpyCrRa8DRTwQYa q+FyXURvjRvUhRXVGzxSaTv/ymYx9yU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1689234292; 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=DKzxp2+bTU0RvBuftCWUrTE4tMrCxaPuXQY51bUYZiM=; b=q44zqzJx+W+qYfd2okwpXCikpwguziJByksUibC8w5/+2ZQX8A1uC0ue1FNPt7jspHm0/4 YKLWP+UZHuD8x2Bg== 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 8C6BA133D6; Thu, 13 Jul 2023 07:44:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 9qF4IXSrr2QVFgAAMHmgww (envelope-from ); Thu, 13 Jul 2023 07:44:52 +0000 Message-ID: Date: Thu, 13 Jul 2023 09:44:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH 2/2] mm/slub: remove freelist_dereference() Content-Language: en-US To: Kees Cook Cc: Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim , 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, linux-hardening@vger.kernel.org References: <20230711134623.12695-3-vbabka@suse.cz> <20230711134623.12695-4-vbabka@suse.cz> <202307110917.DEED145F0@keescook> From: Vlastimil Babka In-Reply-To: <202307110917.DEED145F0@keescook> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.8 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_SOFTFAIL,T_SCC_BODY_TEXT_LINE 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 On 7/11/23 18:21, Kees Cook wrote: > On Tue, Jul 11, 2023 at 03:46:25PM +0200, Vlastimil Babka wrote: >> >> #ifndef CONFIG_SLUB_TINY >> -- >> 2.41.0 >> > > I like reducing the complexity here, but I find dropping the "object" > reassignment makes this a bit harder to read. What about: Alright. > object = kasan_reset_tag(object); > unsigned long ptr_addr = (unsigned long)object + s->offset; > freeptr_t p = *(freeptr_t *)(ptr_addr); Are we really so benevolent with declaration-after-statement now? :) > return freelist_ptr_decode(s, p, ptr_addr); > > ? > > They're the same result, so either way: > > Acked-by: Kees Cook >