From patchwork Mon Sep 19 12:38:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101765 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp939056qgf; Mon, 19 Sep 2016 05:39:22 -0700 (PDT) X-Received: by 10.98.91.197 with SMTP id p188mr47386141pfb.101.1474288762050; Mon, 19 Sep 2016 05:39:22 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pa7si28875259pac.177.2016.09.19.05.39.21; Mon, 19 Sep 2016 05:39:22 -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; 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 S932952AbcISMjU (ORCPT + 27 others); Mon, 19 Sep 2016 08:39:20 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:53528 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754542AbcISMjK (ORCPT ); Mon, 19 Sep 2016 08:39:10 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue003) with ESMTPA (Nemesis) id 0MZhl4-1bQR5e455a-00LUEC; Mon, 19 Sep 2016 14:39:01 +0200 From: Arnd Bergmann To: Miklos Szeredi Cc: Arnd Bergmann , Vivek Goyal , Al Viro , Andreas Gruenbacher , linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ovl: avoid setting uninitialized creds Date: Mon, 19 Sep 2016 14:38:46 +0200 Message-Id: <20160919123859.1335236-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:FRGehc2c9CTY8m3/IESaCQBKXmAsFb7QStPr7woPfWxKIbDxebQ OzPM4YVMrZnxjTfmHkBLHzyM5bzmPSpoVmLCnPDUwM/mu7Q55QyYyju2AWi6d1bwSN77+oU 2UTX8M7E+l+UiH6fpktS/KmBEO6zNqqaUP7EjbL8z5uREphzXHSGk61WinhZ3PUAO0tk/ju TDHU5rV4Ee6JrbnlMhPYw== X-UI-Out-Filterresults: notjunk:1; V01:K0:se+zSip2tNY=:8ZrrGpivk9LSQ6WA3f6Ek8 PWT4MGJnZkd8R0zHGIneqeTtnBvvGZnN/UQp97CePtTG/qWSSu5ehwZLyPvOUv6eVYdgwEzNN Ej7AgxtaaL3jfyS3972vK10ViKWhGqKk4/6X33FLcD+xmxBLDQoqnIiV1h5ptqEdc+HOUUw4/ WHbbd2t7SELMgkBKr50bWkQ6Cl2tKfn1tvkH7I4SjHr5MyuZPQwEHpkd1uZlkSgAXqKLnqLrh PHhiPIobWuSN8Ga8r2NE399LnHxl7+Xf0aBAqCWrftZhoXNu46Op2GRIWzvjS1Zz8wscjO9OX YN925MQLkuUW/PQWWpxs/vBddAdL0KM8fGY55TakQREmma1grbd4xwSbk0sck5ZEIUjhLtmRb GQ0HQPZCxoUo8JX6/U8hu2il3lWQ5tuh0pqxcmzvtU17U3CLcOHEJZyz+wnr99m4zJ07/0dez 2wdCF/t18ElWPVoexG5MI/mrkCtpktb0QAj09e2xH/fK6kM5qqaKZCWDLOfkhbpxJKMxXdd5a xLl838PmVs49vuCj8jMjSMYaxi5a0CQ8smSA81/Hc7FKBW3jzynaEu6xFEKeLC0Yp1TcUZC9Q Py3dMVcPHIDOuJledBKaLUGJMazCfb37c9ipvAVVmP1xf5+tn5kx6ILT/dNYvoUnmVAPpqdih m4+7IvURSA47z+zs/tJHeZla4TFjxMoQwwCJrcWqHLtDcLkJeLthf6u/ZqEBTpT8e2zM= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the call to ovl_copy_up() fails, we now call revert_creds on an uninitialized structure after a recent patch, as found by "gcc -Wmayby-uninitialized": fs/overlayfs/inode.c: In function 'ovl_open_maybe_copy_up': fs/overlayfs/inode.c:39:2: error: 'old_cred' may be used uninitialized in this function [-Werror=maybe-uninitialized] fs/overlayfs/inode.c:22:21: note: 'old_cred' was declared here This changes the code back to not call revert_creds unless we have already called ovl_override_creds(). Fixes: 54249cd03956 ("ovl: during copy up, switch to mounter's creds early") Signed-off-by: Arnd Bergmann --- fs/overlayfs/inode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.9.0 diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index af87c7c109b7..65375f9c5563 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -30,13 +30,14 @@ static int ovl_copy_up_truncate(struct dentry *dentry) old_cred = ovl_override_creds(dentry->d_sb); err = vfs_getattr(&lowerpath, &stat); if (err) - goto out_dput_parent; + goto out_revert; stat.size = 0; err = ovl_copy_up_one(parent, dentry, &lowerpath, &stat); -out_dput_parent: +out_revert: revert_creds(old_cred); +out_dput_parent: dput(parent); return err; }