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 X-Spam-Level: X-Spam-Status: No, score=0.1 required=3.0 tests=DATE_IN_PAST_03_06, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EA94C5B57D for ; Tue, 2 Jul 2019 21:04:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5822C218B6 for ; Tue, 2 Jul 2019 21:04:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gWT0fL/s"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="ZMFtd4fn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5822C218B6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=H1Uz/jl/gtdLkXb3pwsm2zl659CRFJV1Cxlp0co9kWo=; b=gWT0fL/sMI5NZt RKyFVmie5xxGRClKD/g1EDOguX1DO8aFJdHwkPhIdijn7m8s17+gbKner+SGwVnpzBx1t5iizoC5Y CBIZWZTqVc0rvX6zZ/SBoCwNb/E++2mWXfg1RCIswVRS55QSjtx6/8ZRiza2SgLfucVt8JZXAfb+N Ec7MijmLcxFwuZLZw2Eg0mW45a8NB0gQvIkb9m1BOmulazH6J+U9BKobJaAnE+TTtMLJxHPIVnETB iHuBjWcP6Bl8+xB+VqRvLKG1YBxXZDcXEb5AVGwW4lK2ytcB8Zh32lniQOKW3LW/ZdthJfzpz/Hye 6ANY54bdKlbpc3bFX1bg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hiPx5-0000nj-At; Tue, 02 Jul 2019 21:04:35 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hiPwg-0000bf-E9 for linux-arm-kernel@lists.infradead.org; Tue, 02 Jul 2019 21:04:12 +0000 Received: by mail-pg1-x544.google.com with SMTP id i18so3618925pgl.11 for ; Tue, 02 Jul 2019 14:04:08 -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=a6DSR9zMVNSIPOHutOGYYowzxyygnNjjAgHH6t/fH3Q=; b=ZMFtd4fnwBhjqDgEcmMPYqwTfM3scvxup6E9ES0eTl1QBLbkm4L+EYQQqrUrDt7I0f 1W7i7K4qFAKEM9FkLZbBvOwEPA2KShqct0FnQuEtwjRtbN+49uyAwET1ta2fkPFntUdL d1HKAJ/XrkEjycdCCsfgQI1lqoOc8poLOC7Ys= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=a6DSR9zMVNSIPOHutOGYYowzxyygnNjjAgHH6t/fH3Q=; b=MC+N+FqapW5zAgweXvKDAO03dSJP+rD82wxhqiqvBNc/bSgQfNzNmX8BPC9EQzdskP IEyYeYuvpsI7e8n6YFZ++NbuFxST4xRQUGovW36ZbKF2pynqabK/d4QsAu8ODNMAaVcW KgIGnFeNza8fvTPHPpHLi6afGx0PlPdAV3ClM9MlxqXXMdn/GTuoNJ9FKLlNRpcb6GSN Y7bSP7nxbYlbWZ48MzZJfiD4Qmycvj+HLzg7nza1xBJmGIVsmlWjd/VVyF1gk2Xh9KeN 08sENJSmZ5pIk1yOrOczgdhvKBU5hDYknX5szmrRZ7IhcP9HDW4gDGRHqGO6t3iHiabM 4gnQ== X-Gm-Message-State: APjAAAVi0t9vkbrIi6MmM3WFz+ZlSfqDjULRHwO1yVAjAnVbhADR8D49 Y7tBdLSOg6PGb2zZFcL/PW0SmA== X-Google-Smtp-Source: APXvYqxbnDf0epA4zxEVMf+KQtiS47h5ZVi4HVl0lxeY8pfHVzHmCshNhotvWTcEjEQC+XEnSbkkRg== X-Received: by 2002:a17:90a:b908:: with SMTP id p8mr7901348pjr.94.1562101447970; Tue, 02 Jul 2019 14:04:07 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id g1sm52207pgg.27.2019.07.02.14.04.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2019 14:04:03 -0700 (PDT) Date: Tue, 2 Jul 2019 09:33:02 -0700 From: Kees Cook To: Joe Perches Subject: Re: [PATCH V2] include: linux: Regularise the use of FIELD_SIZEOF macro Message-ID: <201907020931.2170BAB@keescook> References: <20190611193836.2772-1-shyam.saini@amarulasolutions.com> <20190611134831.a60c11f4b691d14d04a87e29@linux-foundation.org> <6DCAE4F8-3BEC-45F2-A733-F4D15850B7F3@dilger.ca> <20190629142510.GA10629@avx2> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190702_140410_620648_76454C72 X-CRM114-Status: GOOD ( 20.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andreas Dilger , bpf@vger.kernel.org, kvm@vger.kernel.org, kernel-hardening@lists.openwall.com, netdev@vger.kernel.org, intel-gfx@lists.freedesktop.org, devel@lists.orangefs.org, linux-kernel@vger.kernel.org, Shyam Saini , linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-sctp@vger.kernel.org, dri-devel@lists.freedesktop.org, Andrew Morton , linux-ext4 , intel-gvt-dev@lists.freedesktop.org, Alexey Dobriyan , linux-arm-kernel@lists.infradead.org, mayhs11saini@gmail.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sat, Jun 29, 2019 at 09:45:10AM -0700, Joe Perches wrote: > On Sat, 2019-06-29 at 17:25 +0300, Alexey Dobriyan wrote: > > On Tue, Jun 11, 2019 at 03:00:10PM -0600, Andreas Dilger wrote: > > > On Jun 11, 2019, at 2:48 PM, Andrew Morton wrote: > > > > On Wed, 12 Jun 2019 01:08:36 +0530 Shyam Saini wrote: > > > I did a check, and FIELD_SIZEOF() is used about 350x, while sizeof_field() > > > is about 30x, and SIZEOF_FIELD() is only about 5x. > > > > > > That said, I'm much more in favour of "sizeof_field()" or "sizeof_member()" > > > than FIELD_SIZEOF(). Not only does that better match "offsetof()", with > > > which it is closely related, but is also closer to the original "sizeof()". > > > > > > Since this is a rather trivial change, it can be split into a number of > > > patches to get approval/landing via subsystem maintainers, and there is no > > > huge urgency to remove the original macros until the users are gone. It > > > would make sense to remove SIZEOF_FIELD() and sizeof_field() quickly so > > > they don't gain more users, and the remaining FIELD_SIZEOF() users can be > > > whittled away as the patches come through the maintainer trees. > > > > The signature should be > > > > sizeof_member(T, m) > > > > it is proper English, > > it is lowercase, so is easier to type, > > it uses standard term (member, not field), > > it blends in with standard "sizeof" operator, > > yes please. > > Also, a simple script conversion applied > immediately after an rc1 might be easiest > rather than individual patches. This seems reasonable to me. I think the patch steps would be: 1) implement sizeof_member(T, m) as a stand-alone macro 2) do a scripted replacement of all identical macros. 3) remove all the identical macros. Step 2 can be a patch that includes the script used to do the replacement. That way Linus can choose to just run the script instead of taking the patch. -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel