From patchwork Thu May 20 09:19:38 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: 443206 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp2151568jac; Thu, 20 May 2021 03:22:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3bCx4o4PP1DleyNwg9FcSU2EFodtckEe6UM/EiL0tefpBDVpHHaJYNif6VQiZnH2oIqs0 X-Received: by 2002:a05:6e02:2192:: with SMTP id j18mr4644130ila.223.1621506154943; Thu, 20 May 2021 03:22:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621506154; cv=none; d=google.com; s=arc-20160816; b=ZJ9mHjGk+SeI32WwHZ455lMhng1Fl4aydMCUUlwRwb9plR4uVqjIzy2wnkXmCd1xT+ 3fUvbRCKhQ+Kh5IEP+2TfHzoCDm1BC8aLn3V7iI17g4ZkSHlVqaEACGbAVCImRHQIV0K zrwdCEKFILWjuw78/gXL+jfs8xxuxzASfXTCl+wbCjQgZhumBSpNiOWbpPtd3YmKww7w WmOOOBoi0S52IujenSpmnZ5BebtKNqDJd7NA8OC+Rx5m0b2rh8UyFKduTEo9BJW6aQZd 2YqstNIFje8g7gkqExfUbWTdwIJ7sFDUmlhk49e5w/1RN4McP9mHhnKNj268/eF1HCVD c7TQ== 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=cSTNzHNgELP4iSBvXmKxOKeLfIIFo7xM89VyaJv9kdI8cugj0tQFhYPBn+Yb7RnvcS l9wu+gTZG9AOvygO/YwmCvJo1OaQnnUf08ZRBS+Bd+Vz1s5lm7qVKvYIyx0XrcO44VvO PUFjEJVNHjqEMYqGV2w3bF9UoveV0Wpct3dXZ5+Ybjcjcj1iHdGnufQMZVtHa0ZRzQ29 0dN19Fzgty3VjSmnBICFtCBuB4EWm01HJNm+LqFMSa8N6+ZigMbnxnanj4nsEuG5EJrx VebM2HSkThYHywQJZAFvSOfYar+tmOOitDnQcCTkepeFQ2+SJ0VNCnNhKMaI3K8KyG7u xr9A== 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 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 n12si2038041jat.1.2021.05.20.03.22.34; Thu, 20 May 2021 03:22:34 -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=Jpy8+oUU; 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 S236059AbhETKXw (ORCPT + 12 others); Thu, 20 May 2021 06:23:52 -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 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 @@ -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;