Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp36269pxa; Tue, 4 Aug 2020 15:47:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRubWQAqh3oLM+WoGxqzs43GDDs33vhpUhCOWN4TUv6MshwDuKrF7fZxmlGd8qzr2q8OWB X-Received: by 2002:a17:906:e115:: with SMTP id gj21mr318240ejb.505.1596581276538; Tue, 04 Aug 2020 15:47:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596581276; cv=none; d=google.com; s=arc-20160816; b=WUbV4fgi2lIEzFHYOFMeFYQkOo74SXNfAXUoSOimumJ64y6ut19+DKxY2E10L96yja JQj+hUASbpFnjUbEDPVu4F4RdWKmF3J1T/LAK/xjRSIXaHfVWMxtHa/zWCsfiIRLjdhc /v5EnMjZ+Pn55m406qKN9+ITlh+E1S5WAVBVWw+Sf8/705A5BAF4/+exjS+FkOlEMwcw kFoyyqqXcySod8eRapWZhRwKeeoZJDF0FZmWDyGwsoD8z2s5mo4fAjx6VzAJzmglc7NU cc/+E2vgM3Hpuh6M0QkVY4rUI9GCU7avnCrQNN4A13rhSAKr7Au+b9VoWim4YSW5sqN0 LWnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=UveKBYDbIZyIjh6ZPjOv5UQRCvtyfkU8x2EftZkViyE=; b=dcQwCPBeNN0casf0zspYwZqHRZbEzaiE9JCGMh4bYCo4tXYosUb/yY099ADn+wFVoF Mv1ti8EXWNWPSwFt/gQhGxT2IschjUddsYV2x1QXp0UGAHoU9nQAsTsX5zdMBs/2xaAU nRblwvMjCaw8jq08HSO4XL6nc6Zpvg5KIJfredVQI7rATIXwpjYnovJswT9pC9eunvfJ aBGSw2YVIGlvPcIy4oXJozgUyO6H8l/jW0+5aRElTGb9e2o9IRfSebPj/tha60o4wCnd n9z39H2cGyXTL5Pi7bjLQGbxNbMvDmIUt7n2VL2EOJOKpCnO0VS5UpNBilySIWWDLB9H 4KHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b="fFSpiFi/"; 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 cw13si106351edb.170.2020.08.04.15.46.56; Tue, 04 Aug 2020 15:47:56 -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=fail header.i=@infradead.org header.s=casper.20170209 header.b="fFSpiFi/"; 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 S1726752AbgHDWpt (ORCPT + 99 others); Tue, 4 Aug 2020 18:45:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726222AbgHDWpt (ORCPT ); Tue, 4 Aug 2020 18:45:49 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB85CC06174A for ; Tue, 4 Aug 2020 15:45:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=UveKBYDbIZyIjh6ZPjOv5UQRCvtyfkU8x2EftZkViyE=; b=fFSpiFi/AMgkfAVlAg1gz8Lovv wknbgJJDGNkFpBxfe0qi+Ue73w6sgRM7wQaROnxaNYjc+aWAYlFcyrH07uLsKeMGuxhu9giRlAnyz aTVv6J41koFtbUaMem8UHjzBa0hJQeQQmpEy2So1FXEK8WiBx7n2wL7m+FCpn5kTFiTLr166/s1mG oF6c8p7cbV3KllUCY0toiT8PYBe66OAbufWPr9nVF16CUmVL8mYK9qada0Z3fMorh20eafrP0Gpdr 1r1lS9WNOg6cCuLQ0XJkMWT40x1ZBVY1UsnLGyKglE66JM73d6Ruviw3Er7hFtvL4zHSXxYg4VoSP 07JwMXGQ==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1k35gm-0004rW-MJ; Tue, 04 Aug 2020 22:45:44 +0000 Date: Tue, 4 Aug 2020 23:45:44 +0100 From: Matthew Wilcox To: Kees Cook Cc: Rasmus Villemoes , Jason Gunthorpe , Leon Romanovsky , "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: Re: [RFC] saturate check_*_overflow() output? Message-ID: <20200804224544.GK23808@casper.infradead.org> References: <202008031118.36756FAD04@keescook> <202008041137.02D231B@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202008041137.02D231B@keescook> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 04, 2020 at 12:23:03PM -0700, Kees Cook wrote: > > What we might do, to deal with the "caller fails to check the result", > > is to add a > > > > static inline bool __must_check must_check_overflow(bool b) { return > > unlikely(b); } > > > > and wrap all the final "did it overflow" results in that one - perhaps > > also for the __builtin_* cases, I don't know if those are automatically > > equipped with that attribute. [I also don't know if gcc propagates > > likely/unlikely out to the caller, but it shouldn't hurt to have it > > there and might improve code gen if it does.] > > (What is the formal name for the ({ ...; return_value; }) C construct?) 'Statement Exprs'. A compound statement enclosed in parentheses may appear as an expression in GNU C. This allows you to use loops, switches, and local variables within an expression.