Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10430190ybi; Wed, 24 Jul 2019 23:04:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqxE6ORFLWVqL9qTTAWulc4EIdXKcMBBtuR+7INOLxsl/2Tsb6fz2z8CmvRJkjwToTFaO7Qg X-Received: by 2002:a17:902:6a88:: with SMTP id n8mr89613696plk.70.1564034687465; Wed, 24 Jul 2019 23:04:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564034687; cv=none; d=google.com; s=arc-20160816; b=ldO1eotkC01Gs9JSCcskw7MU1qLLVAHA0Pnz7pzkZ8gDbdOnZJZaNuNMWDOdcHuOVu ZYi36cCk6WE2fWSxcPwoYUbRrZHq+PRKklD6Z52PWzWoX8uxezzXuzZzZvtfVKUPbrBS y4UU+Pla4Z9BumXTu5GN+GlFl5cY8MB39wzAm6zxzymAiW7IEPcWb+ZvSiWVI+VOuGtT t21ggk0Z2V/c3GTHtkQcejuGjCOpFuPGRR52gpkMYDr3VC7rifOKedVe9K5Ed9t6l/br /y5HMfjGM8iQdbU24xHw0HOZqAtjpCTGhFO0uh5CukoYrBoj/SNA2MQXFM9opa2zhsbd 8Hew== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=557tnGv7JjQOIl3eIPAOjwF0DpfM6vftw+i3k/Yb0z0=; b=jpjLZMlFVVGXgazOjnFqmeeXrdx9mJMFaIZc3lu0c8ThxpEU3t/3r7243gtuBmzEQo t7o+u7LPHDAwBlJ6PInRz1rjOkSCMCorNRkilzuTpZFVmDeUd7kAkv6XuDOUQf67BdlV SnkRQYrSTqYJsP6e9/3VieDlFukXHtCZDBdsG9NM7HcCf6a6sSDAUDHAhYjadOpQx7UE 43j3CNMKBSNZ5z8I0pPZreOiE79zRuAf45A6T8oz5iCumnVte1JUGRjbglaxUv0eY+Le lNys5C9Vl4JLaCr3xw4FgLVobgvtYnfzGOkvSFXzOrK58xC2NGvbauOA4APCCM4hfGw8 xXsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wziZLSch; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 72si15332270plc.415.2019.07.24.23.04.33; Wed, 24 Jul 2019 23:04:47 -0700 (PDT) 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=wziZLSch; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391548AbfGYFrS (ORCPT + 99 others); Thu, 25 Jul 2019 01:47:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:35246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391525AbfGYFrQ (ORCPT ); Thu, 25 Jul 2019 01:47:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 026082075C; Thu, 25 Jul 2019 05:47:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033636; bh=S0t3sC77Tgfik/F+fYwdHpd5/+/LozTQp1zITTY+whg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wziZLSch4UEIhxiM5lRX9uMdnk1Kl1GOBWhYhB5Rhgz08U02E6/T0XCN9kNGtwQCw s8d6QgEr1rrMXelqkWykJxN8VkQo3xN8vvRFvftl8qHA9UWP9kay4GbEDhyUVh1EJv NhzWpAB/0/lYPkU/OqKw0lThU8g95YDnG+FgKbCk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Tyler Hicks Subject: [PATCH 4.19 260/271] eCryptfs: fix a couple type promotion bugs Date: Wed, 24 Jul 2019 21:22:09 +0200 Message-Id: <20190724191717.478612234@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter commit 0bdf8a8245fdea6f075a5fede833a5fcf1b3466c upstream. ECRYPTFS_SIZE_AND_MARKER_BYTES is type size_t, so if "rc" is negative that gets type promoted to a high positive value and treated as success. Fixes: 778aeb42a708 ("eCryptfs: Cleanup and optimize ecryptfs_lookup_interpose()") Signed-off-by: Dan Carpenter [tyhicks: Use "if/else if" rather than "if/if"] Cc: stable@vger.kernel.org Signed-off-by: Tyler Hicks Signed-off-by: Greg Kroah-Hartman --- fs/ecryptfs/crypto.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c @@ -1018,8 +1018,10 @@ int ecryptfs_read_and_validate_header_re rc = ecryptfs_read_lower(file_size, 0, ECRYPTFS_SIZE_AND_MARKER_BYTES, inode); - if (rc < ECRYPTFS_SIZE_AND_MARKER_BYTES) - return rc >= 0 ? -EINVAL : rc; + if (rc < 0) + return rc; + else if (rc < ECRYPTFS_SIZE_AND_MARKER_BYTES) + return -EINVAL; rc = ecryptfs_validate_marker(marker); if (!rc) ecryptfs_i_size_init(file_size, inode); @@ -1381,8 +1383,10 @@ int ecryptfs_read_and_validate_xattr_reg ecryptfs_inode_to_lower(inode), ECRYPTFS_XATTR_NAME, file_size, ECRYPTFS_SIZE_AND_MARKER_BYTES); - if (rc < ECRYPTFS_SIZE_AND_MARKER_BYTES) - return rc >= 0 ? -EINVAL : rc; + if (rc < 0) + return rc; + else if (rc < ECRYPTFS_SIZE_AND_MARKER_BYTES) + return -EINVAL; rc = ecryptfs_validate_marker(marker); if (!rc) ecryptfs_i_size_init(file_size, inode);