Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2548575pxj; Mon, 10 May 2021 05:41:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBfyXaDmckHBmzpk6Rhweg7ILiPbudpgKi7hylvhUj6Ux26D7JjnxmRU1RnENPCSTfSGxh X-Received: by 2002:a05:6402:8da:: with SMTP id d26mr29291003edz.161.1620650500609; Mon, 10 May 2021 05:41:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620650500; cv=none; d=google.com; s=arc-20160816; b=HHggNJTsxR7iXR8nP6KXdPqHHEMO/HqrRjpvTTm8IfTJCf51mJu/l89pU92hma4C79 +LZUFYjWl5XnIHdx75D+oFpJzHgQCANwJRe67iaElK+9GYmJnAFC5Gky81ZZLwzbdTiA U83gnQp8NZFxT9PAwV4IMfzYErs4neqDk6+3mcAFFhrlkdspuMzm3yTAgRpDp3iPPugc Rbo/TOCT4KwQwoQKe0AyayHs7CJ3HOPfAwIn/C053MU6hR6g1Aba3dAUKzrKU/KxXtCj btFKGD1IzTlenHbKz44bYBm9C0febM6cKUyH1cD2pvIDMUznilBnaFVZUWNb4XvYIXlK KynQ== 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=NkxIApmy5S22tGx9gLN3nVXFJamBAyLdxcztxOw5Y4U=; b=oS8OFFtIUxCWcK43HK6CXwNm3U2pUSKWbIVGmuJgYaHvGvm4azlaEfcKGYJ5cBMdgO mSvQSTy61cprXu8g8AMoC8NotZSjWPsMP+8WFUU8K5bMXA04nkjnV6B+c8vie7/KK7qn ZnnHQbeMpIDPKGkUsLpNJ6F2nPnudFd+AcgJswy0tLthHSapFJGljpaTBh9hmbIOOTl6 wLAs491MByS0Y5grZFXzBP6DBh1xK0NY9rO6LRe29vcHBpzmdWkGUyRrebqyPV9VpSs0 MExvM4EHLfnwL4iyeSfB76395CvtsLG7lVFFx5P25fZRpbU64fHAnp8JWOn3q9pfs8HF ++AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Rvbd9EDQ; 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 y22si14986036eda.511.2021.05.10.05.41.17; Mon, 10 May 2021 05:41:40 -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=Rvbd9EDQ; 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 S1347592AbhEJMg0 (ORCPT + 99 others); Mon, 10 May 2021 08:36:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:55988 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233601AbhEJLOO (ORCPT ); Mon, 10 May 2021 07:14:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CF49161424; Mon, 10 May 2021 11:10:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620645041; bh=Rm//JxqJELkUL8BRgI54ulf7oVv8a4orV4V0NwUxU2U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rvbd9EDQcJvCA3LstLbuNbssNwdOIkBL26Pk85IjUY0CyVoLE9sNnkVquZfkAGyHt m1PftWr2tebvnjuCgvGG3pljCGvX0Hq7/iX6xJUezV5DyU26ZNZKT9HToKcbPTkRVK tq0XRD7Wi2yvHwHVFnKkVS5tr/k8saeJn2SmAvhU= 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 5.12 327/384] security: commoncap: fix -Wstringop-overread warning Date: Mon, 10 May 2021 12:21:56 +0200 Message-Id: <20210510102025.573829288@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102014.849075526@linuxfoundation.org> References: <20210510102014.849075526@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: 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 @@ -400,7 +400,7 @@ int cap_inode_getsecurity(struct user_na &tmpbuf, size, GFP_NOFS); dput(dentry); - if (ret < 0) + if (ret < 0 || !tmpbuf) return ret; fs_ns = inode->i_sb->s_user_ns;