Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1247586pxa; Thu, 13 Aug 2020 04:34:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyANpwFYK0cdB1f3JAc+jLH6t+Vcj9R6VbbtzeX46FjzcaPkK87MfYwzftrC1gj/+KtaJ+U X-Received: by 2002:a17:906:3655:: with SMTP id r21mr4452739ejb.248.1597318461706; Thu, 13 Aug 2020 04:34:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597318461; cv=none; d=google.com; s=arc-20160816; b=kJSdZJuclaHuMY0NRvOiVGveP7ID44jr2au5loekfiWLw+tGj4loa535SvunQCErXi 3E/fhug3dipU64BfR438ZJ/guNL/OYQ/Vuz97/1UlnRaUkNxHsHoG+wCSKmAWFvp3Pdd e58j/NffvLTMdseYkasX+QB0h6DQ7hFXfpm9Ds7ze7g6ia+YzTFXQyadldBije6HHI8K ZtHOdViLVh478NIWDmT1GV/XV8xl0XwE+tzaIri/Ip28sSBn0/HXukDmr/DfwpNhFm1i 1QbiIQbvMTDXuSVVEhuQJiL0tBg53SA2wUMbM3Gc+ZQCi89dYT6dV2FgZPejUHM2yaHq aMRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=CKBHpRq2gdYecMDnHVd5fZCbJkMkjf8ao+KHmXIXSMg=; b=pOaXP0DWyKqDfPAxQ1vnh99vMHnY/6Gq/+/Cj9gNGWUPCS4tV4YyC2t9RBp9kovbcB +KCjXcpcK5TwtIIXgHRUacTvhpK+u+hiNm7xHqmmV3TATduHWdplVLk8RKnsL0KNysIq JaPT5gjDixn8dJizoSvu7bZ/QT1YMr38Du/x6iWkmWg2sv4/KqGoL7usb1eWYoD2eQIz +Kq8MOCbqcd/L90/QFe9sqEGuJ6LxAcFPuAky2GU7gdSh6fhylAJL7jmSmfOpv2ynqbP aWGyQEjt9lG3LT65LfIJXsIgwcfzJE19wfzdpk5N0QFikXx6XijW0jzYTiwzLNfMsSs1 7VmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=ejivrTcN; 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 ox11si2978578ejb.727.2020.08.13.04.33.58; Thu, 13 Aug 2020 04:34:21 -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=@rasmusvillemoes.dk header.s=google header.b=ejivrTcN; 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 S1726681AbgHMLdL (ORCPT + 99 others); Thu, 13 Aug 2020 07:33:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726102AbgHMLdJ (ORCPT ); Thu, 13 Aug 2020 07:33:09 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37EDDC061757 for ; Thu, 13 Aug 2020 04:33:09 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id h19so5759662ljg.13 for ; Thu, 13 Aug 2020 04:33:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=CKBHpRq2gdYecMDnHVd5fZCbJkMkjf8ao+KHmXIXSMg=; b=ejivrTcNuBz6f3oxo1Y3zzsM8DitmA3VJUE1qaeuEwlJPxUAvWFXytt/iywwB7qCGy 5MD82jHYBj5HiDAf7kqp4ks7+5ToBEqHq8nGc08BLB5vvo5QQS/eV3bJ4iGfykjfdDRM rZvrV7fxjdhXqS6mmXipjtnrPgGvLYh5D2JQ4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=CKBHpRq2gdYecMDnHVd5fZCbJkMkjf8ao+KHmXIXSMg=; b=lp4n89CPRSEE7Cafn5V1Wv53VhO+CvEGith/sYCpp081Vif+bZZuwy32BKIuJBDyPW fFUhwqfhvW/BV8no/7ct2qHC/Lwui+x149VKRXRGS48h+tSRNrlUVqvT91dmK4v+5Kn7 hzSFW2RmCXpTfzRmMtK+m8DxfKZOqR5MYWoXLYXfLcKise1hZtBk2WH+1l2RvX4YX0SK 12kK9Z3W0e39EOVT8GGpLOZcA+DW2K+e1Tf/h4aMDnxgbVoJhxefnmg1AWrtdxipnmiX hlSOfAd5C7tLJkqnz3LijRNryFQSf8usQzRvg6kGIAkuQv0BwE2fDOOkFAMceve1byNl 2jww== X-Gm-Message-State: AOAM533Uj68UbQ3NlcSmvQZJxHH8Wcit91OZZX5JDiLV2+Bu39Sxtmf2 guRR/rPQCJX8N4V021c64/V0Yw== X-Received: by 2002:a05:651c:314:: with SMTP id a20mr1762778ljp.434.1597318387708; Thu, 13 Aug 2020 04:33:07 -0700 (PDT) Received: from [172.16.11.132] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id a1sm1138751lfb.10.2020.08.13.04.33.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Aug 2020 04:33:06 -0700 (PDT) Subject: Re: [PATCH] overflow: Add __must_check attribute to check_*() helpers To: Matthew Wilcox , Kees Cook Cc: Rasmus Villemoes , "Gustavo A. R. Silva" , Jason Gunthorpe , Leon Romanovsky , linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com References: <202008121450.405E4A3@keescook> <20200813112327.GF17456@casper.infradead.org> From: Rasmus Villemoes Message-ID: <3e498585-f22f-25b8-9385-feadd55fdc7b@rasmusvillemoes.dk> Date: Thu, 13 Aug 2020 13:33:05 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200813112327.GF17456@casper.infradead.org> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/08/2020 13.23, Matthew Wilcox wrote: > On Wed, Aug 12, 2020 at 02:51:52PM -0700, Kees Cook wrote: >> +/* >> + * Allows to effectively us apply __must_check to a macro so we can have >> + * both the type-agnostic benefits of the macros while also being able to >> + * enforce that the return value is, in fact, checked. >> + */ >> +static inline bool __must_check __must_check_bool(bool condition) >> +{ >> + return unlikely(condition); >> +} > > I'm fine with the concept, but this is a weirdly-generically-named > function that has a very specific unlikely() in it. So I'd call > this __must_check_overflow() and then it's obvious that overflow is > unlikely(), whereas it's not obvious that __must_check_bool() is going > to be unlikely(). Incidentally, __must_check_overflow was what was actually Suggested-by me - though I didn't think too hard about that name, I certainly agree with your reasoning. I still don't know if (un)likely annotations actually matter when used this way, but at least the same pattern is used in kernel/sched/, so probably. Rasmus