Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2617233pxb; Sun, 17 Oct 2021 20:38:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLi8TSwN2W5oIEXx6W9ljfn/DzZVbGY4v/bKPGleKFUHWP6bIi1DFR4oNKZKzutywhBLaR X-Received: by 2002:a17:90b:1c92:: with SMTP id oo18mr44556764pjb.56.1634528324254; Sun, 17 Oct 2021 20:38:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634528324; cv=none; d=google.com; s=arc-20160816; b=rXfRiCXlkqD18PP3AMacmJStocG/svwf/APaJUiveA/hHkeL0LZCc/qO1fMiexgct3 2O7Npoo5W5PHZ3cbVnwUa4LInf53mFPUzSn2qdN0rHPwThOeM2uokSlk6LIvyukIrjA7 9zqOQNnGkzcyY/ussnlhF58l61mQXTIvWIv+3Pp6mi/JI5LsVdVd9FEYfGtmmJvPPlzg kZ3++QWVERjf6lxh/8CmjGtQyatoJ/XeKJ/XMGmI/F9VlUGy25x77ycwljA2vy3T5j12 4yupBH75UGGOYGE6j6BKStX7d7JBfjXzE7Lldnnos6czpK9byjmqCzcbdX+56HaFf3fS oZUQ== 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=NjDNk6B/N6Q1irkDiWN3RyxwNrYWGdj8hgHHx1uvt14=; b=GNfhemES/l23BIw1BeFcHRoec/mvoxlP5z2+CYX6cMeJPCgVTGy+WlN39WGtM3pKKm KNBy8gMYKezJO3MH8C81iexEMct8LEsko3doC6vWkhUrDLVET0fBqyOHChkbxtRgVIsi FruBPAswdGb5IS7/cRxbiHu79ceqnMG1cXcCo73yIUEFzoIOY/qBSS8Kxt8b5qL0Galv EWjKvAgQ9aKYVzw3fALDEF+1MtWiel32x/US1zalav35Mnj35Y2vpOH9UNYhB/WLdH8f /X7ErS5T+O2En/kGVTcNNN0o8lLKyO1hSl+7qJsE0PqgQMLjYXNPGwF7lCGL0QjFf07H 7RcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BuXiPspP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a2si6720942pls.44.2021.10.17.20.38.31; Sun, 17 Oct 2021 20:38:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BuXiPspP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244652AbhJPVOQ (ORCPT + 98 others); Sat, 16 Oct 2021 17:14:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60327 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244651AbhJPVOP (ORCPT ); Sat, 16 Oct 2021 17:14:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634418726; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=NjDNk6B/N6Q1irkDiWN3RyxwNrYWGdj8hgHHx1uvt14=; b=BuXiPspPwsAMdcZs2o7EHp8y5M1CGBolb0e+l8k7e3E/MJBgR7wBur5BIf3ddENmynWv0P LyagOhsnQuB2aUOvFXGQmLcOj19w37FWKcpSwkmwBTnU7VXrjhPqwJAek18DVX8p7188P1 X0bWTPglFbDDWUG30Pem6g1b1cNjgtw= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-447-dgT7VyewOyCb-QNUdRBXww-1; Sat, 16 Oct 2021 17:12:05 -0400 X-MC-Unique: dgT7VyewOyCb-QNUdRBXww-1 Received: by mail-qk1-f197.google.com with SMTP id e22-20020a05620a209600b0045f81b8f89cso9281593qka.5 for ; Sat, 16 Oct 2021 14:12:05 -0700 (PDT) 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=NjDNk6B/N6Q1irkDiWN3RyxwNrYWGdj8hgHHx1uvt14=; b=ooZp3wEwgqZibULWRAqdLnxzP/8gkPIN1OCQIOxdzX/YXfGGkxHD6y3PYOfNvp7fa7 gvTVDOOvb6imOwBb0ScNitlQvhHk0eukn1Dj506qm10qJTescsucLS4MR/QymWzg0P2d uol3xXGqx//grkY0LQRK/13m369lMFv1DyNdK84lIxmUImLBEsNvcBH3KnPHZF3iuN8r WyjfcOxfhJovctwHWcsIQMQ/Ykb7e6mGS2cj6r76dy4b0POoDLOAGQSCyT+lDxyh0TpF PHS/A9bFs15F4GHPQ1Gxvrm2rMD0uWduReB1PbgWYMkk8hHoAjqY8rwke8wOXcffCEH/ +EZg== X-Gm-Message-State: AOAM532FOgXCXOh9m6UWZTsaZD+JLx1TG7agnP8TxOXyDrnpU8eWFl7f pdMCs8ems28hqInsVhm3R3pW8tNTmpfNBMOee4hICfORGiaVFSDxjJB5smlZYEVOEv9fiBP42Im +NwG2FzBDXIRjqi4X8OQMNtCJ X-Received: by 2002:ac8:5a96:: with SMTP id c22mr22223717qtc.266.1634418724704; Sat, 16 Oct 2021 14:12:04 -0700 (PDT) X-Received: by 2002:ac8:5a96:: with SMTP id c22mr22223703qtc.266.1634418724447; Sat, 16 Oct 2021 14:12:04 -0700 (PDT) Received: from treble ([2600:1700:6e32:6c00::15]) by smtp.gmail.com with ESMTPSA id z186sm4435014qke.59.2021.10.16.14.12.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Oct 2021 14:12:03 -0700 (PDT) Date: Sat, 16 Oct 2021 14:12:00 -0700 From: Josh Poimboeuf To: Sami Tolvanen Cc: Andy Lutomirski , Thomas Gleixner , the arch/x86 maintainers , Kees Cook , "Peter Zijlstra (Intel)" , Nathan Chancellor , Nick Desaulniers , Sedat Dilek , Steven Rostedt , linux-hardening@vger.kernel.org, Linux Kernel Mailing List , llvm@lists.linux.dev Subject: Re: [PATCH v5 03/15] linkage: Add DECLARE_NOT_CALLED_FROM_C Message-ID: <20211016211200.umf7okyvtet5ayrd@treble> References: <20211013181658.1020262-1-samitolvanen@google.com> <20211013181658.1020262-4-samitolvanen@google.com> <7377e6b9-7130-4c20-a0c8-16de4620c995@www.fastmail.com> <8735p25llh.ffs@tglx> <87zgra41dh.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 15, 2021 at 01:37:02PM -0700, Sami Tolvanen wrote: > > But we *also* have the read-the-address thing: > > > > void something(void) > > { > > /* actual C body */ > > } > > alternative_call(something, someotherthing, ...); > > > > That wants to expand to assembly code that does: > > > > CALL [target] > > > > where [target] is the actual first instruction of real code and not > > a CFI prologue. > > Yes, here we would ideally want to avoid the CFI stub for better > performance, but nothing actually breaks even if we don't. That's because there's no CFI involved in alternative_call(). It doesn't use function pointers. It uses direct calls. So all the discussion about clear_page_*() is completely irrelevant. It has nothing to do with CFI. Same for copy_user_enhanced_fast_string() and friends. > > And this all wants to work both for asm-defined functions and > > C-defined functions. This really is orthogonal to the > > is-it-asm-or-is-it-C things. All four combinations are possible. > > > > Does this make any sense? Not really, I think Sami debunked most of your theories :-) I think you're misunderstanding how Clang CFI works. It doesn't instrument the target function. It hooks into the caller's function pointer relocation, so when I try to call func_ptr(), the compiler hijacks the function pointer and forces me to call into a func_ptr.cfi_jt() checking function instead. > > I kind of thing we want the attributes and the builtin, along the lines of: > > > > asm("call %m", function_nocfi_address(something)); > > > > or however else we wire it up. > > > > (And, of course, the things that aren't C functions at all, like > > exception entries, should be opaque.) > > I agree, there are cases where having a function attribute and/or a > built-in to stop the compiler from interfering would be useful. I'll > dust off my patch series and see how the LLVM folks feel about it. With all the talk about function attributes I still haven't heard a clear and specific case where one is needed. If you take out the things that don't actually need the DEFINE_NOT_CALLED_FROM_C() annotation then all you have left is the need for opaque structs as far as I can tell. -- Josh