From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx01.omp.ru (mx01.omp.ru [90.154.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6C2D208A4 for ; Fri, 6 Sep 2024 20:30:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.154.21.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725654615; cv=none; b=pU66lCNkUs4g2eAJeGxfDXpW5GVxKWTYtp4313722Vsn8HGRAhTc2TtAAQfGGEIkc8rk4117SV3t1lcPShufwqnPPfmypMMOdyXLb24cfUUa8RotZjO6LRxjsbVgBU/0N0kBi3Mpwsy975LFDzlvbRo0kJMuQM+zTbCo9mUalnw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725654615; c=relaxed/simple; bh=hJHF4v7aSf47GY/DPzV56HvVJuFbMVg6ELYEezF1950=; h=From:Subject:To:CC:References:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=R1RO1gFOz/Rbs7HgHL3oyhZNJr/jRrrjhiJmh+Kv7R2HqEKf9J0eyYm/QcNzmo77dL0mOTymeP5YqFxG9ROd9GhA7gfAtBk0JPzWX8HCdx+6m+MXev4jmqjIC6JBxEuGdhLPkwx1l+mk0rvR2STL/l6eRW08HqY7GlRe2Msg3tQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=omp.ru; spf=pass smtp.mailfrom=omp.ru; arc=none smtp.client-ip=90.154.21.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=omp.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=omp.ru Received: from [192.168.1.105] (178.176.75.14) by msexch01.omp.ru (10.188.4.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1258.12; Fri, 6 Sep 2024 23:29:48 +0300 From: Sergey Shtylyov Subject: Re: [PATCH] irqchip/gic: prevent buffer overflow in gic_ipi_send_mask() To: Marc Zyngier , Thomas Gleixner CC: , References: <048ff3bb-09d1-2e60-4f3b-611e2bfde7aa@omp.ru> <87cyli5zj7.ffs@tglx> <86o752v8xs.wl-maz@kernel.org> Organization: Open Mobile Platform Message-ID: Date: Fri, 6 Sep 2024 23:29:47 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <86o752v8xs.wl-maz@kernel.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: msexch01.omp.ru (10.188.4.12) To msexch01.omp.ru (10.188.4.12) X-KSE-ServerInfo: msexch01.omp.ru, 9 X-KSE-AntiSpam-Interceptor-Info: scan successful X-KSE-AntiSpam-Version: 6.1.1, Database issued on: 09/06/2024 20:17:39 X-KSE-AntiSpam-Status: KAS_STATUS_NOT_DETECTED X-KSE-AntiSpam-Method: none X-KSE-AntiSpam-Rate: 59 X-KSE-AntiSpam-Info: Lua profiles 187598 [Sep 06 2024] X-KSE-AntiSpam-Info: Version: 6.1.1.5 X-KSE-AntiSpam-Info: Envelope from: s.shtylyov@omp.ru X-KSE-AntiSpam-Info: LuaCore: 32 0.3.32 766319f57b3d5e49f2c79a76e7d7087b621090df X-KSE-AntiSpam-Info: {rep_avail} X-KSE-AntiSpam-Info: {Tracking_from_domain_doesnt_match_to} X-KSE-AntiSpam-Info: {relay has no DNS name} X-KSE-AntiSpam-Info: {SMTP from is not routable} X-KSE-AntiSpam-Info: {Found in DNSBL: 178.176.75.14 in (user) dbl.spamhaus.org} X-KSE-AntiSpam-Info: omp.ru:7.1.1;127.0.0.199:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1 X-KSE-AntiSpam-Info: FromAlignment: s X-KSE-AntiSpam-Info: ApMailHostAddress: 178.176.75.14 X-KSE-AntiSpam-Info: {DNS response errors} X-KSE-AntiSpam-Info: Rate: 59 X-KSE-AntiSpam-Info: Status: not_detected X-KSE-AntiSpam-Info: Method: none X-KSE-AntiSpam-Info: Auth:dmarc=temperror header.from=omp.ru;spf=temperror smtp.mailfrom=omp.ru;dkim=none X-KSE-Antiphishing-Info: Clean X-KSE-Antiphishing-ScanningType: Heuristic X-KSE-Antiphishing-Method: None X-KSE-Antiphishing-Bases: 09/06/2024 20:21:00 X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: Clean, bases: 9/6/2024 7:13:00 PM X-KSE-Attachment-Filter-Triggered-Rules: Clean X-KSE-Attachment-Filter-Triggered-Filters: Clean X-KSE-BulkMessagesFiltering-Scan-Result: InTheLimit On 9/5/24 10:47 AM, Marc Zyngier wrote: [...] >>> ARM GIC arch v2 spec claims support for just 8 CPU interfaces. However, >>> looking at the GIC driver's irq_set_affinity() method, it seems that the >>> passed CPU mask may contain the logical CPU #s beyond 8, and that method >>> filters them out before reading gic_cpu_map[], bailing out with >>> -EINVAL. >> >> The reasoning is correct in theory, but in reality it's a non problem. >> >> Simply because processors which use this GIC version cannot have more >> than 8 cores. >> >> That means num_possible_cpus() <= 8 so the cpumask handed in cannot have >> bits >= 8 set. Ergo for_each_cpu() can't return a bit which is >= 8. > > That. That? :-) > The irq_set_affinity() check exists because the affinity can be > provided by userspace, and used to be be *anything*. Since In this case you mean gic_set_affinity(), right? > 33de0aa4bae98, the affinity that the driver gets is narrowed to what > is actually *online*. What I haven't quite understood from my (cursory) looking at the GICv2 spec (and the GIC driver) is why only one CPU (with a lowest #) is selected from *mask_val before writing to GICD_GIC_DIST_TARGET, while the spec holds that an IRQ can be forwarded to any set of 8 CPU interfaces... > So we could actually relax the check in the driver (not that it really > matters). Well, maybe in my copious free time... :-) > Thanks, > > M. MBR, Sergey