From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CAD54CD4F59 for ; Thu, 5 Sep 2024 07:48:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4SSKYZNcFr9YpKKlgjYACiG4JeGRix8+/1XbAd8VULE=; b=sHY0MfkEX+YA9QkukF80d5FI36 w6OxBgWqybc6iXzuCRnWv2pO/PfaVguSWNdvLJc/4tVsJxLzhk6UqlGqLUUX/hqxjZy///+KlppA4 kK+qDrGKkUSIeQi7QIg9O5uVu0/e0sqygGk+nk5qk0+wgOFnlrNN9OSDBemw8uphWVJS8kJiIM25z pdUE+2qzK9UF/MT1bs0lGNaattokGVxa4dvPm71LsA/ad4LytWp3EjpfQtOZmJUmMatyc817uKwuy 9pC6wFJMaj4vaMQIEj8bOzRdtd3xGoDhFRGYN2zNSmq0HxSB7f5u9hxI2lD6i9rUlsd8CopHt/JF5 HRl9WyvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm7E2-00000007Pwg-3VgH; Thu, 05 Sep 2024 07:48:19 +0000 Received: from nyc.source.kernel.org ([2604:1380:45d1:ec00::3]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm7D0-00000007PWi-42jJ for linux-arm-kernel@lists.infradead.org; Thu, 05 Sep 2024 07:47:16 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id EFA1CA4420F; Thu, 5 Sep 2024 07:47:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE594C4CEC4; Thu, 5 Sep 2024 07:47:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725522433; bh=R4geDy0qg5CNt1ZRUWzFP5pZjthysIlhRdPRx3tF/+M=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cBCdrPM3KpO1Rn3M6EvsRhFspoKzUJ/zjav0dN8BcGmrdfRYLLTjrsoAlPkNL+s7A FOFjXE5MDM4455jRPJUpQ7AZvYInpteYm4gsCa3M3rG/rbiBCfcEROVwsuJO9FcX5i 943HmoRKTFk9eJknvVvd9iuxXVp1uHxdR/mtXRMIi/vf9n0Lda/lccX9c0tACRXZHG B6woTN3xJRUPcQhUOHN0W64exhinK+pWUzKuQLcWpIKxCel4ZerGr76Vj6I0ZtxSR3 kS1RYrGvSJhro/h/a4h4qSZmi51+bai8Z/f0vpldm3qfy6RhmVVhfAGGIWY4QSTWZY fdPw4AD6KUqXQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sm7Cx-009r8s-Nz; Thu, 05 Sep 2024 08:47:11 +0100 Date: Thu, 05 Sep 2024 08:47:11 +0100 Message-ID: <86o752v8xs.wl-maz@kernel.org> From: Marc Zyngier To: Sergey Shtylyov , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] irqchip/gic: prevent buffer overflow in gic_ipi_send_mask() In-Reply-To: <87cyli5zj7.ffs@tglx> References: <048ff3bb-09d1-2e60-4f3b-611e2bfde7aa@omp.ru> <87cyli5zj7.ffs@tglx> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.4 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: s.shtylyov@omp.ru, tglx@linutronix.de, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240905_004715_108235_D26CF3FB X-CRM114-Status: GOOD ( 19.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 05 Sep 2024 08:29:32 +0100, Thomas Gleixner wrote: > > On Wed, Sep 04 2024 at 23:23, Sergey Shtylyov 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. The irq_set_affinity() check exists because the affinity can be provided by userspace, and used to be be *anything*. Since 33de0aa4bae98, the affinity that the driver gets is narrowed to what is actually *online*. So we could actually relax the check in the driver (not that it really matters). Thanks, M. -- Without deviation from the norm, progress is not possible.