Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3905240pxv; Mon, 26 Jul 2021 15:26:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyg5FISFkVlSPQnsVCHyG3HqSfXtshbju//hJVtbjTc71maIGzh7zJc59khUpLMXG52gQHf X-Received: by 2002:a05:6e02:dc8:: with SMTP id l8mr14632624ilj.5.1627338397111; Mon, 26 Jul 2021 15:26:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627338397; cv=none; d=google.com; s=arc-20160816; b=AatAzEn7HSQJoY7m4DOVV501WFPJOoRb8tkEWWgt8GGSBvf49pfdUEvD6kNejI6JRj Vcbt5nj9LJaR9PQdqRuaQYyBrtnYUtnJDgWsLzVI5rtw/LAzEHoUNCbOPCW+/nFzODdT i9T9b2nTH/UQUxGOvpxFLVhT44bwRM2QFCNUFhyhVh+r42/kXqvFe3IALKv70MvToOHr NoN3SaqA/Fq1PFbagwXXy8s5xuC34mAqTGnqICLYNPk5teAAFI50/7TazQ7oJfXGhtE1 wqtOLuNt/WdGPRZRdHY7D/KN429sBuHfBJFhybHk7RQU38zhoeTi5tDWWg8DMGI8bEdG px3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:dkim-signature; bh=V+YN/pr6U6avdjNltlEBndjqKop3RfqP+MM/c4xjz3Q=; b=SPWiiLPcez5GGxpqrskDlVzzabL8V9OISQ51MClEsTxIKdbr0p9f3LxKkzb8F2RT8L GurGNNg5xWkESw8BXUQF82ojxvSRzbhfAhpNI+vrPhxjTNdYR5sAncQSrNNpBBCCQJal L13K1mQYUmILP+dQTLS0WvQHHjKl39TbstQKZOZXRo6+uXOct66HseoEvQIpe8pfPArC yPh5vbKQh/LKhfrTmVMAZFnCwUzJn7XRZGkWnM62kV7IFM3++3brRuhBBtlQuz7GDLRh TeMy4EtdLBzIIHlJsTIOHTwU5GtHW6RRY4C4RmX9SRg18Zmjl/dpU35WjatSS0benMlw bYbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2021-07-09 header.b=ykyrjOAS; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=g6UPtY0o; 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t16si1214138ilm.159.2021.07.26.15.26.24; Mon, 26 Jul 2021 15:26:37 -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=@oracle.com header.s=corp-2021-07-09 header.b=ykyrjOAS; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=g6UPtY0o; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233660AbhGZVnt (ORCPT + 99 others); Mon, 26 Jul 2021 17:43:49 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:4902 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231990AbhGZVnt (ORCPT ); Mon, 26 Jul 2021 17:43:49 -0400 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16QMH7Td027592; Mon, 26 Jul 2021 22:23:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2021-07-09; bh=V+YN/pr6U6avdjNltlEBndjqKop3RfqP+MM/c4xjz3Q=; b=ykyrjOASaSyQxZLjC+zRL9sgMHnUrMs7Y1Ey18KpMmTn0ZPiBHGAlrqRxie5cwt2OWBW EjQwBpxsWjZg9owvrqT1pI9dGfyD9zOgWydhZN6nly1R3oeutM3+gjQYg0Dz2tg1L9Jx cUXMgtRoeJtx5+49jNo8YqBF2598TOun6QNelJic5sBKBVWT1KItdPuO1cKfgZm3S8iT tfR6bjt/vQDfFctx/oGgDRcZRZF9+FJa/jQNyN8XoPtUHZCB3+jolTeIjoXTEslljC4v Rz/Z/ZCVQD1tt0Dxdh+q26RePspDiwqtXDfjkYDpSMekD/3QkPKXTUVonvahsIaReuNd jw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=V+YN/pr6U6avdjNltlEBndjqKop3RfqP+MM/c4xjz3Q=; b=g6UPtY0owqQ5xa+glQgaCG90Pe7/LFWEB8bSu72eWxyg58ithH2M61IUXTtub14ZJspe P+0+t3yFRucRTUm2xY+UuqFOS3n6Byv7AnwBR8lfZClLsr1qhFVo6ZPnP1zUqsEfhHkt qqmR1V8zRwRwlQbq7iVWQKfm9TRDy6m2wJezSb1dLjyAlFUXBW5fc0D1rNawokDLhWJl KmiS6n0uMhFWO/hNVVvOtzYJNlM0SDybHDmNSav8t4rNHAT4v1jd2ikmdlQhubUdY8vi oXwYEfhC5RRZvFPapuwIK2eGLoDjEStHP3ADgUQ/GCZZ+qrlfhjNOCnH4PYy9yQ3Dq2U OA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3a234w0aby-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Jul 2021 22:23:47 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 16QLZcpk174200; Mon, 26 Jul 2021 22:23:46 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 3a23498676-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Jul 2021 22:23:46 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 16QMNfgE032477; Mon, 26 Jul 2021 22:23:44 GMT Received: from [192.168.0.104] (/49.207.206.224) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Jul 2021 15:23:41 -0700 Subject: Re: [External] : Re: [PATCH] 9p/xen: Fix end of loop tests for list_for_each_entry To: Stefano Stabellini , asmadeus@codewreck.org Cc: ericvh@gmail.com, lucho@ionkov.net, davem@davemloft.net, kuba@kernel.org, v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210725175103.56731-1-harshvardhan.jha@oracle.com> From: Harshvardhan Jha Message-ID: Date: Tue, 27 Jul 2021 03:53:37 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10057 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2107260127 X-Proofpoint-ORIG-GUID: AZHCkNvR_tEGLvOZUSHajP9U0_PfZDat X-Proofpoint-GUID: AZHCkNvR_tEGLvOZUSHajP9U0_PfZDat Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/07/21 3:00 am, Stefano Stabellini wrote: > On Mon, 26 Jul 2021, asmadeus@codewreck.org wrote: >> Harshvardhan Jha wrote on Sun, Jul 25, 2021 at 11:21:03PM +0530: >>> The list_for_each_entry() iterator, "priv" in this code, can never be >>> NULL so the warning would never be printed. >> >> hm? priv won't be NULL but priv->client won't be client, so it will >> return -EINVAL alright in practice? >> >> This does fix an invalid read after the list head, so there's a real >> bug, but the commit message needs fixing. > > Agreed > > >>> Signed-off-by: Harshvardhan Jha >>> --- >>> From static analysis. Not tested. >> >> +Stefano in To - I also can't test xen right now :/ >> This looks functional to me but if you have a bit of time to spare just >> a mount test can't hurt. > > Yes, I did test it successfully. Aside from the commit messaged to be > reworded: How's this? ===========================BEGIN======================================== 9p/xen: Fix end of loop tests for list_for_each_entry This patch addresses the following problems: - priv can never be NULL, so this part of the check is useless - if the loop ran through the whole list, priv->client is invalid and it is more appropriate and sufficient to check for the end of list_for_each_entry loop condition. Signed-off-by: Harshvardhan Jha --- From static analysis. Not tested. ===========================END========================================== > > Reviewed-by: Stefano Stabellini > Tested-by: Stefano Stabellini > > >>> --- >>> net/9p/trans_xen.c | 4 ++-- >>> 1 file changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c >>> index f4fea28e05da..3ec1a51a6944 100644 >>> --- a/net/9p/trans_xen.c >>> +++ b/net/9p/trans_xen.c >>> @@ -138,7 +138,7 @@ static bool p9_xen_write_todo(struct xen_9pfs_dataring *ring, RING_IDX size) >>> >>> static int p9_xen_request(struct p9_client *client, struct p9_req_t *p9_req) >>> { >>> - struct xen_9pfs_front_priv *priv = NULL; >>> + struct xen_9pfs_front_priv *priv; >>> RING_IDX cons, prod, masked_cons, masked_prod; >>> unsigned long flags; >>> u32 size = p9_req->tc.size; >>> @@ -151,7 +151,7 @@ static int p9_xen_request(struct p9_client *client, struct p9_req_t *p9_req) >>> break; >>> } >>> read_unlock(&xen_9pfs_lock); >>> - if (!priv || priv->client != client) >>> + if (list_entry_is_head(priv, &xen_9pfs_devs, list)) >>> return -EINVAL; >>> >>> num = p9_req->tc.tag % priv->num_rings;