Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp3155054rdb; Tue, 6 Feb 2024 08:37:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxakavJSD9nlm5OaLhEI0NwuMKgegYuzIBzPSbM+RwU5S+d+n+hGizu3XQT0Qb4q2SbFOd X-Received: by 2002:a17:907:910d:b0:a35:b2b1:5372 with SMTP id p13-20020a170907910d00b00a35b2b15372mr1799920ejq.68.1707237455982; Tue, 06 Feb 2024 08:37:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707237455; cv=pass; d=google.com; s=arc-20160816; b=Pt/1Tecg0J18McdEB8J6m6VILWMxweaAwr8h9noE08uN+QxrnrRAaslEHMOdxVXrwv xcHDlzljzSa9HDrq7lohRYXX+KuatqL8y31e2B0JGkxbWPMNW50MpO5IluQK8uCY530i J56q4E2jlJ8KD5VOtBvkl8d+IrgRNAdDUQOfpWILuTqJEGVdgWcl0ZPEsGTlihbOpz17 CxPjTFS+wcHmiC+13oH2mpqfgvW6ucWt+1TjFu1yoybJWOH6OYi2iBbZMHMVP6NspqNe BDg5a8E5fOT0OvyNDUm1tgwTfx/DI3etZX43ySJiXaRfsxm/SpMivefJhSCFw3z3b84I wI1A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=ho3hrp7XcTsBErJhywPAagDi6Mkqk4q72L1K4GsdTRQ=; fh=kvLijJrdrOEXBOqezgwTcVlFbKXqUOfEcavvy2MQeeU=; b=VzzxF84vZREI5chIWlH9VHg0h66T9QR46JYuFTHX5dBoz6/6wclKyu7dAISs2qB1ez oVPCtLfpU1rGvw+PSwr802p9AJooYqPRdcJSgrLx35ZxhzxWGtG9gDhsxi9IxYat47GK pWYqom8YjfB41r/CAcTZdt3p8rADPlM9Cc6GOtrPab7bKS02j40gqhBnkH4DNpA39szQ P2ymalCxLxhV2QMO5lEz1pG6S75jD89kmcENaf9amkr+T2gQkBaC4eCxHKD6JgQrdxCw 0DvR2TwtIVg/Uzb3WBzvWTlL63qCP4j25YMWlnCpkzZVdy+7yrhl62V6OsYLGigq6/fj p/gQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=FYm38sxs; arc=pass (i=1 spf=pass spfdomain=embeddedor.com dkim=pass dkdomain=embeddedor.com); spf=pass (google.com: domain of linux-kernel+bounces-55326-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55326-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCXVt5DT0edixbUEGuqqB98nVEJ2uacagbot0MkmwUbOA9EKlkTLq8fffh+S32WZSeak+BPiZhf/+GzJH6bE+imQtHa1t+mFHtVcTQzyWQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a17-20020a170906685100b00a37487eb520si1265049ejs.754.2024.02.06.08.37.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 08:37:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55326-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=FYm38sxs; arc=pass (i=1 spf=pass spfdomain=embeddedor.com dkim=pass dkdomain=embeddedor.com); spf=pass (google.com: domain of linux-kernel+bounces-55326-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55326-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 892E41F26539 for ; Tue, 6 Feb 2024 16:37:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 75CC04A11; Tue, 6 Feb 2024 16:36:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=embeddedor.com header.i=@embeddedor.com header.b="FYm38sxs" Received: from omta40.uswest2.a.cloudfilter.net (omta40.uswest2.a.cloudfilter.net [35.89.44.39]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E4D3D527 for ; Tue, 6 Feb 2024 16:36:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.89.44.39 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707237387; cv=none; b=u0wI7UyrlNPeFA84M3WfKeotn7GRsLzH6lfVlDLex5GsCFxDZHFosVxGHXNR3jiIkdfW5Q+5jIFvDl6mymGJaMhKBYYjVm3bW8f6vsHxKHycNToVpxVg6keQ+0h+mu2lm0ZagKyvQLeCcOoPaqF8QLE5Fopt8pOkF2DoXfDxETE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707237387; c=relaxed/simple; bh=mgZOgLB1HuathAGqKmjNnG/0xoJq5roM2WNaXcdTp9U=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=NLdO7ieWrwfNZvSwerh4vZYQ8dTv0oyyyFlyfkvv0U/Dh1qLulFuN/TU3TFuf19j/XWtxcsYG7ivvltqRwZgbmqhdAoL0IJggwasXs5lGFwEDSy3Fpv9DTYFDoPRFLqvhtyJt3XHTPtkuLjf9cRe14/XcbXQ9dzYyiQwiV8ZpUE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=embeddedor.com; spf=pass smtp.mailfrom=embeddedor.com; dkim=pass (2048-bit key) header.d=embeddedor.com header.i=@embeddedor.com header.b=FYm38sxs; arc=none smtp.client-ip=35.89.44.39 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=embeddedor.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=embeddedor.com Received: from eig-obgw-5003a.ext.cloudfilter.net ([10.0.29.159]) by cmsmtp with ESMTPS id XKpvrG1oK80oiXOQlrrgX7; Tue, 06 Feb 2024 16:36:19 +0000 Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with ESMTPS id XOQkruWp4OmWYXOQkrn8UU; Tue, 06 Feb 2024 16:36:18 +0000 X-Authority-Analysis: v=2.4 cv=T/MvTOKQ c=1 sm=1 tr=0 ts=65c26002 a=1YbLdUo/zbTtOZ3uB5T3HA==:117 a=WzbPXH4gqzPVN0x6HrNMNA==:17 a=IkcTkHD0fZMA:10 a=k7vzHIieQBIA:10 a=wYkD_t78qR0A:10 a=VwQbUJbxAAAA:8 a=cm27Pg_UAAAA:8 a=lXWNAtzADcZZgIjtGc4A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=8LfgHNaa6p4A:10 a=AjGcO6oz07-iQ99wixmX:22 a=xmb-EsYY8bH0VWELuYED:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=embeddedor.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ho3hrp7XcTsBErJhywPAagDi6Mkqk4q72L1K4GsdTRQ=; b=FYm38sxsIiXyEaRic6gNnCyQPN jieaLQ1ZUefC3lameJVtACCu3wIbgJUUS6oVj3kQ+T7XD7iHEv/92rQ1LXloUwkRIyVUn01oN42l/ vgdZLOhtn8Z3YWHilM6+epHYQ4yIlsBW10IoRD7WoBBSIg5vnBL9M4hzpZF95UVj9cS5BaY6NeDWo G9ULvv2gM2B20XmTUxPloOo1w1kCxMo6qeQFDJWzZh2dUnXSNjVBAHJ6cGmfyVKwOMWVBJ+G7S9Rs bj4sTK5brhJDOxaaw5Gmx48u0cmt7mfa0mpI4FgzRnCyntjdpXjv2BuMT067jS/wH+j5/7tjQg4gS iOLAF0jg==; Received: from 187-162-21-192.static.axtel.net ([187.162.21.192]:36786 helo=[192.168.15.10]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96.2) (envelope-from ) id 1rXOQj-003Ba7-1b; Tue, 06 Feb 2024 10:36:17 -0600 Message-ID: <89a743fb-37fa-40b9-8ce5-d118ae95af38@embeddedor.com> Date: Tue, 6 Feb 2024 10:36:15 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 1/3] overflow: Adjust check_*_overflow() kern-doc to reflect results Content-Language: en-US To: Kees Cook , Rasmus Villemoes Cc: "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org, Marco Elver , Eric Biggers , Mark Rutland , Andrew Morton , linux-kernel@vger.kernel.org References: <20240206102354.make.081-kees@kernel.org> <20240206103201.2013060-1-keescook@chromium.org> From: "Gustavo A. R. Silva" In-Reply-To: <20240206103201.2013060-1-keescook@chromium.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 187.162.21.192 X-Source-L: No X-Exim-ID: 1rXOQj-003Ba7-1b X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 187-162-21-192.static.axtel.net ([192.168.15.10]) [187.162.21.192]:36786 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 1 X-Org: HG=hgshared;ORG=hostgator; X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfBue6D50HEGO5CIPVHuIETEoeaAIr2DRy5TuyMNZwJwFgavRXvf6hwLfezPzMzHqubHEr+pmzVBNNfKBrUazMRD7gzPuO4ANs6QYOMrwzpYfmuKLhW1J 1di6FgJbZy6xdIBcvN2IcohGxIz7R9E8pxeYnUrKtYVrEDArqQCQK8EmFksNj4/4LBsz64LtQuZHAQPo0/Ct3GpIR02SGBwFoODXjw6pv7MaV4iieFNyQFWL On 2/6/24 04:31, Kees Cook wrote: > The check_*_overflow() helpers will return results with potentially > wrapped-around values. These values have always been checked by the > selftests, so avoid the confusing language in the kern-doc. The idea of > "safe for use" was relative to the expectation of whether or not the > caller wants a wrapped value -- the calculation itself will always follow > arithmetic wrapping rules. > > Cc: "Gustavo A. R. Silva" > Cc: linux-hardening@vger.kernel.org > Signed-off-by: Kees Cook Better to be concise and direct. ???? Reviewed-by: Gustavo A. R. Silva Thanks! -- Gustavo > --- > include/linux/overflow.h | 18 ++++++------------ > 1 file changed, 6 insertions(+), 12 deletions(-) > > diff --git a/include/linux/overflow.h b/include/linux/overflow.h > index 7b5cf4a5cd19..4e741ebb8005 100644 > --- a/include/linux/overflow.h > +++ b/include/linux/overflow.h > @@ -57,11 +57,9 @@ static inline bool __must_check __must_check_overflow(bool overflow) > * @b: second addend > * @d: pointer to store sum > * > - * Returns 0 on success. > + * Returns 0 on success, 1 on wrap-around. > * > - * *@d holds the results of the attempted addition, but is not considered > - * "safe for use" on a non-zero return value, which indicates that the > - * sum has overflowed or been truncated. > + * *@d holds the results of the attempted addition, which may wrap-around. > */ > #define check_add_overflow(a, b, d) \ > __must_check_overflow(__builtin_add_overflow(a, b, d)) > @@ -72,11 +70,9 @@ static inline bool __must_check __must_check_overflow(bool overflow) > * @b: subtrahend; value to subtract from @a > * @d: pointer to store difference > * > - * Returns 0 on success. > + * Returns 0 on success, 1 on wrap-around. > * > - * *@d holds the results of the attempted subtraction, but is not considered > - * "safe for use" on a non-zero return value, which indicates that the > - * difference has underflowed or been truncated. > + * *@d holds the results of the attempted subtraction, which may wrap-around. > */ > #define check_sub_overflow(a, b, d) \ > __must_check_overflow(__builtin_sub_overflow(a, b, d)) > @@ -87,11 +83,9 @@ static inline bool __must_check __must_check_overflow(bool overflow) > * @b: second factor > * @d: pointer to store product > * > - * Returns 0 on success. > + * Returns 0 on success, 1 on wrap-around. > * > - * *@d holds the results of the attempted multiplication, but is not > - * considered "safe for use" on a non-zero return value, which indicates > - * that the product has overflowed or been truncated. > + * *@d holds the results of the attempted multiplication, which may wrap-around. > */ > #define check_mul_overflow(a, b, d) \ > __must_check_overflow(__builtin_mul_overflow(a, b, d))