Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp2108376lkv; Thu, 20 May 2021 03:36:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKfEglvqUGsE1oxeusctz6t/lZ7hdcBIGbuncOcsAOqiyiTCrHleju2QMHwTkX1p6M2+hk X-Received: by 2002:a05:6e02:1e05:: with SMTP id g5mr4862701ila.134.1621506988059; Thu, 20 May 2021 03:36:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621506988; cv=none; d=google.com; s=arc-20160816; b=aXBgtv9GaihZz1pxMcEvQA92TkJUw5YLm/Xs5jzD7a0pjCGv96BzNzKugvPXezJrB7 R7/6zNkXZj2/Bzn3j1n2Z/uKkmNd/kw3lG5BP2pCYqoPlp4vnpX9ljqNBYKIqAQ2ZxCM kOzkVKQ3Zmohu8IFGX7dF8lgb3Zmev5aJCpLKB6F1X6z58IeV8R0pSHW2SgnFp3+4sb9 ilRLZVZGedzicBeHi/7JkalTl0GN4sVLxtq2wNhlHNA0DH4znxDPuG6qjlxSN7ZafEUo Uodz+rIHC3nITwNrscMICQGV+xTpx9JmeN2XBzwYJHyEVlCRahZgx5djdR7wnX6LHTo8 S18A== 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=4dyOZ1tvT8gR9XvF/VUbHiUipqQc2ATsWh+MlIhgDiw=; b=G9AxlUU1FCfuhFZaEktJ6Rl5ziUTCx0HeLC5VvDSNPtI7nI2eCNIbjGI5Z7C71bZ9a VzYnWvek0D+qa7cDIYI9tGlRqn18P3s76n9vH+014xkOrr/8Gkumo/EvwGAd3b53j2Da ossPzQdyjXIb1ogzkCQ6M4nti7ky2AqaqqWoIfiI8jZYhpiBN9LtL4QZxVZQcu0+hX7L ud7MPj5MMAy/WlESTo4kzkZaFRCmXrDu4VBvRjrc5+1TyDwNwg0LI6nh1vpD/0uUq5DN Q4Ut4FkEF6lWmmyaBXU7Y+zkMzt/t7sa5yrBeaSLYSG6/JJTpGcuBzBPVtjX4gPeBWig eqBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Jpy8+oUU; 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 e7si1840459jam.26.2021.05.20.03.35.52; Thu, 20 May 2021 03:36:28 -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=Jpy8+oUU; 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 S237687AbhETKfT (ORCPT + 99 others); Thu, 20 May 2021 06:35:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:51084 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236050AbhETKVp (ORCPT ); Thu, 20 May 2021 06:21:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3D50F619CE; Thu, 20 May 2021 09:48:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504089; bh=OiXSrU9raZo/MypIrbIP9AX2FGiy9QxF6dwavzZYp+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jpy8+oUU8rccflPo4vPfRDTbCgiFJdBquCKwgh9phXFlDeMXL8fphkYANcGKxMYLb iuYcfULCvx0x2q7QPTuao67fbvgmKFIy2BLqMQNwR8Kao2ZDvJkU7ObNaklW0IJpAC 3AdAkqcdDZwcacaUMnBZ/hW2Mgi6VJYLe7Nawiyc= 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.14 086/323] security: commoncap: fix -Wstringop-overread warning Date: Thu, 20 May 2021 11:19:38 +0200 Message-Id: <20210520092123.031950025@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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 @@ -398,7 +398,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;