Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4913946rwb; Sun, 13 Nov 2022 17:03:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf5w1ATQ3TDATzqAlOunu21kH208dOMn1lvBMCKWoEbEwcS9sWWgIw+Tl/2V1RKE+sN9DD/C X-Received: by 2002:a50:9f61:0:b0:463:b8dc:893f with SMTP id b88-20020a509f61000000b00463b8dc893fmr9765026edf.28.1668387828686; Sun, 13 Nov 2022 17:03:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668387828; cv=none; d=google.com; s=arc-20160816; b=Ey00ScMam8evKOsoiAtOMQb7D6li3NMYbuDEpN8RUbk5xEgYJo+O+H99cBuD6neoCT QaBtN3C62ZgL2p8zwL0RnWMYdOAY/MljVZHfocXOrlDpJ/P2lR08YOR2TuOwW3slFtQm +tpHPM3fTB6OBc3wG0iTqa9vxwlc3qur3OcuJvDTN/yI5aB2MxDzOm/CsfnSSk3zEV4F Tup9rXuMQBqM41PSX38EVNu8CtC88/FUVFHXOqEbotymV9Knq991maOfTNCTkVwKZHet 7b1tJvdTdbDSc2b/WAeXTeji/L8TmeJmFRjZdHr9ucEvsmN/nWGCMnvzxJe0VkzNe+nq LJ1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=298xBiPdMw3VmsAX52yzXCL1aaXNA99BGmwtLF53JB0=; b=zrFynFtB9ukyblbY3lbV+e3joNalSiwsSXbyCEShDAlxDHfs6lZyFZ4B1hzMwPTWTP 5SFk2XI6xsHFUuWCo3gobMlo6bMasL+IEJlKBiv+K997lIgtKdRZ8xGtwWztOfusxYQ6 zrE0GafYYcZoK7cWJ9CKSRZ8Wv0aw79hrf0tINEsZ8W0SVFqQHvv9QcNkII5znIvqmBF xWyAlZ/2zy5f/5lAO5KbVD7g41MagDRvopUewG1yXDW9WaMwO4D+xguti07gJLaox7wI HQbjEHFdkeUN8OFsGZ29ZR4xuppM5rN9i88h2MOd2aYcsy/ytYaDUjz1SIlZ5VYiTGfa ezlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VW8Wea5c; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x17-20020a05640226d100b00457ebe79577si8358780edd.623.2022.11.13.17.03.26; Sun, 13 Nov 2022 17:03:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VW8Wea5c; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S235508AbiKNARG (ORCPT + 89 others); Sun, 13 Nov 2022 19:17:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229692AbiKNARE (ORCPT ); Sun, 13 Nov 2022 19:17:04 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3B75114B for ; Sun, 13 Nov 2022 16:17:02 -0800 (PST) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668385021; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=298xBiPdMw3VmsAX52yzXCL1aaXNA99BGmwtLF53JB0=; b=VW8Wea5ctOF2moD2CSTNeGJrdaxIT4Pp389xo1FAU08w5VNAxi4HJ/h+Tvc7h7Y82VolOQ c3Yaas9JDAd7yTQPwjU9xCmO5u+PfMVQ7Nb9t0QW+wIAGcAwiTJMgSBSPoYIlhNw3gVpvU 3TVubgYrHceb3FKCdyMkfUv4u5ronXzT2h2p4OkkDHMJN5AohcXDjF0csRW/rQ+OBOq1YL RaV5DigPcNg7TJopmcFuJxXrez4FVILe5OYopFZJ/gIifVsmBjyz2SSHvSS6ZbUAsaqu0H aL8euhlZPc6Hl2FMzQcjfE2T6VKqa5uooO1zMi6ijBUA6RcM08XX1/pDEbZvJg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668385021; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=298xBiPdMw3VmsAX52yzXCL1aaXNA99BGmwtLF53JB0=; b=l87wUFsJWebq3nni0+O4C9yku4r/95K7ZWS+vCWpJbNR+snG+knme4cn0IVehzpzz0wZhW BhwSv75dMDGs5eAg== To: =?utf-8?Q?Barnab=C3=A1s_P=C5=91cze?= , linux-kernel@vger.kernel.org Cc: John Stultz Subject: Re: [PATCH v1] timerqueue: use rb_entry_safe() in timerqueue_getnext() In-Reply-To: <20221027212506.3745164-1-pobrn@protonmail.com> References: <20221027212506.3745164-1-pobrn@protonmail.com> Date: Mon, 14 Nov 2022 01:17:00 +0100 Message-ID: <87v8nis83n.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 27 2022 at 21:37, Barnab=C3=A1s P=C5=91cze wrote: > When `timerqueue_getnext()` is called on an empty timerqueue > the returned rb_node pointer will be NULL. Using `rb_entry()` > on a potentially NULL pointer will only - coincidentally - work > if the offset of the rb_node member is 0. This is currently the > case for `timerqueue_node`, but should this ever change, > `timerqueue_getnext()` will no longer work correctly on empty > timerqueues. To avoid this, switch to using `rb_entry_safe()`. I agree with the change but not with the argumentation above. Whatever the current offset of node is does not matter at all, really. This is a blantant missing NULL pointer check which works by chance. So there is no weasel wording justfied about "coincidentally" and "might not longer work correctly". Just spell it out that this is a blantant bug and nothing else. Back then when that code got introduced rb_entry_safe() did not exist at all so it's even more obvious that this is simply a missing NULL pointer check, right? This also requires a Fixes: tag which flags the commit which introduces this bug. Thanks, tglx