Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp916952pxa; Wed, 5 Aug 2020 16:24:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxkEDu0uh+Aos21a4QitWBXNpFjZapngZXHWTpswDianLS9Ta6N6UvimZjC2+8LbwnWvbA X-Received: by 2002:aa7:c0d3:: with SMTP id j19mr1498057edp.157.1596669849655; Wed, 05 Aug 2020 16:24:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596669849; cv=none; d=google.com; s=arc-20160816; b=GrdR5Wl9wRZn8U6dffkJf92a+/lb3lerdoNWJwK62/76oXODCOzPUz/Bc1jQvG4aCf novYCXz3OKlCTMfd5pS3OOi7KHY5kY9tQMcpuTrWZ/a26oRc983cnx0//WoS391oy/9Q SBb7pXoNH8+j8HM4zhrXSW4JzvuM96StIHmz8vMPji6c7OsfrI32CaZJvy2MYEgmOTJh 2Lx0qOQeEAtGBu2gKMnBwYBwx3fiXuf+wGsybBliQ8IakJXr2ssldnfuAVpcKUW361Zk Eq2luAUjlI3D86vQnkm/v0zYW15yfLTjdOLIU8B/Umvh6GLNQwH0AwWIzMe+Luk6Vy6a afJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=hmnFGoNpdPeymMJXeGh3+t1yJ+BsYeivVGTdIDQY/Ps=; b=c97FlFIpSm2xlEQVneFkdDrHn4d3CXk/qazXkcTQ3NESMcUGyCjQ9RYfNhdo0fsxzK Jwh7rVL+Ew6xsLmU2l8geU+465lCvAx9yxf05VU0a1Q/UV4uW7RePTZLOMmBeEtfC1dO 4lwxruYex8gE+Dh6fi6F2/F1tcyRJLbpW40TxQg5g1+fmGwM+caLAkpEphUNwmFQBjpc ZvMt+XCn3d+k3oIvVBsvcZsYNUsoXrZBYaP+8BBZyuBwbmtDNd+IjMNt6XzyFS/uGZX5 R4ZF8Sa970nOfqb+wIpuuFxdTPgCmvsYRNyRaWlYvnIwyqBz6VacviCNaID3pk19+Dt5 i9hQ== 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 t3si2103147edq.511.2020.08.05.16.23.45; Wed, 05 Aug 2020 16:24:09 -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 S1726150AbgHEXWe (ORCPT + 99 others); Wed, 5 Aug 2020 19:22:34 -0400 Received: from gate.crashing.org ([63.228.1.57]:50825 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726027AbgHEXWe (ORCPT ); Wed, 5 Aug 2020 19:22:34 -0400 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 075NMAtN018390; Wed, 5 Aug 2020 18:22:10 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 075NM8hF018389; Wed, 5 Aug 2020 18:22:08 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Wed, 5 Aug 2020 18:22:08 -0500 From: Segher Boessenkool To: Rasmus Villemoes Cc: Kees Cook , Jason Gunthorpe , Leon Romanovsky , "Gustavo A. R. Silva" , Matthew Wilcox , linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: Re: [RFC] saturate check_*_overflow() output? Message-ID: <20200805232208.GT6753@gate.crashing.org> References: <202008031118.36756FAD04@keescook> <202008041137.02D231B@keescook> <6d190601-68f1-c086-97ac-2ee1c08f5a34@rasmusvillemoes.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6d190601-68f1-c086-97ac-2ee1c08f5a34@rasmusvillemoes.dk> User-Agent: Mutt/1.4.2.3i Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Rasmus, On Wed, Aug 05, 2020 at 01:38:58PM +0200, Rasmus Villemoes wrote: > I'm guessing gcc has some internal very early simplification that > replaces single-expression statement-exprs with just that expression, > and the warn-unused-result triggers later. But as soon as the > statement-expr becomes a little non-trivial (e.g. above), my guess is > that the whole thing gets assigned to some internal "variable" > representing the result, and that assignment then counts as a use of the > return value from must_check_overflow() - cc'ing Segher, as he usually > knows these details. A statement expression is not a statement (it's an expression), which turns half of the world upside down. This GCC extension often has weird (or at least non-intuitive) side effects, together with other extensions (like attributes), etc. This may be a convoluted way of saying "I don't know, look at c/c-decl.c (and maybe c/c-parser.c) to see if you can find out" ;-) > Anyway, we don't need to apply it to the last expression inside ({}), we > can just pass the whole ({}) to must_check_overflow() as in Yes, much nicer :-) Crisis averted, etc. Segher