Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp627593pxb; Tue, 14 Sep 2021 05:28:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7F7SIpRCf6moEq9lcutiBcAKjG0kSSUe+Bza1BfkH3YTwmQyOryIn4JA2GldFHioMmtDR X-Received: by 2002:a92:de0e:: with SMTP id x14mr7684719ilm.259.1631622500112; Tue, 14 Sep 2021 05:28:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631622500; cv=none; d=google.com; s=arc-20160816; b=Ten5vgcHhZiotxG4CFRHxcg+AIRwF1wc0LFGea2qQKrOkmg+Ih/xv7YlfBiR0BqITr rAdet+YDEgsZ2pR3k89Sx8iZuUg7lcJN2fX9GqpBPnW/hKxrppOh11oreS4xGQyZZ8ZI hzR/1qdFBCsqMqsMJT3q31ccN0jC6EWJ2nS4MGg7fe08fXvtAc3nBA4oZABqzupTCvvC 9bdZu6Uk4wM/MrjH92FAIqzVvYTohSc6rPJINLrHJQ/6aH2YUm557G6rwWkG7qUPg+qr HceY+3BA2dcVvt1t+f0qYLez3LfWw+DTV3AgQisHECnyU/xJg97vuOXY8sHsrzwdC/b/ Y3yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=YMs7eRVf7WZVlO2rvbc4ggFxzEshoEoI2sMVNW5jfHA=; b=JXCx8JpblglBo+asKXSIUbZgCDjHXobFc90/gNAmxakHBqyGptr9qEG88uRMzbsqKw S4E95y8ykInWNbxK5D2fQUk38G7FFHrPOdZyKNqgH9lFt49wlY1X6xmOzUaeE8Q3RMM8 n9oRqjf+w/5PbbT2eN7e+59JPAeOhdh6uFS8pLAIi0kY+Yf+LiFQL2eyq+nF4pbhbRlq wxtWbMYG/UpNIhul+03Bno9FvkhLRObHjzW/RY5YVMXci5306YXiOHG9CzP5NpP8vXqh TgHjB8vD4BA1s4HWAmX4itOAtYFxU+hP75YEFhkr1gfFviB7v3GE/ETeOq+rnYmiPVmM JBrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=S2dlEmMP; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=lOkQle13; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g126si9472880jag.77.2021.09.14.05.28.08; Tue, 14 Sep 2021 05:28:20 -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=@linutronix.de header.s=2020 header.b=S2dlEmMP; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=lOkQle13; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232781AbhINM2Z (ORCPT + 99 others); Tue, 14 Sep 2021 08:28:25 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:33268 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232801AbhINM2W (ORCPT ); Tue, 14 Sep 2021 08:28:22 -0400 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1631622424; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YMs7eRVf7WZVlO2rvbc4ggFxzEshoEoI2sMVNW5jfHA=; b=S2dlEmMPnzFVj0Yr5uaW98D0wHnA7TWdKIEKAmCdMMiVT6OP/CW2jFfN9iBoCONXaQ4Yyc ssirJ6oOfonmLhPrlyZVLTwQgcBSzS2VBJ6NVeOa0Bbro9p43Wy/Nux1XCYczHsdDS5KtN exPeb/irwKDHAbwg1iHTGJdl0t0T6VtpuU3BGdGciKXXtbN0EgtoZhx3KCMpbm63lvPMWe qGDR/FTp6jv54kQmHW4toU6OCns7qe4AtAu6t2M+kIW1NPtxQ8Zq4UZi1xErEjVDo2FsZj KCk8SsLmmdjtpi6rRclplQibStGD6h8kRnqx3ZNkxfGfmonjd5QsGrXXpQAoVw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1631622424; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YMs7eRVf7WZVlO2rvbc4ggFxzEshoEoI2sMVNW5jfHA=; b=lOkQle13+r8kObXOu+Agg331vU9fX/KVjjA+VrT7DumI9GZ3k9KbONNR0BEbYBbM3rHi5e ERtBgxzZ+TlZmPDQ== To: Jiasheng Jiang Cc: linux-kernel@vger.kernel.org Subject: Re:Re:[PATCH 6/6] irq: Potentially 'offset out of size' bug In-Reply-To: <1631609290-2830831-1-git-send-email-jiasheng@iscas.ac.cn> References: <1631609290-2830831-1-git-send-email-jiasheng@iscas.ac.cn> Date: Tue, 14 Sep 2021 14:27:04 +0200 Message-ID: <87k0jjcpgn.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 14 2021 at 08:48, Jiasheng Jiang wrote: >> On Fri, Sep 10 2021 at 03:26, Jiasheng Jiang wrote: >> The find_next_bit() use nr_irqs as size, and using it without >> any check might cause its returned value out of the sizei > > On Fri, Sep 10 2021 at 18:28, tglx wrote: >> Why exactly is this a problem? The return value has to be checked at the >> call site anyway. > > There is really a check at the call site, but the annotation of the > irq_get_next_irq() is 'Returns next irq number after offset or nr_irqs > if none is found', which tells the programmer should not check the > return value of it. In case of a programmer write a new call for the > irq_get_next_irq(), he may not check the return value because of the > annotation said. The return value has always to be checked because nr_irqs is guaranteed to be an invalid index. > Therefore, it had better to add the check inside of irq_get_next_irq() > to fit for the annotation. Care to look what find_next_bit(..., size) does? * Returns the bit number for the next set bit * If no bits are set, returns @size. So for: res = find_next_bit(addr, size, offset); res is guaranteed to be: offset < res <= size IOW. irq_get_next_irq() is doing exactly what the comment says. So again, which problem are you trying to solve? Thanks, tglx