Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3785535ybi; Mon, 29 Jul 2019 12:34:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmI7VXKzt08W8F2KQDLnp5UjwNN9ay0aUyMIaDF42u6Mkfr1+dy+xcC8d9hDetsbJ6hITU X-Received: by 2002:a17:90a:d343:: with SMTP id i3mr118298321pjx.15.1564428898449; Mon, 29 Jul 2019 12:34:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564428898; cv=none; d=google.com; s=arc-20160816; b=DtdDhBY+temnvd7pCW2QzWhynfF11Di6OHyPVcO9HIGfZ+DJosa/mSlWjkYTZg+oOI KF6VRfPomwLw2dxao3AG/2rcAVpnOjQq8qn2oIZbeu0+XY1DR6fKFemoHOEBcZtbMdK9 07KvEfc/hKchezJaUM1TIhGZ5jgw8j2wXjcaY7GJaAYfEdpK8IIv+C8L5o96wdGI8riQ fbWqy2dsqMz1piBj7NvsJTxjOnT9ncfyZsJa/i9G2JEpnxpJR2sUK6IiMV2zu3wtwVgw 6iPoqd26hSLSyee6Gr50yZRQBhenI1r3E+pbggQjIq2B1GobiOH0NH9IOSlcelfZGcyI 8SvA== 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=wLjmp89HgKG9JuRUkk+LStVMs7ZCDsREyZQmE4KSalw=; b=DjDVdbtKg3xbcXAbADgT4FXKUQUegaWzGg22zfBBdcrH0GhFsRJCEooyqvUxISBh0M B5osDqpv/16cq3A7+jQYg1Kmi0N46EtHFUUeq5ViOQmhYNq+aTo7drNr1qLlISkXzvZU g+KLd4mlfprF4jnLnfE0amNTf1CbZ2PJA0CmCRliMVt/WT+Gs0UYNP8b2cpINfqcfp6T f+2L/0GSdyCUodnYfLM0OlcanHA3xWZ/AP0XFYRPZKT81FHu3TGNCzujtdQgBFMb55I9 pJ948K4WzxFgJsbfcvmlLf1KidB3hQVCOlCGhx6RoqHC3VfMlKhoQbgxGqDEsaGv9imr ggYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AM6JsZBO; 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 z4si27515475pgr.69.2019.07.29.12.34.43; Mon, 29 Jul 2019 12:34:58 -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=AM6JsZBO; 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 S1730250AbfG2TcZ (ORCPT + 99 others); Mon, 29 Jul 2019 15:32:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:45718 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729269AbfG2TcU (ORCPT ); Mon, 29 Jul 2019 15:32:20 -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 7D40E2070B; Mon, 29 Jul 2019 19:32:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428740; bh=rbdUCINXBgKYCp87cPrQVrS8D6nIsmFue30DS1f2waI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AM6JsZBOhp6j2aS/1KcfVqYB3sDrTAl9ZZIoPSUN1+2i4qgNywcs3ZvI6h+U+10xm S/RuxGXvZ5By+fwousj88NNMYFFDXkSrvdAQTjGWS5P6RPOsD4pIn7mF29Rj/kOx+/ iltd/1AnKbTobRhVogk922pfrhFZbN+6AhExxCic= 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.14 171/293] eCryptfs: fix a couple type promotion bugs Date: Mon, 29 Jul 2019 21:21:02 +0200 Message-Id: <20190729190837.603040194@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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 @@ -1034,8 +1034,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); @@ -1397,8 +1399,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);