Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1188907ybi; Fri, 2 Aug 2019 10:48:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqy20cjOR2jIdAt/lI1KPXe2ZmsVANB4t34zpHgqizrcrVxSehRHDWmIb9T3O6raoOKWeda8 X-Received: by 2002:a17:902:16f:: with SMTP id 102mr127708171plb.94.1564768101297; Fri, 02 Aug 2019 10:48:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564768101; cv=none; d=google.com; s=arc-20160816; b=0f2kP16954WXInNh5fVfc7zo7d7oU69tIUPujhUwfqYQGrqKYQQjE1L7slCn3axVFF VmGJJHeqozceziLNeqYK4/9Jiu9IHIt5OA7DjzQ3EquWLgMhIYpEBBalYY7XHJpb1OG3 HTF+6vOlV94KnnRRMiF//UuGnWlgGUV2N+Yi7h1JG4AATUnV/EtbuOonfTGD9uLJH3OK d0V0imnu6fNmb6688ce/0wut99EHgP6q2COi7id9O/YwwYE5Cht9M1m/euAtXLBtlrKg z85rrrGxsMzT07lXVRZP7+iX1WmliR/hgbWuxA2ekRk8k/SwkQZNwAcrWrMLSbzsao/f ID/A== 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=etLZw9Gc3DJ5TkY3oawIw2g/ZPVHdgoN8xkhcT9oHxoXcwX52cV409aETwrwInpp/7 b4Z8UZVGtwLfU3dLQQeerE9daMNykL2PZ0KUJv4vsVSl3jGWg8CjyNsSqZLqLrLNv/+1 5QY9N8n7rTMuKSGSxDXlXrVjpt1QrsCjZJJysuT3JdK5zIYSoclZieJg43SxGLcWJ2PK 94MYFPTZZpPjhv6S7v5pGLU7okWbrhQIGIZe4oiF/Ufv6im4gwI3bGp8jr5jrSRWHH1l Pm3HOudjwWP3eaHFBHJUF6tTDY6as5HdmUQ8c37lmH21ZCe+t7JHtKYp5nBVE9tVqLJO bKkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a013YNKo; 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 6si36602103pld.293.2019.08.02.10.48.06; Fri, 02 Aug 2019 10:48:21 -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=a013YNKo; 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 S2405377AbfHBJuJ (ORCPT + 99 others); Fri, 2 Aug 2019 05:50:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:49908 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390950AbfHBJp6 (ORCPT ); Fri, 2 Aug 2019 05:45:58 -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 0C52E217D4; Fri, 2 Aug 2019 09:45:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564739157; bh=rbdUCINXBgKYCp87cPrQVrS8D6nIsmFue30DS1f2waI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a013YNKoj98w4rIC/qEhvHKy8yIxb1uFIVogAXkH1ZyQPGkALz+GCbj+07Fu3sffQ B18RsWnHTmRkEqFhytaIciPnvwY9lZp3umYmHdI+b+SL9DalqXYIpVkGWGwIJ5iTG9 64Ksv/I316IC6FsPZ4IHb8wNeDgEVvG1Leul+KVs= 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.9 120/223] eCryptfs: fix a couple type promotion bugs Date: Fri, 2 Aug 2019 11:35:45 +0200 Message-Id: <20190802092246.963008457@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092238.692035242@linuxfoundation.org> References: <20190802092238.692035242@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);