Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp243325pxb; Mon, 13 Sep 2021 18:10:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxp4rcbTU8aktgZXyj3K1ZHI7YKpJ45TluoYZL88GaC2zbUS38hl4i2QQfxkWnHMTvAIc/ X-Received: by 2002:a05:6402:1257:: with SMTP id l23mr16612772edw.8.1631581801365; Mon, 13 Sep 2021 18:10:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631581801; cv=none; d=google.com; s=arc-20160816; b=Ea6RbbvDykyK967C0OxyLCQGI2Tk9v7p4+WktHKLB4EWPjWhjleRK+Ti58KKwVvIoz o6LVIyaPIp4CZnRYCYjBUuyGqzD7TbfHvO/c/54TE5vEx/qUUU0giyKayJVwhu8iYUO2 YQ+4KsX4fvyrZKZqjmBQE5zlJTaucoTQKX171bMzDD4fsoda7/FOQwg1XnYCTiqVZsD3 nBmmaZ3IXWslQGM7WPMHWvBY/vw9CGBFvqggF7tOz5SF0JTMO1Bs1KF/mQmqGH/GHDt8 r6u731kRyq48BbD/kpnfRA2ZWxUhQHpT1Vf2DsoCJ85BRVWQJV/CBNvqcJEPw3BYg7+w bSIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=8TVqbn8thZCqMP/VrYd9m008Vn/d1QsljDuZZA3Cj3U=; b=bvhpTSXBMvoG+lUKI84rmOPWfAxyVNDIV+lzk2z16sfl17GgpKeOfLndRSfIYcQmjN DffjhoH7cFI/TfjBUBjSzcmThu2C2h6ztubWlwM3a0RSa0SJrzWdh6xnhGqfDRP6knCq PaxZ8u5kSUhGad+zJZe6+R/CELTTI/RmWW7X1jdY/BPl8jdytBNYBahsWUBjkEdLtSOd obljHLiybA1H1MQhlkS1r/PSScksS3vBKceYHpapbHHu+WhMu3pqpLJM6y71+roSEKTW X29Zpp5DVwTNNtwpNrMgG4GUf56ZYPTRAy8R4b5/QstJpLBmXKzbELyynEKgiX5DSpr+ VP8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="Kx+QXs7/"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dz8si8966461edb.30.2021.09.13.18.09.37; Mon, 13 Sep 2021 18:10:01 -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=@google.com header.s=20210112 header.b="Kx+QXs7/"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244441AbhIMUxg (ORCPT + 99 others); Mon, 13 Sep 2021 16:53:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243622AbhIMUxN (ORCPT ); Mon, 13 Sep 2021 16:53:13 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 126CEC0613BB for ; Mon, 13 Sep 2021 13:50:30 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id s3so19585780ljp.11 for ; Mon, 13 Sep 2021 13:50:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8TVqbn8thZCqMP/VrYd9m008Vn/d1QsljDuZZA3Cj3U=; b=Kx+QXs7/Gqu+0fT01IBf7AvtFuuKzukMCBr8Uj8Tlirfgy3sBlDb/0dgxW8i2fm4ki Cr2wjOBudyMAbTz6hMk9v40PhWKj9nMcIvmb30kyKFZB5RsdvaSnLonYQoWCJky9Fn/q rvmHHz1xfT6sAANA+Cql145bvCNIa1CwpBa7ThFjKt5zw9vKElWhqhFhEUwiaxOgfZ8Z mc6ZDYEM+0S6oMqPrZMSE/Xi4nZl2oaQoisz2wKEDinJKmadJxfu8MSthUEwUNPCWeqH fluefePE4KH12STgQsgozYhaHaImiPkP9T36zeeUIgpXLdwXCdryY+34zNJ9CWrttP02 lFrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8TVqbn8thZCqMP/VrYd9m008Vn/d1QsljDuZZA3Cj3U=; b=pe+MOCvKICChjuR7T5rR94GDOIRoeGF5nwNxBtQX4AZtwIMccobywOVnRkvj9uLAwb /Asw2ukvN9ADsEJgz2/ChOKWowSxqkXS5Qm9skFewyMVBUn7DZM0vV+3OjO5J7B8MQca M6dohd7+gkLAeyuDudbtH+zgE0BN5wsT0i+PIbv7wu9s7Wk24cYl7R9Xd/eM5Y7xLN/g JQGKo+OXOPx/WCy9r+PtJBFJBiaiCVA74GLN6grzxAT68Ft5C7LKEj4kL5nK+WEA/QLn YYArw81hagWtfsLH63B4ab5GPFhhXKulZ/Rqmh4r4HIyDvmCcxsCWEYL8DJO0JuYZ7ZQ UxBA== X-Gm-Message-State: AOAM530P9ybqvsGSDsa94bkR5FN8gYrxh0qhoSkbdHEIrN3TkAo6qVhj 2vMZqHxzdhpJX8VCt+ngLP0ODj2cT6igwpwYmKViGw== X-Received: by 2002:a05:651c:54d:: with SMTP id q13mr12530242ljp.526.1631566228215; Mon, 13 Sep 2021 13:50:28 -0700 (PDT) MIME-Version: 1.0 References: <20210913131113.390368911@linuxfoundation.org> <20210913131114.028340332@linuxfoundation.org> In-Reply-To: From: Nick Desaulniers Date: Mon, 13 Sep 2021 13:50:17 -0700 Message-ID: Subject: Re: [PATCH 5.14 018/334] nbd: add the check to prevent overflow in __nbd_ioctl() To: Linus Torvalds Cc: Arnd Bergmann , Sedat Dilek , Greg Kroah-Hartman , Naresh Kamboju , Nathan Chancellor , Baokun Li , open list , linux-stable , Hulk Robot , Josef Bacik , Jens Axboe , Sasha Levin , clang-built-linux , lkft-triage@lists.linaro.org, llvm@lists.linux.dev, Kees Cook Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 13, 2021 at 1:42 PM Linus Torvalds wrote: > > On Mon, Sep 13, 2021 at 1:16 PM Nick Desaulniers > wrote: > > > > Do we have access to _Generic in GCC 4.9? > > We've ended up using it unconditionally since last year, so yes. Sorry, grepping would have taken < 1s. I'm very lazy. http://threevirtues.com/ > > In fact, the compiler version tests got removed when we raised the gcc > version requirement to 4.9 in commit 6ec4476ac825 ("Raise gcc version > requirement to 4.9"): > > "In particular, raising the minimum to 4.9 means that we can now just > assume _Generic() exists, which is likely the much better replacement > for a lot of very convoluted built-time magic with conditionals on > sizeof and/or __builtin_choose_expr() with same_type() etc" > > but we haven't used it much since. > > The "seqprop" code for picking the right lock for seqlock is perhaps > the main example, and staring at that code will make you go blind, so > look away. Looking at my patch: https://lore.kernel.org/stable/20210913203201.1844253-1-ndesaulniers@google.com/ I don't think _Generic helps us in the case of dispatching based on the result of is_signed_type() (the operands could undergo type promotion, so we'd need lots of cases that are more concisely covered by is_signed_type()). It could replace the nested checks in div_64 with nested _Generics, I think. Not sure it's a huge win for readability. Maybe cut the number of expansions of the parameters in half though. Let me give it a try just to see what it looks like. -- Thanks, ~Nick Desaulniers