Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1314164pxu; Thu, 8 Oct 2020 08:31:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgp7YSifDQzqAhNZXAQFniRVW0fCHDyZGyfTzu/nHB78i+hMWUobH9fUPEYcufugLKs8Yi X-Received: by 2002:a05:6402:1446:: with SMTP id d6mr9575153edx.244.1602171094797; Thu, 08 Oct 2020 08:31:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602171094; cv=none; d=google.com; s=arc-20160816; b=rekG3w6Bf5nkVnXGtXpAsl/JC46G7+nIar7zJVQy8vjSJt6QWbziJCcna8FMAGoyfq 4ssY2H+/hbzOtqSRwSKgAvBs7kgbJ1YB8ljegXYIQ0lLJ9qsujoIr0cSH76wwfgpFNBb xshhBk+pdjDZdvdJT22R+6xJ0Mhkzj5si05/URteGTRzSwR6GyM5/iK4kyL05ekVHEgM yLserK3BrhmXz28Dsawqh7sWCfkLmFbjfzwvWtLcz9DwUHYwZWgraabRmwrv++ZnaZFo /wv3k8qKNG4Yf/lK+MkFZG6Ergi5bzMhx1pIOouQWy5SQ8b0I5zQHDpZkZ9t301W7hUf 3ybg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:message-id:in-reply-to:subject:cc:to:from:date; bh=Xv0GgH3hIsV199GK6f8sg9VY5w12vjI8U+YUJvD39y4=; b=Z4dF+01H9LgnnSyi73W191ILUvSr0YdNw+AToFbdT5HqAWV287pkO09kTeEPWTgyZy M5x+bY+9gmi/O2+psH+dFonV+hlF8cSFAHXHgBNnWSKZPX6nPsPta1SuYbBSdd5pjoIF ZbODdoczBrFVJDmBK2PAZ6WQlZaGKXpMtM5wYubmkdFsJSfEGhbotJN+At3yYpfKYYYZ 3MKC8gWWuFI5fXWMn66QSngfdeBQ5jAE6hnd3ooh7Z2R68tpJjLJzP+wRIS5PqogJ82b Cbj+Lx5S6CEXvF3LFgRRwswPbnU2NKpBcj+toX0lBHkrk0LDR1yj30eTxghAFLXbPJ7E WX3g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r12si4001814edb.495.2020.10.08.08.31.10; Thu, 08 Oct 2020 08:31:34 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731053AbgJHP3c (ORCPT + 99 others); Thu, 8 Oct 2020 11:29:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730550AbgJHP3c (ORCPT ); Thu, 8 Oct 2020 11:29:32 -0400 X-Greylist: delayed 326 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 08 Oct 2020 08:29:31 PDT Received: from a3.inai.de (a3.inai.de [IPv6:2a01:4f8:10b:45d8::f5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1BEEC061755; Thu, 8 Oct 2020 08:29:31 -0700 (PDT) Received: by a3.inai.de (Postfix, from userid 25121) id E3B3358758003; Thu, 8 Oct 2020 17:24:03 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by a3.inai.de (Postfix) with ESMTP id DFDF360E1940A; Thu, 8 Oct 2020 17:24:03 +0200 (CEST) Date: Thu, 8 Oct 2020 17:24:03 +0200 (CEST) From: Jan Engelhardt To: Jason Gunthorpe cc: Nathan Chancellor , "Gustavo A. R. Silva" , Linus Torvalds , Kees Cook , Greg KH , Linux Kernel Mailing List , linux-rdma@vger.kernel.org, clang-built-linux@googlegroups.com Subject: Re: remaining flexible-array conversions In-Reply-To: <20200424121553.GE26002@ziepe.ca> Message-ID: <36r41qn8-87o3-2pr1-856p-040167pq097@vanv.qr> References: <6342c465-e34b-3e18-cc31-1d989926aebd@embeddedor.com> <20200424034704.GA12320@ubuntu-s3-xlarge-x86> <20200424121553.GE26002@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Friday 2020-04-24 14:15, Jason Gunthorpe wrote: >> ./usr/include/rdma/ib_user_verbs.h:436:34: warning: field 'base' with >> variable sized type 'struct ib_uverbs_create_cq_resp' not at the end of >> a struct or class is a GNU extension >> [-Wgnu-variable-sized-type-not-at-end] >> struct ib_uverbs_create_cq_resp base; >> ^ >> I presume this is part of the point of the conversion since you mention >> a compiler warning when the flexible member is not at the end of a >> struct. How should they be fixed? That should probably happen before the >> patch gets merged. > >The flexible member IS at the end of the struct and is often intended >to cover the memory in the enclosing struct. There is no guarantee for the presence of such a struct. In the case of the RDMA headers, even if we assume best conditions -- a block of malloc(sizeof(struct ib_uverbs_create_cq_resp) + sizeof(u64)*N) and not some struct -- it smells a lot like undefined behavior, because ib_uverbs_create_cq_resp::driver_data accesses data as u64 while ib_uverbs_ex_create_cq_resp::comp_mask and friends are u32. There has got to be some aliasing rule in C that causes RDMA's purported use-case to be UB.