Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp37097440rwd; Tue, 11 Jul 2023 09:22:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlGf1WqhML3ZtsKU4EDLJBws7yY7pF7g8mhHK233bPof6N4q1OhdImWoRQ40V7T7wfiQnzzK X-Received: by 2002:a05:6a20:81:b0:110:f65a:13d7 with SMTP id 1-20020a056a20008100b00110f65a13d7mr11046613pzg.9.1689092531885; Tue, 11 Jul 2023 09:22:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689092531; cv=none; d=google.com; s=arc-20160816; b=Gas+n3Zjno4EV7ZQaWhvrOCDxuyVPofFP3f10MFtvMUvxZ49ObFDqziJYcdDLOMyjd QJHrcBQnvA1eZk7dGOr5PLZ0oq0I1qRsJ4ZCCMxvYREnAtlCve08FFIsjA6PKbA7cIld lnGhIwQLh37ao+MpKuVrlyXqOXvKUDHHNIUTWpJemaTmAz/E+4b4yWcCmWj9TX5P+8QX w7hF3tPPzgpLFsc6kz6gSjSWHO29Eq4ZkGjyqOO3fK9zxJn1xKZXeM1+uwlKin6q34FW vLGhQ5RR8vLsWE6xAfhr9R7iJiIEPT+o7x8mIe0mt6cy7R2PT9AMlOASxsPKob69bFw5 tIkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vq9YViWYg4uFChvJGSLE3j7fYiOn1S8zzbS7MgZUOXM=; fh=uVhf7W460rgBYDoMEVmAaCiCt78MDctxX7/FHURrW1A=; b=JTBR8HX1GK7JtWBPyKlNjQskXTv7phsRfrYSgA1ir2Tle+HoUybzGfQ2UpwKa/vElY 4sQLcovBz4vA6CSPMw6qt6/LKxJ7aYGvf5KrIHE2SENbpVPyZbNoi1moxUxycYjTNUuL JHgundlsxTK3idR72zVDWN/GxbEk0N2ANywsILUfH3k2J22nrM1DuuGrRlZ7lQbL0i86 vuTRHh4oduQG9FkZrDfH/LKDlprxPekGzmFxvVLJu1dNSc/73IMdT6vaKgBU6az4Z8tn Kp7XarMp6CllzEleG2OOkb9GGfpu0mUD6EmcF4gj5uyMHnbWB9r+JVxsZ0bmbIGiZRcN cWCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JnU40aqX; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ct8-20020a056a000f8800b00682399fa4f9si1717462pfb.300.2023.07.11.09.21.59; Tue, 11 Jul 2023 09:22:11 -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=@chromium.org header.s=google header.b=JnU40aqX; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230239AbjGKQOx (ORCPT + 99 others); Tue, 11 Jul 2023 12:14:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229637AbjGKQOw (ORCPT ); Tue, 11 Jul 2023 12:14:52 -0400 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 626B9E60 for ; Tue, 11 Jul 2023 09:14:51 -0700 (PDT) Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3a36b309524so5100186b6e.3 for ; Tue, 11 Jul 2023 09:14:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689092090; x=1691684090; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=vq9YViWYg4uFChvJGSLE3j7fYiOn1S8zzbS7MgZUOXM=; b=JnU40aqXrl+cQXJk+/mWGhypL/UL4FW42fibfXNLp4FDHbP6XSKttylnrv712ddyCS QQiAkK4VyodEzrwPiYTOu3AnXnDvRdzb3zq1Eb9j/1HiZN1ZbrRv0XaTUkXjQRh/C60X aRnapaN/LqPA5iZkV1sZtWXCNBY011f1uE2TI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689092090; x=1691684090; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=vq9YViWYg4uFChvJGSLE3j7fYiOn1S8zzbS7MgZUOXM=; b=JZqKHmT2NzEEMPhwGVmJUyZQPf6iVwmAGAWO2rdJLA4pVIi1cM9DTsOFLzrngOW6/i laLm1zYcgoyEUssir7Yy97/Wpg3WbZxY9+LkrMzhlg6tIK4uQovXVPCVJF0shc1osIxb cte+zCWZnF9p2dB+MRxRhR6Q+WMklVQI9BSdGgvdJBD7KuJjHuXAOt7rn25Bd/Tin88G wxQjaS/x70Bs+NuMcfpXtqCGOqKtmfqbS5o8SYGmbRuTQjyTBS7YcSR52Mf+/xlxzqlE gTXAHf3x7+e/Tx6lKIdOhkSnLflY9IVbAm7/TRfBQgmX11UHOEwhvjNGCFZOm8iExSAV SJ/g== X-Gm-Message-State: ABy/qLZQOKcbT0rUvlWqVidQU2QHrCvDse+1MJHcFIm1fbtUNu749TJ4 RcQYi1HofL3UlFN9IElIvriFpg== X-Received: by 2002:a05:6358:290b:b0:134:e4c4:ebff with SMTP id y11-20020a056358290b00b00134e4c4ebffmr16820772rwb.11.1689092090568; Tue, 11 Jul 2023 09:14:50 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id c10-20020a63724a000000b0055386b1415dsm1802755pgn.51.2023.07.11.09.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jul 2023 09:14:49 -0700 (PDT) Date: Tue, 11 Jul 2023 09:14:49 -0700 From: Kees Cook To: Vlastimil Babka 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 Subject: Re: [PATCH 1/2] mm/slub: remove redundant kasan_reset_tag() from freelist_ptr calculations Message-ID: <202307110914.8D460C7@keescook> References: <20230711134623.12695-3-vbabka@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230711134623.12695-3-vbabka@suse.cz> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=unavailable 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 Tue, Jul 11, 2023 at 03:46:24PM +0200, Vlastimil Babka wrote: > Commit d36a63a943e3 ("kasan, slub: fix more conflicts with > CONFIG_SLAB_FREELIST_HARDENED") has introduced kasan_reset_tags() to > freelist_ptr() encoding/decoding when CONFIG_SLAB_FREELIST_HARDENED is > enabled to resolve issues when passing tagged or untagged pointers > inconsistently would lead to incorrect calculations. > > Later, commit aa1ef4d7b3f6 ("kasan, mm: reset tags when accessing > metadata") made sure all pointers have tags reset regardless of > CONFIG_SLAB_FREELIST_HARDENED, because there was no other way to access > the freepointer metadata safely with hw tag-based KASAN. > > Therefore the kasan_reset_tag() usage in freelist_ptr_encode()/decode() > is now redundant, as all callers use kasan_reset_tag() unconditionally > when constructing ptr_addr. Remove the redundant calls and simplify the > code and remove obsolete comments. > > Also in freelist_ptr_encode() introduce an 'encoded' variable to make > the lines shorter and make it similar to the _decode() one. > > Signed-off-by: Vlastimil Babka Thanks, this is much more readable! Acked-by: Kees Cook -- Kees Cook