Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2678957rwb; Sat, 8 Oct 2022 12:08:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6XNJyP0I7WqLGNa/Lsq3Inn/njAtl0SYt0SRuJToF01pGpAcDntgNvIy7Z7sgqS2M3MF3O X-Received: by 2002:a17:907:8a09:b0:78d:3863:a98d with SMTP id sc9-20020a1709078a0900b0078d3863a98dmr8696249ejc.538.1665256099474; Sat, 08 Oct 2022 12:08:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665256099; cv=none; d=google.com; s=arc-20160816; b=01X13kYtuZpKTitZuLrTFJbejv41hhJI5AYA8kO7tWbYXkFpHUdC9Se8Xpq6/esXUB mnhK+paEViArBcL+w7QVi12cbdIBi7S94VABVY3KAw5PvOgadn+T5Ozjzh3gMiQC0cVL 6TVhHu+gr5BTCWtXt0EtqrnkBegNFPR6JT3AtVoUmy2yGcbLuXkjN1T3aWsFHLRko6KC EpV1F6ac/jZJ8lKhg+2Rr+a+d4m0QlSC1VryWRVgZeIbgFkWjkHEGshQVdkVIXx+oa7V 5a1YDs2iSUg2GjGLXKTq8UVkXeEDFLMT0IDIfyyI0EWWOGY/aPdw/9tBLuVq1PGlEfhE GAiA== 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=GKva1pFsfuqgoIJb+srIILrjXqoJtPS42tfHzEkNmrc=; b=gLMCQrwFv5bHjidkzxyzzzhXqAFsJ+OB8gc4fNt+pd00++4M5boGBQKQtKuY9OmJSd fOkjOwVashICfrROIMA9DfURicdY4ktkJr1bGJVvLbFOWif5jvKqmbC9DXyQGPP57lE7 IfRExMApE1qjoXnxfWi47IvtOucoO78TeVvPZELhOmtUJYoncwoS812fINmhceUl671r ZUVDBjtExv1LHBu0a89ZnpMniXLTJlDGbw5twJf/nucZdC+cCheu4JW+VtBrkzMxEkS8 Y/ig9pvT9uswOIu1ld1Z7VtOvdyF08iCf+kRQjb0iS+v4fRVOt0PpMogVflRBl/Lu98T cYYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CekR7HaU; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-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 v5-20020a056402348500b00458cf31627bsi5243382edc.266.2022.10.08.12.07.46; Sat, 08 Oct 2022 12:08:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=CekR7HaU; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-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 S229732AbiJHTF4 (ORCPT + 99 others); Sat, 8 Oct 2022 15:05:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbiJHTFz (ORCPT ); Sat, 8 Oct 2022 15:05:55 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC59B37404 for ; Sat, 8 Oct 2022 12:05:53 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id b15so6893792pje.1 for ; Sat, 08 Oct 2022 12:05:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; 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=GKva1pFsfuqgoIJb+srIILrjXqoJtPS42tfHzEkNmrc=; b=CekR7HaUaBPxfQ7jIF3CdVMYLrp3EIW/Nv4aOnq6ugjdifExc4l1670DEpXlb7J1el oTum84aSYvNN3vIOC+8qPw8+axphBiFvfIX4G8Wnwci1VPuVg+K6YN/tBUPzybMIKnhk z+p3AilNoTy9XqurCjJBK/3g5vTiI0NOEMjoE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=GKva1pFsfuqgoIJb+srIILrjXqoJtPS42tfHzEkNmrc=; b=WzD4bRKDe2MxwvVVWDsGGsC3sD7C5gZCvaDAByR12iEEJhun+vpcdJ332mTmKrfSGw n5cyZoS3bwUlKmUwuTm2yj+F3Ws5AXgWGpJ8I1sojbEkpW37+WEmR5voarjtr4AQ8gah tXCkGNz1+58Z5fsNT4P/O7K+0LDVt7DFB/DDJaHajEfDz0185fCFV12Aln/6kCxT++ja 5Do9msMRJJbwEXo7MGFPR+b5Qk5hERp4SfxUGZDyjDyJED09LE+90XhxR9yj5ihHg5FA d68ePJQewFNxQFyly520YrtKPZoFwxIRXd7GCERSnrbtZUEXoObdFCnV5Fq9zig1fW4e dBqg== X-Gm-Message-State: ACrzQf3eGCSGTIm4zLQeAp+J1SyIAvKW2Hx8JalzJt+/+LA8DxMjRWzl vWmatkQpinR/6Fhe4V0RIHbE7Q== X-Received: by 2002:a17:902:ec89:b0:178:3ea4:2960 with SMTP id x9-20020a170902ec8900b001783ea42960mr11228973plg.160.1665255953317; Sat, 08 Oct 2022 12:05:53 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id b19-20020a170902d41300b001754cfb5e21sm3651784ple.96.2022.10.08.12.05.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Oct 2022 12:05:52 -0700 (PDT) Date: Sat, 8 Oct 2022 12:05:49 -0700 From: Kees Cook To: Chuck Lever III Cc: Jeff Layton , "Gustavo A . R . Silva" , Linux NFS Mailing List , Nathan Chancellor , Nick Desaulniers , Tom Rix , "linux-kernel@vger.kernel.org" , "llvm@lists.linux.dev" , "linux-hardening@vger.kernel.org" Subject: Re: [PATCH] NFSD: Avoid clashing function prototypes Message-ID: <202210081204.BE88541@keescook> References: <20221007235406.2951724-1-keescook@chromium.org> <7AC81CF2-2D64-452D-83FC-33E5BEA82209@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7AC81CF2-2D64-452D-83FC-33E5BEA82209@oracle.com> 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_NONE, SPF_HELO_NONE,SPF_PASS 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-nfs@vger.kernel.org On Sat, Oct 08, 2022 at 03:49:45PM +0000, Chuck Lever III wrote: > > On Oct 7, 2022, at 7:54 PM, Kees Cook wrote: > > > > When built with Control Flow Integrity, function prototypes between > > caller and function declaration must match. These mismatches are visible > > at compile time with the new -Wcast-function-type-strict in Clang[1]. > > > > There were 97 warnings produced by NFS. For example: > > > > fs/nfsd/nfs4xdr.c:2228:17: warning: cast from '__be32 (*)(struct nfsd4_compoundargs *, struct nfsd4_access *)' (aka 'unsigned int (*)(struct nfsd4_compoundargs *, struct nfsd4_access *)') to 'nfsd4_dec' (aka 'unsigned int (*)(struct nfsd4_compoundargs *, void *)') converts to incompatible function type [-Wcast-function-type-strict] > > [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access, > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > The enc/dec callbacks were defined as passing "void *" as the second > > argument, but were being implicitly cast to a new type. Replace the > > argument with a variable the desired to perform the casting in the > > function body. There are no resulting binary differences. > > Hi Kees, thanks for the patch. I agree this internal API could be > cleaner and more type-safe. A few things I noticed: > > - Your patch does not apply to HEAD probably because it conflicts with > 3fdc54646234 ("NFSD: Reduce amount of struct nfsd4_compoundargs that > needs clearing") Ah! Thanks, I will refresh. > - A union type might be a better fit for this application, as that > would avoid casting through an anonymous pointer. NFSD has a union > type, union nfsd4_op_u, that is ideal for this. Perfect, yes. There are similar conversions that used similar. > Would it make sense to use "union nfsd4_op_u *", such as is done in > fs/nfsd/current_stateid.h, in the definition of nfsd4_dec and nfsd4_enc ? Yup; I think that'll be perfect. > With regard to timing, I would prefer to queue this change for the > v6.2 merge window through the nfsd tree, if that's OK with you? Yeah, for sure. No rush. :) -- Kees Cook