Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10286122ybi; Wed, 24 Jul 2019 20:04:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjvU32ijer5Iviv0qZgH+4cqtg46C9FyPzSwyzlpjSgLOmPv2kVnuekcq6ldyZggbmcyYd X-Received: by 2002:a17:902:4501:: with SMTP id m1mr89255290pld.111.1564023888716; Wed, 24 Jul 2019 20:04:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564023888; cv=none; d=google.com; s=arc-20160816; b=oFp4MXzFPCM+dwRU8VaBzzbXPjtVg7Vj4p/tK/avX62UopS1V/VW89iMpvtb3k6+ta c5gwF85Ne9P1JfKYLpr8nTObZkpycKiE8wWV+lYzxatUA4lcKpCXjnHKzOIfJxzlF7UM sAWXLsXn2byWB1jdRHZq2liwCHcedEEGw7kfglMafzgTNElvZ3OzAtNQIDWBXiuJgw5C WXjNijqNHU1DUzkOvaw08x46l3aw74WiHzGoqG2heEd+g3ic+ezBAOosd1SMP+laN3Y1 HTQUDDwhPLmIhWS0rg5rLkjNfegCEuoNX1VtLuGZhuYgQiYYUvmcAVmddxsFVTU1ntLx F5cg== 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=+VaE5GNHJCfAUEI2NAdhcC5EiCFc3l/COSL/w/sCBFY=; b=LaMpVSD8PKBWANDa3cCBVDMyAj2zJJupyh1yGw0c0Dlo7SpvIohnk0zyY/Zp3L6C0r gwQmZLTsaE2FG5QNy91PEbYqpo2BYyBkKr7OohU7jZ7ldKYU10TQVjApoLtUq6HQ4+Pl yXTrSmMC/F0RHw5By6eH4vbjBq3D7FWtt1WMecgqHb0I5vBtzppIb1/NbGrN4RwmdbLm fy11fad8H8D9N45FMjQ7SejjI3er7TZbR4SDdgq2ImBkI8TA6rt77x6Eaufzv1lWOxJs PVYKvthpESnN6xKs1vFqjEV1Bmvi+wWGLQFavhndd/tO1Jt2i8x1I/6qcmJD8JQwZLA6 A+Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ihKC2HBZ; 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 w19si7052532pga.462.2019.07.24.20.04.33; Wed, 24 Jul 2019 20:04:48 -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=ihKC2HBZ; 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 S2390312AbfGXTmB (ORCPT + 99 others); Wed, 24 Jul 2019 15:42:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:43522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389740AbfGXTl7 (ORCPT ); Wed, 24 Jul 2019 15:41:59 -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 92D7921873; Wed, 24 Jul 2019 19:41:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563997319; bh=jnWybWz1GHgb+SURgW27+vuHdkH2zlG6t/JUokmp9Uo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ihKC2HBZ7/XUQo3L5Z93YJRa/yiSHKQKbRljDLN7RJiLAutHJ95TOl1/1hti/Jqcu cjJQkg4iDmu6xiAxRKtzWKFOaDENja+5KUKwzAykqsLzq0DIitGjJaoTCp2DuDnzT5 gfmakSv51sUaxOWSe49wkIKJut4Y+8tZrdEYgiR8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Tyler Hicks Subject: [PATCH 5.2 396/413] eCryptfs: fix a couple type promotion bugs Date: Wed, 24 Jul 2019 21:21:27 +0200 Message-Id: <20190724191803.299683811@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@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 @@ -1004,8 +1004,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); @@ -1367,8 +1369,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);