From patchwork Sat Feb 3 02:35:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 196151 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp819535dyc; Fri, 2 Feb 2024 18:51:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IFQOFhMrpnmr7YDVpbAotVqyqgXpdC81mcaGzRPhlO+uTHaC7VsfKsi27FdsrDxh/utgwMt X-Received: by 2002:a0c:ab4f:0:b0:68c:7f24:efe5 with SMTP id i15-20020a0cab4f000000b0068c7f24efe5mr63384qvb.60.1706928685640; Fri, 02 Feb 2024 18:51:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706928685; cv=pass; d=google.com; s=arc-20160816; b=iQ+C41HnXWJsnXY8JJAwUclgXvsTZ9qKhKTMbsinoRioCFKG4tLzFVSGGB/XSWPG5T nwsdFzZzzbuiCSXO5NJ6LMcgZOUXU8BQd7DprbsK+LwIVlbxXRJ4aN46b/6eaepUSCdb FQLa7DInZGAKMXyxHefzq1tI77RqgvH3YgV7Jj12pAcPz29jUyhpktQn4YdMgUOy3KYH d0yL9gE0NZcHxOyY9MlVZffSIfMq6wxBdh6qGkBokGrFv08oy1SYPq8y3XzTDtl4DpKr EFuMnoEHUi5G/WOZyFZdVS2to+GqA+N8fLfTpPx1ZINrt6Q7zI/6DueREDxz/F6ubG4I y7UA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jumcsyHAMPRdK6BBRrtXrViYw1o9e9jHI3H7NDZD9Tc=; fh=Jodx/TKvRCE+pLVh6Fip0+Gb+54wijciUa1kSjPLM6I=; b=PDt3v/7WuXDzAHn9iRptcQ4ULnhSxLlFHT008E8jUDhkjVxT2b/GRtHNqmNhjCzZd8 4gqgLKKi5m6cxNvQZ4qY3RzUc1n+OzubOgTtXQBvDJvVXMMKrl3UbG8+7XZ+YLOPbkMF L2e4KIppxuPKPtVUbFTdLZeUywbdpKQIewsA+WXAqc9qvjdzxYwH7QsbceCFtB5WI4N8 MLJx+mQVxVBu1+5XcRg/hL1171VABQ/+m8iwMdCrbGDFTgKU4A9/wLjw+cl8JSAkqw5m mkFwx8PMNLafr8JfovPAnl7ZI2DZYi+Jzf3TXfImI+d4ro3dWPUuwieZka1hqffVLt18 WcrA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Zo4s8Gx7; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-50849-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50849-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=1; AJvYcCXKnfBjnNwxzA+1OwXO/KZcwE2JCh/vOEtLDLlHUoXylWYaUOQTNhrJvocZe8+IcuaGiOtMtWlb2xwg9AakkmtGsj7Uzw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x7-20020a0cfe07000000b0068c805120b4si3404237qvr.55.2024.02.02.18.51.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 18:51:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50849-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Zo4s8Gx7; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-50849-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50849-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 562D41C2166E for ; Sat, 3 Feb 2024 02:51:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 796D45027F; Sat, 3 Feb 2024 02:38:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="Zo4s8Gx7" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A55481798A; Sat, 3 Feb 2024 02:37:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706927875; cv=none; b=m44vVjk8ILdgONr5wVqVwEyJSYOETO06vnOzNdvAVFvM8EH/XB3KouVXF0sN4WuHv2zM7Gmx7is2IQ9Gj7eUCn/5C4ZX/x3TmmP6yopq8gGuLsmTFyjoHxTcUXvhC+XYv02w08OeyU5hBUmFR/8jgyBtEkwLN/Mdir2JqrwHOdk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706927875; c=relaxed/simple; bh=AUzYa+W3vXThhkfZrkvq18z95m/MUhJSaK13Esrt9IU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NyL1+H13WDJV+XdlPg+zSnQ2IkC8CUD8P1JTZKryJtg31JiaA/b8VLtJxEh1UUS9O5tMJ3PRTGprrEZoYcjKDXC2dIzsP7jApgZYi8Bw2j+BqkomEO/Gb+XgbPBQHDSquadChSfMaJuHxM7HOS1tIYKNn5TER14rwuzY3MH6g7E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=Zo4s8Gx7; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 4132bROW029984; Sat, 3 Feb 2024 02:37:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=qcppdkim1; bh=jumcsyHAMPRdK6BBRrtX rViYw1o9e9jHI3H7NDZD9Tc=; b=Zo4s8Gx7nCs3+0vl2HUQCuFIHDx1bGEB8xB6 ZXRV5sU/kFKFUzuIJIXbZzjAQucU9yNTG8xiYa1hH9m+GJt5s74nIJMBaqdI104q xOO98fOW2/2zYM5Ozlr3CVVuC1Vu1FHJ1dRNAUn2GL4dKEDExRxyq8v1aUO08ZAb Jmm2o9sNDxavD21dhLNx1CepTOrk96BjzHW1rpnLNia+bFfFykgqh5VoRu2VzaAq WXP6UDszfUmgk3ClwDi+Dplh0TIYEi0iqW+kOEB7CWz4RuL+rooNR3SiVkOH3X9d N+ZdxHNE9ZOtNGJ5IQJDYPbBwxS5+GUC8Lpm0usBXzc+l1Yfpw== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w0ptwawr7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 03 Feb 2024 02:37:27 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 4132bIHf003503 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 3 Feb 2024 02:37:18 GMT Received: from hu-wcheng-lv.qualcomm.com (10.49.16.6) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Fri, 2 Feb 2024 18:37:17 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Mathias Nyman , Wesley Cheng Subject: [PATCH v13 02/53] xhci: fix off by one check when adding a secondary interrupter. Date: Fri, 2 Feb 2024 18:35:54 -0800 Message-ID: <20240203023645.31105-3-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240203023645.31105-1-quic_wcheng@quicinc.com> References: <20240203023645.31105-1-quic_wcheng@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 3rUdhidrD1t1Pnpgqa5TYwH6m5OxXRcN X-Proofpoint-GUID: 3rUdhidrD1t1Pnpgqa5TYwH6m5OxXRcN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-02_16,2024-01-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 malwarescore=0 mlxscore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 mlxlogscore=999 adultscore=0 impostorscore=0 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402030015 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789844453696595014 X-GMAIL-MSGID: 1789844453696595014 From: Mathias Nyman The sanity check of interrupter index when adding a new interrupter is off by one. intr_num needs to be smaller than xhci->max_interrupter to fit the array of interrupters. Luckily this doesn't cause any real word harm as xhci_add_interrupter() is always called with a intr_num value smaller than xhci->max_interrupters in any current kernel. Should not be needed for stable as 6.7 kernel and older only supports one interrupter, with intr_num always being zero. Reported-by: Dan Carpenter Closes: https://lore.kernel.org/linux-usb/e9771296-586d-456a-ac24-a82de79bb2e6@moroto.mountain/ Fixes: 4bf398e15aa4 ("xhci: split allocate interrupter into separate alloacte and add parts") Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20240125152737.2983959-3-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Wesley Cheng --- drivers/usb/host/xhci-mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index d00d4d937236..a7716202a8dd 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -2322,7 +2322,7 @@ xhci_add_interrupter(struct xhci_hcd *xhci, struct xhci_interrupter *ir, u64 erst_base; u32 erst_size; - if (intr_num > xhci->max_interrupters) { + if (intr_num >= xhci->max_interrupters) { xhci_warn(xhci, "Can't add interrupter %d, max interrupters %d\n", intr_num, xhci->max_interrupters); return -EINVAL;