Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4574109imu; Tue, 29 Jan 2019 04:04:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN5FFq9B83vkyGw/eX7d98/FZEvykCPROUMOkVC1kxdEXMXU58VGchZKXF3XZFoM4R4XtNqZ X-Received: by 2002:a17:902:780a:: with SMTP id p10mr26340526pll.54.1548763447687; Tue, 29 Jan 2019 04:04:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548763447; cv=none; d=google.com; s=arc-20160816; b=qF+rvotmKediTKdanFWOMblgrtePuaLHmkIXBSXgAxhwiJ8Qrg6Aavgj+HdIkugyRe tmVozlqrwhcdkXcOjko3xy9D1bB8+g9oLDIwhl3lTHn7Q+VBUgjg9i5Xzuo8Jx4e4oNH XJ5U6JgT9xo5mjN+jKpNcukm3SL4vE3chCM80kLA7CIs8Qb8yoeYYIVYgW+tQBt2yvng Py9HZZirYN6t2wZ2teQRYchuunn/18w1NLiqkSpV/sRVhARetifKpAWBilHiW+h/Il4R bbv8Q/HRK3HC+9B3vbZTtT6kKni15qrwGlG+HGv8oVTgkcGgsum2Mh2RBhIQx/jKYzbz uS1Q== 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=gSU3zSKDWTuQGk+au9mnez6CXlPYbwz1CJIqhMbYgdE=; b=xB40zirJRTxEODYA/MtKYkFHNQ1OtVVe483VwIX/0ce0T5xhXCYQ1MrNjLYxAJPINT JZA6ggsjsVC/ak+yIGVzUm/vdf4I12xB4xc+KUfTsE0ua5eFNeXXTpWPLFLX0x1yttFj wQHW9/HRyIQ5+jjfNsc8E9baLbQ2x/n+j7PHTC77cZUiu6zo9LJwJmBKIcAxP1Fkcbsi m8Wi1Emxfqh5UHix//mwb2hv/271SzTmd1/eeINCyxqAAFGaVasuer04AnmOpmNjm93t MEzzQEwPq4flJ+iwL6KohKi032VM+eryZOxMRekiSKpvHVsUBP5jO4Irr+6CezvwF+Up 6UrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cJqbqMIM; 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 f63si4230pfg.136.2019.01.29.04.03.49; Tue, 29 Jan 2019 04:04:07 -0800 (PST) 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=cJqbqMIM; 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 S1730410AbfA2Lno (ORCPT + 99 others); Tue, 29 Jan 2019 06:43:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:33690 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729882AbfA2Lnm (ORCPT ); Tue, 29 Jan 2019 06:43:42 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 3772D20882; Tue, 29 Jan 2019 11:43:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548762221; bh=S405Nio0cPrc1jeD32TVs3mVSOHJ8Ptem3hfuKN9w9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cJqbqMIM9n3l6gsXtotoinY0OpcKJbPHf5DdN2vqerlO2QOg20dvCzyGLMc0qUBi1 5SHCxfuPGGnQOJWBihy7mIic7/pomejWluKii4aI+n7dckiD7oKfFHletC5Ct48SYL RC8T84WooIuy6VVTYAJHhyrJrW/XB748Gaka3548= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tetsuo Handa , Amir Goldstein , Jan Kara Subject: [PATCH 4.19 033/103] inotify: Fix fd refcount leak in inotify_add_watch(). Date: Tue, 29 Jan 2019 12:35:10 +0100 Message-Id: <20190129113201.551200774@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129113159.567154026@linuxfoundation.org> References: <20190129113159.567154026@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tetsuo Handa commit 125892edfe69915a227d8d125ff0e1cd713178f4 upstream. Commit 4d97f7d53da7dc83 ("inotify: Add flag IN_MASK_CREATE for inotify_add_watch()") forgot to call fdput() before bailing out. Fixes: 4d97f7d53da7dc83 ("inotify: Add flag IN_MASK_CREATE for inotify_add_watch()") CC: stable@vger.kernel.org Signed-off-by: Tetsuo Handa Reviewed-by: Amir Goldstein Signed-off-by: Jan Kara Signed-off-by: Greg Kroah-Hartman --- fs/notify/inotify/inotify_user.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c @@ -724,8 +724,10 @@ SYSCALL_DEFINE3(inotify_add_watch, int, return -EBADF; /* IN_MASK_ADD and IN_MASK_CREATE don't make sense together */ - if (unlikely((mask & IN_MASK_ADD) && (mask & IN_MASK_CREATE))) - return -EINVAL; + if (unlikely((mask & IN_MASK_ADD) && (mask & IN_MASK_CREATE))) { + ret = -EINVAL; + goto fput_and_out; + } /* verify that this is indeed an inotify instance */ if (unlikely(f.file->f_op != &inotify_fops)) {