Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp43294ybf; Thu, 27 Feb 2020 15:41:17 -0800 (PST) X-Google-Smtp-Source: APXvYqybsOruw733+h3r4jIUAQkmXvMeCH0fBkTAx+c+TxQ+PbC/TrqKEiwi7UVVFabSg4q/3W9B X-Received: by 2002:a9d:518b:: with SMTP id y11mr1034039otg.349.1582846876951; Thu, 27 Feb 2020 15:41:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582846876; cv=none; d=google.com; s=arc-20160816; b=wGDqNmXg74Rxa2JyWKSPw06ju66YEueabPcqKjLeU6WK0ZcTemCS/fFzCuFkKzFM0k cocdZo1OB1CtCDN0X533PR+FuqAxMmMJzWCfHrxhDx054z9epJg2FSp5ZqqCihquHMzp tEgPHBmSV0lE/VaVB2p/gug0n1iAg5hisx+CUpGHEHNl2BXa8FnHmwlz/gVN5aN7g8dR /Du9P7n+BIUWGzuQkVHiYrV6YSBs3UPgNldZ3F1m7AnHGfSZ9arx1DB/d4iEymJxHiGa V3AIo+QAOZBSHmtiQC5Di6BYgFLM3otpdv+s0OKs5L1Ptf0BNNdGIxNK9iQM/42p7L2o RLqA== 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:dkim-signature; bh=QAUmzbXS75kRRHA8vMaXZbCEV196XuZkxYJm5486XJ0=; b=A7nGBhGP8SybmXYUnvxyMyZQLYkISbNpl2qRF0Q/SIQ7JZ0Biqy7elK+nn5GfU53cg MGX+u0WVG71vFv/cUmfdVaZm7ElQ3eCSgh8i9+IvikN1tPltH1Mu9xQAomJWeVJN7VJa Z4r1dwK78Ok8AobZEG8VkilVwWOP00LhXfeEvVBPPNUBfhNmc4UHHo6O/GNEjIJGwIC4 5WXJtuhQPelZve4Y01xb4WQMMzdpSv0HlbBPsBi7MxIWskRhwDdxjnnP5kv4TLGPs3lk XVFyfC3gL4xhJX6l5iE5WyfTgLG8NLqMk311ToeZP+vrxQ03om1vf2BCM0KVND/9j90K gyqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=T8QyLuNv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h21si462944otk.196.2020.02.27.15.41.03; Thu, 27 Feb 2020 15:41:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=T8QyLuNv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729982AbgB0Xjh (ORCPT + 99 others); Thu, 27 Feb 2020 18:39:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:43748 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729750AbgB0Xjh (ORCPT ); Thu, 27 Feb 2020 18:39:37 -0500 Received: from gmail.com (unknown [104.132.1.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9F5DC2469B; Thu, 27 Feb 2020 23:39:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582846776; bh=fQciLqB49DiuqFxaJ8U7Wyw+hn2oXk1NpstgqjpjGMg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=T8QyLuNvjo55oRiRkjaifrrjclB0W/W8631zfgLa0tUN364HYs4v9d6R7N1RU81jw zv4aZxGWI277yTQPRTnoGj3mxKuoXSslOPb3hm3JEzl0s/Y7Eq5BHLsGd0RxMlHbH8 TK1tbDiMKzxiLaF5shcp4PyPlh+vw4x7r+wGxS4w= Date: Thu, 27 Feb 2020 15:39:35 -0800 From: Eric Biggers To: Scott Branden Cc: Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Subject: Re: [PATCH] exec: remove comparision of variable i_size of type loff_t against SIZE_MAX Message-ID: <20200227233935.GA176371@gmail.com> References: <20200227233133.10383-1-scott.branden@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200227233133.10383-1-scott.branden@broadcom.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 27, 2020 at 03:31:33PM -0800, Scott Branden wrote: > Remove comparision of (i_size > SIZE_MAX). > i_size is of type loff_t and can not be great than SIZE_MAX (~(size_t)0). > > Signed-off-by: Scott Branden > --- > fs/exec.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/exec.c b/fs/exec.c > index db17be51b112..16c229752f74 100644 > --- a/fs/exec.c > +++ b/fs/exec.c > @@ -919,7 +919,7 @@ int kernel_read_file(struct file *file, void **buf, loff_t *size, > ret = -EINVAL; > goto out; > } > - if (i_size > SIZE_MAX || (max_size > 0 && i_size > max_size)) { > + if (max_size > 0 && i_size > max_size) { > ret = -EFBIG; > goto out; > } Nope, loff_t is 64-bit while size_t can be 32-bit. And this check is intentional, see https://git.kernel.org/torvalds/c/691115c3513ec83e - Eric