Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1411789ybg; Thu, 4 Jun 2020 09:03:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxp2O3uyTvvn76ORgYOQsQ1RUAJ9rDZarVUAl48wEmm2jg73BsxD8HYpfFlcHOntAcnuW/K X-Received: by 2002:a05:6402:3044:: with SMTP id bu4mr4959480edb.69.1591286633329; Thu, 04 Jun 2020 09:03:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591286633; cv=none; d=google.com; s=arc-20160816; b=ktnx/dYs8tviIPFbe2uwgTdBOJDPtfbfEEvCSRXNDOQq1CP9aPe9nyANfn68rKgs6O WOZq4GYlk2CEZe75zY9ppZVEtQkVOxUC6qRijcSSKX7SLHJQbti7bLXUco9q+qR4HdtM oqH7s4/Hpl0DFKBrtK3r2o4XJVLltGNpUYi12cDRAZ9EzIAMc4gfGAJ/gMBztuBJJ3pL uTSrbAaZObUwk1nzqZOuCKDK/RzYaazjACTF/R3WPbG2ITKJuuNKpgSv7e0Fx3FuqSPS dE053UFOvZnl+hlcFeg2H7H+Fy4jAYFaJ3bYmyAz1FDbsJ/qcOHvAQ6E31j3gwEVw9ds TDRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=gSE6BdE4/VFzX3t/Cxitf0IUrhF90wQNUXw+URqjRrk=; b=ncyvi2SW5BzxZF13usVYyFPilIaYqqqFTMoEJRU4qzwKJgTe2Rvl+cYSbBmPuhZebp go7Dudwgw5d8WRbKKog7Jcibe048V4r5I1Yx5esUphttjxrpIO/CA5iJm/0Hah2Mlyjx lzC+M7hyvC5eVrzFnRrWkO7qqgbChUhgw0CjpR7/Xm7Xl439o/nZ80KLCd1wcSgEI5mw RgrVV80fhjF3u+NtT2x+iFy3i8FnNwEJHVHTYaLAXmK9JT10Fskmx0nmDs3ZOoOP9g/T NHX59CtwLmIfD2jjEcp/Be2xga+YiCPh96k75CG9DkmkWCUUq8jSmxo+Fk2gCnY4pDiV TVhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="mLy/HvzH"; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a4si1776661ejr.736.2020.06.04.09.03.27; Thu, 04 Jun 2020 09:03:53 -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=@chromium.org header.s=google header.b="mLy/HvzH"; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729652AbgFDQAk (ORCPT + 99 others); Thu, 4 Jun 2020 12:00:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729629AbgFDQAk (ORCPT ); Thu, 4 Jun 2020 12:00:40 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 569B0C08C5C1 for ; Thu, 4 Jun 2020 09:00:40 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id p30so3625259pgl.11 for ; Thu, 04 Jun 2020 09:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=gSE6BdE4/VFzX3t/Cxitf0IUrhF90wQNUXw+URqjRrk=; b=mLy/HvzHev9qn2v1D69VG573ZlAmuwdGrUAVyFRAlQGYhXDAB4eRmdrAwXHU8suvZl vr1IG9/sDG1dSwSMCOeVIzqK9QUy6EZ0bxxEpLsnbPNzaP75fa/Q5Fv8/tWV7wSoqcI8 pZcmZvYpvkkbnCEqDbzFQNJI61Y5loWolvvCs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=gSE6BdE4/VFzX3t/Cxitf0IUrhF90wQNUXw+URqjRrk=; b=XehxABAg9981WVOF/seCcB3TAlo8VCn62NL9+0paH4AkbWuZWLf+4ORpraKJ+VldDY cQi6JRzafZQ/bBQAdbOtonVO0ACXmsV6/a+VTCNBp2Re/9la6k5MvurhLemR3j3Wkahm e5ZAUBqh19hKBms4LQuFQhRGBwNI3voVuvgY03I1gsOgzQ/k5oFp6UwGn3OCrn4uIbmN 6w2N5Lc/x0C2nb2swimzzONKAipzE1fcwyRq0OepnLHwlopC8YjclLS/PsfeOZHTl4vr numeaPo268pXTAI9P3aeOiU0iATIst9jjr3Yjr3/JXPCAaveX7dDyFOSiboYvv/a5q7d 8GCg== X-Gm-Message-State: AOAM530sTKIyOsrVyPwV5nBWrwbzDMLWAkEHHOlI8LdPATQ83gAiunvV C2Pk/CYQXBn4tSJfkGadC6rQ7g== X-Received: by 2002:a63:5054:: with SMTP id q20mr5083098pgl.117.1591286439853; Thu, 04 Jun 2020 09:00:39 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id w206sm5098711pfc.28.2020.06.04.09.00.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 09:00:38 -0700 (PDT) Date: Thu, 4 Jun 2020 09:00:37 -0700 From: Kees Cook To: Miklos Szeredi Cc: Alexander Potapenko , Vivek Goyal , overlayfs , linux-kernel@vger.kernel.org, royyang@google.com, stable Subject: Re: [PATCH] ovl: explicitly initialize error in ovl_copy_xattr() Message-ID: <202006040858.3BF48FCF63@keescook> References: <20200604084245.161480-1-glider@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 04, 2020 at 10:57:24AM +0200, Miklos Szeredi wrote: > On Thu, Jun 4, 2020 at 10:43 AM wrote: > > > > Under certain circumstances (we found this out running Docker on a > > Clang-built kernel with CONFIG_INIT_STACK_ALL) ovl_copy_xattr() may > > return uninitialized value of |error| from ovl_copy_xattr(). > > It is then returned by ovl_create() to lookup_open(), which casts it to > > an invalid dentry pointer, that can be further read or written by the > > lookup_open() callers. > > > > The uninitialized value is returned when all the xattr on the file > > are ovl_is_private_xattr(), which is actually a successful case, > > therefore we initialize |error| with 0. > > > > Signed-off-by: Alexander Potapenko > > Cc: Kees Cook > > Cc: Roy Yang > > Cc: # 4.1 > > > > --- > > > > The bug seem to date back to at least v4.1 where the annotation has been > > introduced (i.e. the compilers started noticing error could be used > > before being initialized). I hovever didn't try to prove that the > > problem is actually reproducible on such ancient kernels. We've seen it > > on a real machine running v4.4 as well. > > > > v2: > > -- Per Vivek Goyal's suggestion, changed |error| to be 0 > > Thanks, applied patch posted here (with your signed-off as well, since > the patch is the same...): > > https://lore.kernel.org/linux-unionfs/874ks212uj.fsf@m5Zedd9JOGzJrf0/ Can you please add: Link: https://bugs.chromium.org/p/chromium/issues/detail?id=1050405 Fixes: e4ad29fa0d22 ("ovl: use a minimal buffer in ovl_copy_xattr") Reviewed-by: Kees Cook (and adjust the CC field to drop the "# 4.1" so tools can figure it out?) Thanks! -- Kees Cook