From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 A0FB9C433F5 for ; Fri, 8 Apr 2022 03:42:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 22E686B0071; Thu, 7 Apr 2022 23:42:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1DE006B0072; Thu, 7 Apr 2022 23:42:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07ED36B0074; Thu, 7 Apr 2022 23:42:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0129.hostedemail.com [216.40.44.129]) by kanga.kvack.org (Postfix) with ESMTP id EA2106B0071 for ; Thu, 7 Apr 2022 23:42:35 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id A20AC1845F851 for ; Fri, 8 Apr 2022 03:42:35 +0000 (UTC) X-FDA: 79332314670.31.CA8E644 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by imf17.hostedemail.com (Postfix) with ESMTP id 21C4240002 for ; Fri, 8 Apr 2022 03:42:34 +0000 (UTC) Received: by mail-pf1-f182.google.com with SMTP id a42so773655pfx.7 for ; Thu, 07 Apr 2022 20:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=K96mlN10n7EweDR+53jcFZAkfBQwRjsHeZeSVOaqH6U=; b=dL1emr/SVvDUitmI/GhFvZ5GDfJfCZqqybUK0jY5r9YpcwDEym86lGSPk5ajT9fkXv 68GItVAds/Z+CMKr5K6+nclMV48nPWohX7Qz2mbKGSdt22CtfWYhovUHU9eWOOIJxF/x TIwKpkgJMMkaKK6GQVnlphvoASG3ht7FbopB8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=K96mlN10n7EweDR+53jcFZAkfBQwRjsHeZeSVOaqH6U=; b=Vk9z4eqyJpQnFr6YZ97lFS30eRkzXbLKoy8qrcTQRQ8UQ0XAlAYHvWVqo/T0UAYqPr 8VcG/kBv87Mt2t3AaWaSq4YYIcPlJsZlpw68BTxVH0dL6m/0l9dHcc3Rr7abt/PF89fh 0UGIgII6WjU5qfSsxQxn+cq97NzBC8z2tE3egbkhBtVAX4MKHl2FUGmO9/6wafDP/QS8 fM22qjOCxlh/UUUJPMj5RPQV8wD9bzjMsh1CuR7wBIoSWFsp2Qo1m0iG51eMiqjaCqOB n/wiSLBHcHkNub23U0DLkVh13YRb7FmORSCa89pgiclfuja2fkuOcqR7UgTq+FYR1dm9 eYCw== X-Gm-Message-State: AOAM533zX5O0Yj5S8n/49v6U9vs0dDs/IoTI4k0c5wa5q7yBTmfHwIAV JT7Wt1O8MP0shEKqtyWBwUMi5w== X-Google-Smtp-Source: ABdhPJzs4BJvqoMUJeyjaJ1TeZcDIdeQX1b09zQG89u/2Jo2P8sjElQ6/UOvNErwvd9fdVv73z+YWw== X-Received: by 2002:a63:6c02:0:b0:398:833b:f739 with SMTP id h2-20020a636c02000000b00398833bf739mr14106439pgc.524.1649389353914; Thu, 07 Apr 2022 20:42:33 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id q27-20020aa7961b000000b004fdf7a4d49esm17171769pfg.170.2022.04.07.20.42.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 20:42:33 -0700 (PDT) Date: Thu, 7 Apr 2022 20:42:32 -0700 From: Kees Cook To: Christophe Leroy Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Andrew Morton , "James E.J. Bottomley" , Helge Deller , Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org Subject: Re: [RFC PATCH] lkdtm: Replace lkdtm_rodata_do_nothing() by do_nothing() Message-ID: <202204072037.FE91C45E@keescook> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: kgq1rfot8jbcspgjiihhywamc9efjr3i Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="dL1emr/S"; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf17.hostedemail.com: domain of keescook@chromium.org designates 209.85.210.182 as permitted sender) smtp.mailfrom=keescook@chromium.org X-Rspamd-Queue-Id: 21C4240002 X-HE-Tag: 1649389354-567942 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: On Sun, Oct 17, 2021 at 07:19:47PM +0200, Christophe Leroy wrote: > But for EXEC_RODATA test, execute_location() uses > lkdtm_rodata_do_nothing() which is already in rodata section > at build time instead of using a copy of do_nothing(). However > it still uses the function descriptor of do_nothing(). There > is a risk that running lkdtm_rodata_do_nothing() with the > function descriptor of do_thing() is wrong. Wrong how? (Could there be two descriptors?) > To remove the above risk, change the approach and do the same > as for other EXEC tests: use a copy of do_nothing(). The copy > cannot be done during the test because RODATA area is write > protected. Do the copy during init, before RODATA becomes > write protected. Hmm, hmm. This is a nice way to handle it, but I'm not sure which "weird" way is better. I kind of prefer the code going through all the "regular" linking goo to end up in .rodata, but is it really any different from doing this via the ro_after_init section? It makes me nervous because they can technically be handled differently. For example, .rodata is mapped differently on some architectures compared to ro_after_init. Honestly, I actually this this patch should be modified to _add_ a new test for EXEC_RO_AFTER_INIT, and leave the existing .rodata one alone... -Kees -- Kees Cook