Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755631AbcCBBn2 (ORCPT ); Tue, 1 Mar 2016 20:43:28 -0500 Received: from mail177-1.suw61.mandrillapp.com ([198.2.177.1]:23733 "EHLO mail177-1.suw61.mandrillapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753901AbcCAXyG (ORCPT ); Tue, 1 Mar 2016 18:54:06 -0500 From: Greg Kroah-Hartman Subject: [PATCH 3.14 128/130] 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: <20160301234504.287908538@linuxfoundation.org> In-Reply-To: <20160301234459.768886030@linuxfoundation.org> References: <20160301234459.768886030@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.03a1de7aa2904f8bb175d26ea12eaf99 X-Mandrill-User: md_30481620 Date: Tue, 01 Mar 2016 23:53:41 +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: 936 Lines: 34 3.14-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 @@ -3085,6 +3085,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);