Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4585351pxj; Wed, 12 May 2021 08:42:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0YLDXw86Rqsbz/PSTSoZ2jCGX/zQ1R25l+AjMm3OFJDM95GqflmdBQmxlHXRv42Pv2jIZ X-Received: by 2002:a17:906:2f91:: with SMTP id w17mr18743082eji.443.1620834152703; Wed, 12 May 2021 08:42:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620834152; cv=none; d=google.com; s=arc-20160816; b=ZVQd0EI4DMEZKe2B5808tXJ4IfjecJ6QWlrrWN/fWTmUq6aLuIrgXe9sUdkz/di4/s G4Gw1ZcId9I2U28cYTTV/UgrnTdYDt0syLutxledE8w13rX8A4J4XLHzFKkrtMUQD/48 WV1yhcBYwlS9CCCT1uvGGMBg7olBSyd3J8JRQGWph5XBD2Jq1Zyk9b+oQ21we7+xl29C 75DmvtGSlHtZAiGUdy1by6q4YRWrphuJsaGaWbWpNjKHa7J9qp93xpXfMwHp3go9RStC +lOpUju1BU3JhoTacR+MtnFHWNuwaZ8bemis1Xrnq/D4aaQwG5YJnj2hnkWEg+lNvpbr rHBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wPkW8qE/3P8mwcaNZVW3uzezBg0sUlhXGIkQ0wfndRw=; b=NwzM7F/Cqfc8uW0SVuycrhSIGOOpJdriMQTdFnM5bcYYN+SLwCXhfLv5UZJDdLVxzM 0fKsA+LEtRZ1ab9dKdttdUSLvmLt9YWRorrou8GZR/9QFCIMLY9NQSwiSpw4Jp/7TCXE ZneMNhqEOMIUx++Ji16HRd67Mt8olgs1Zcdelg6B+jupcaVDH7l1tuFqxC/OXp/49aYy ImgiAsRpw+sYtmxMbLk2Ru9J8nJAn4g+7dQAqRysVR5uyaRY8fqoDT+2/6n/0XK6G/3z A/tCRHr4VacdGPcs6+4Y0QGVzgQ9RtSMe0zuoKoTWP14LglHuXea14ub85p0rkFF+rt7 r7Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2S2bO17v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i26si97259edr.106.2021.05.12.08.42.08; Wed, 12 May 2021 08:42:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2S2bO17v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234164AbhELPlX (ORCPT + 99 others); Wed, 12 May 2021 11:41:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:50550 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233468AbhELPSX (ORCPT ); Wed, 12 May 2021 11:18:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C56BA61418; Wed, 12 May 2021 15:07:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832057; bh=60HUpSYLIAvOm0ggHGcF6TgISfc5JxbYxCq5UeK8v7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2S2bO17vF6TubPcPO1EoPYH47CJi55mdMCN9uCeetv0h0Z32WCUBb6eDDLi8Aa9IL vHbB4TJBdHTYAZFULeQm+gGVJUcf8GKQvtdeGzn+KaGGppa45J+d+Fh+29dycFEgyS EqdP3t+0e3yW+iglmLwbYTcwVSDwa1dj3Z95EYs8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Miklos Szeredi Subject: [PATCH 5.10 107/530] ovl: fix missing revert_creds() on error path Date: Wed, 12 May 2021 16:43:37 +0200 Message-Id: <20210512144823.319050573@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter commit 7b279bbfd2b230c7a210ff8f405799c7e46bbf48 upstream. Smatch complains about missing that the ovl_override_creds() doesn't have a matching revert_creds() if the dentry is disconnected. Fix this by moving the ovl_override_creds() until after the disconnected check. Fixes: aa3ff3c152ff ("ovl: copy up of disconnected dentries") Signed-off-by: Dan Carpenter Signed-off-by: Miklos Szeredi Signed-off-by: Greg Kroah-Hartman --- fs/overlayfs/copy_up.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -928,7 +928,7 @@ static int ovl_copy_up_one(struct dentry static int ovl_copy_up_flags(struct dentry *dentry, int flags) { int err = 0; - const struct cred *old_cred = ovl_override_creds(dentry->d_sb); + const struct cred *old_cred; bool disconnected = (dentry->d_flags & DCACHE_DISCONNECTED); /* @@ -939,6 +939,7 @@ static int ovl_copy_up_flags(struct dent if (WARN_ON(disconnected && d_is_dir(dentry))) return -EIO; + old_cred = ovl_override_creds(dentry->d_sb); while (!err) { struct dentry *next; struct dentry *parent = NULL;