From patchwork Mon May 10 10:20:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 433072 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp2721005jao; Mon, 10 May 2021 03:57:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycX7jkf10OywrU+Boj0JL7xIyCN97Sd/8bs4L3fygX2T5Gnq0Dsy9TaoQlrGX49pmazKuX X-Received: by 2002:aa7:dbcd:: with SMTP id v13mr28465523edt.59.1620644265702; Mon, 10 May 2021 03:57:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620644265; cv=none; d=google.com; s=arc-20160816; b=kt/S1ZudMDNFXN6PIt/9x8uIEW1sQGUPrSbbfbvpV22jbMLCBajbLSXUSoIzMdIKK2 jXtzS2lkVGP/Yhrg+1eAbKsIV2BkBJrgXwvQW8QNiYEJ7kg6KIHelSYqwfpKkLOiSnQ4 rmbEvJCzHsYvdJkTlrFjaAaJw2Cl3xfTCprVnfCKtHAK7iNG3r9xsR9EXN212pK/pPp2 0UNGsVlNRCmxcPdXHpXxw4OzjIhBfecnRZLo5h5Jr7ZzhBM+fOzKgWRVckEtDwpGoqI8 2WxkzoEqsgzGkHF9qlXtGkFajDyk5uxYXTqGQWFkfbhWxDdFXOcREfPCGvM8PVTKU3RD UyDg== 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=DXlnq0aWud/fnMo/2wTp+6EzVkLdA2p0NG5ewyC66vo=; b=YZesrb8sMbYsXALcK/UuceRInoSecvy3MhBl+5+8VHicfsYxRyuSj2DHqjfGONEQ7l JqVKNpHNSoW4XgbQXqhshdWX2sU72kKe3FGgIrojhZt5bv3srWb+lG+iRj+GGp7twmyt w8ctvdxpQPqiXE9oh2KyiVp5oecT1Ch37XXKj6w2iPm3xOA3bEnf2cEVs2gY7eESKSDy SBozDElRz2x5XJ2AiOluTFkfaEhc5HbUC/juS+JvyuAQ6pRMajwLLba8wyDBVtIfLS7C x3kJ4HXxvHEbshw9AXmv9XGq3gVN2S+0DwyDHYrvZt/JCniAh/h2UZqwCpQSC6jQshHY Kydw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fOcSDpZI; 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 r17si13500365edw.273.2021.05.10.03.57.45; Mon, 10 May 2021 03:57:45 -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=fOcSDpZI; 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 S232589AbhEJK6T (ORCPT + 12 others); Mon, 10 May 2021 06:58:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:42240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232344AbhEJKxd (ORCPT ); Mon, 10 May 2021 06:53:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B36ED61288; Mon, 10 May 2021 10:41:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643290; bh=6aDdcVRD5XDeRzPu5cDpy+CeTozswdh322xviITHbFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fOcSDpZIURV6OHS7wc60HVYHfGaKdROWohyMmAzBrfaZ6ykLtBmyepZZBUybs0Ows pqUNLU1mOwPFgAT6Zmko6wMxxejCzsu2yHekoiZU78EHYL3FBZCkcXBusVOWgDMyZC i1JkEkRcoKZNEvMX6yHMl8N/YzR4tTMV46EBJw8k= 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.10 255/299] security: commoncap: fix -Wstringop-overread warning Date: Mon, 10 May 2021 12:20:52 +0200 Message-Id: <20210510102013.371437536@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@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 @@ -391,7 +391,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;