From patchwork Thu May 20 09:17:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 443184 Delivered-To: patch@linaro.org Received: by 2002:a17:907:2b0d:0:0:0:0 with SMTP id gc13csp2439879ejc; Thu, 20 May 2021 02:43:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGQS0rOpdJcvCQ9l4HO8MDnjhW/j/TFWPgfos8hjbnDFH11AdoaP7DDWmrSEEmtgLduLlv X-Received: by 2002:a5d:9c58:: with SMTP id 24mr4736042iof.153.1621503827654; Thu, 20 May 2021 02:43:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621503827; cv=none; d=google.com; s=arc-20160816; b=wk5XadX2kl1fcwtnBR2A8j2RZ3gBvCnp3ze8fRisK+8Ssp04MdQODATLYreNEPYFEo wbIR/ATVRxfevRthb26HkKE9Kie4IsJC7FniFcHnQdR+lYe1uUVM8H9IM+XHHkLMM68Y VculOUpj95f+KAttlgU4MA/MFBT28TsbH0i6CuLovhdWwpkHjRgpBfd9rMVLlJwA+tzL ShleMxvktVYc4Kd2JYeEpjiQkiIm3aAVya5Nd+n+PmnKW2mtktyWYkieySEoed0lBDPu gf47+9kkmAKvqEzzVWR8f95m1MX2apRpyMwnZuxupVhtRHBRj1NzQZnMGruA7n1bM7oI Llrw== 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=3PztwynWwEwBiRKHGs9GcYXVDaFBmwYYHnBVolHAdBY=; b=u9dSKlkTrW7vqmaJq6bLgR4s1NpgBWt6ykPs2wGIcYw0ikXS0DXA95lX3bxj0/ad1M q63ljMAz9a1Z0v5UVjAJFlevzHUFBzSKRZJ3NbLmlfgY+uwf2NrmrR7lgp/uNriN9/XC p2l1D0IJ79mJCwL3Ion8JZ82wQCz7y2JKg04yxw8870+MFshsvEt3AOmAjLN3+jslepz ptlIWzGA+Cyx5UpVTY2B516SUVzKZ7cskr+e3XXyCU6weoMaoH45E4mX6L4yl1PGw+yQ Xytnj96kIYYs+ntyGyM9U8qxntkCTWCeHi3laKRjhjkrxrSHNemL8omFk52RrC2HQmdP m/CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nkaTeeSB; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 y24si1869714ior.40.2021.05.20.02.43.47; Thu, 20 May 2021 02:43:47 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=nkaTeeSB; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 S232239AbhETJpF (ORCPT + 12 others); Thu, 20 May 2021 05:45:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:46586 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233368AbhETJnU (ORCPT ); Thu, 20 May 2021 05:43:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A8CA3613DB; Thu, 20 May 2021 09:32:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503164; bh=0YX0rW6HF7WO0sItRQa5xMnQVHiE+6wfy89xlMzsHxk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nkaTeeSB6pZb/DuIUK7DNJdMW6H5HPoMiTXywt6vTOWQ+56r2c2hu6Oke1jeqKkFf Vy47U10/d4Xj36griff9ZzgKpRHqRf1XP5NQtH6fexITTe5Qhw4QBtH6t44GVMQL0J WhGvddFg3hkZ2TttYLCeAKx5hPvIQh2BU6CL54jc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Christian Brauner , James Morris , Andrey Zhizhikin Subject: [PATCH 4.19 097/425] security: commoncap: fix -Wstringop-overread warning Date: Thu, 20 May 2021 11:17:46 +0200 Message-Id: <20210520092134.642028913@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Arnd Bergmann commit 82e5d8cc768b0c7b03c551a9ab1f8f3f68d5f83f upstream. gcc-11 introdces a harmless warning for cap_inode_getsecurity: security/commoncap.c: In function ‘cap_inode_getsecurity’: security/commoncap.c:440:33: error: ‘memcpy’ reading 16 bytes from a region of size 0 [-Werror=stringop-overread] 440 | memcpy(&nscap->data, &cap->data, sizeof(__le32) * 2 * VFS_CAP_U32); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The problem here is that tmpbuf is initialized to NULL, so gcc assumes it is not accessible unless it gets set by vfs_getxattr_alloc(). This is a legitimate warning as far as I can tell, but the code is correct since it correctly handles the error when that function fails. Add a separate NULL check to tell gcc about it as well. Signed-off-by: Arnd Bergmann Acked-by: Christian Brauner Signed-off-by: James Morris Cc: Andrey Zhizhikin Signed-off-by: Greg Kroah-Hartman --- security/commoncap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/security/commoncap.c +++ b/security/commoncap.c @@ -397,7 +397,7 @@ int cap_inode_getsecurity(struct inode * &tmpbuf, size, GFP_NOFS); dput(dentry); - if (ret < 0) + if (ret < 0 || !tmpbuf) return ret; fs_ns = inode->i_sb->s_user_ns;