Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2521354pxj; Mon, 10 May 2021 05:07:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwB0vJxi9qVbeQi16ZVy93PwgyTrwtHX5wA6dMNX73sQdh4xR3gEMj5GtOpC/+ez6kU4Kcx X-Received: by 2002:a5e:a704:: with SMTP id b4mr18232701iod.35.1620648326548; Mon, 10 May 2021 05:05:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620648326; cv=none; d=google.com; s=arc-20160816; b=JObdkycb8u1kIhyx+zgqIYkL44TS+7KlPOP/B9tC8u/KAV0LtBwZgtZI9eaEo5MeGg ZCf3Jd63f6iNX23ZUgWUu/lP0yopNsD63xPQPCv5dUFcD0OecqyowhBwNZs5RJMPv4Pv twm53I6dQN7GC+lq6lzmHNYzSHnEfZwx31KslsMHq4NGmpnRz3hFMVL7e7h/GDT268hA +D5IznFI+s0iF+4OHdb8d8Sn/Xh9YDXbSJcMpQQqQwHxExtCSe1FIaHIi8Zn13QuDi8A 8zDFPtEmnWRmM5bg9bkbG1MqpDSvyqvMCTn2gQ7nSm+k6ITrYBOFZtIqDkDsaGAaxk69 ZtFg== 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=ju+G1qqBZc98v2qpejg9rvqGDNqKoeMj84XppG3560JU19BgmDW7pDPoeLuo14uROm 46GU4iOX/p4jSKsf10GX8edqrf0f78qScCqn+41vLE54WNzKbMegahBHd9/VeuUouqLb +H6OpvtcD1lQ5SytZForf03t0bV36/pB32jztdWSlRgt5raMBUrxsy4YAJ2owh745BRZ BUmExMN/VljEj92Fa9Kt3ywatdzGHwdwC9WB4HCWAIVuIqskLz7fPAHTXghRUSH38Io7 eHpDsnpxUEyyTBG1O8ep36WLjJIRV68uBIu4ypeyeuf16B9IHSLBHVOOdeho2Albn+Xq IdCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wpXnFVee; 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 z10si13695541iln.4.2021.05.10.05.05.12; Mon, 10 May 2021 05:05:26 -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=wpXnFVee; 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 S244265AbhEJL6n (ORCPT + 99 others); Mon, 10 May 2021 07:58:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:44332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235854AbhEJLGW (ORCPT ); Mon, 10 May 2021 07:06:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A930D60FE3; Mon, 10 May 2021 10:56:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620644199; bh=6aDdcVRD5XDeRzPu5cDpy+CeTozswdh322xviITHbFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wpXnFVeeKCC2tns4e0LHH3pFZegfLWpAJQoXjMv6MsqzyKSuCqotc7nkOGXIzEikz SvUI0OGsVftVKxmy7DtIeut0iTDIvFlJ+qtmMTqiIK3WUEBIk3FcZpI94zPOdhx+4w 6QB/7luv9Z7olwx7e5aTr16rHvH5kHH3gR2Y2EEU= 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.11 293/342] security: commoncap: fix -Wstringop-overread warning Date: Mon, 10 May 2021 12:21:23 +0200 Message-Id: <20210510102019.796657790@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102010.096403571@linuxfoundation.org> References: <20210510102010.096403571@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 @@ -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;