Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932567AbcCBAMm (ORCPT ); Tue, 1 Mar 2016 19:12:42 -0500 Received: from mail333.us4.mandrillapp.com ([205.201.137.77]:57058 "EHLO mail333.us4.mandrillapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932487AbcCAX6P (ORCPT ); Tue, 1 Mar 2016 18:58:15 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; q=dns; s=mandrill; d=linuxfoundation.org; b=UEa9tH3DUBPEUJ57P0Nx4S5qMlkOU4GjQwHEVN1UYqQ0TrtJVcSVVrYArKWjWP79aQEJQH4fl/9/ UVXLII3Eldz4w8gebrYgOHqI9kp6KQ1t6FEehv8+CvsP+DrWJTgid4RbfwRrUsqeIxu7jxiX1kbX 0YvWuSDno7Av+iDHsEk=; From: Greg Kroah-Hartman Subject: [PATCH 4.4 309/342] do_last(): dont let a bogus return value from ->open() et.al. to confuse us X-Mailer: git-send-email 2.7.2 To: Cc: Greg Kroah-Hartman , , Al Viro Message-Id: <20160301234537.868312281@linuxfoundation.org> In-Reply-To: <20160301234527.990448862@linuxfoundation.org> References: <20160301234527.990448862@linuxfoundation.org> X-Report-Abuse: Please forward a copy of this message, including all headers, to abuse@mandrill.com X-Report-Abuse: You can also report abuse here: http://mandrillapp.com/contact/abuse?id=30481620.88bf0f281c6a472c9c6751116eafa75b X-Mandrill-User: md_30481620 Date: Tue, 01 Mar 2016 23:55:27 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 935 Lines: 34 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Al Viro commit c80567c82ae4814a41287618e315a60ecf513be6 upstream. ... into returning a positive to path_openat(), which would interpret that as "symlink had been encountered" and proceed to corrupt memory, etc. It can only happen due to a bug in some ->open() instance or in some LSM hook, etc., so we report any such event *and* make sure it doesn't trick us into further unpleasantness. Signed-off-by: Al Viro Signed-off-by: Greg Kroah-Hartman --- fs/namei.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/fs/namei.c +++ b/fs/namei.c @@ -3210,6 +3210,10 @@ opened: goto exit_fput; } out: + if (unlikely(error > 0)) { + WARN_ON(1); + error = -EINVAL; + } if (got_write) mnt_drop_write(nd->path.mnt); path_put(&save_parent);