Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1971509pxj; Sun, 16 May 2021 09:55:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9SslqrBWaXg8E6hPt++dYssV0hu0rTzjlMB/BtNb7TLplOXCpWhes45ozIDUhm5FLVNj5 X-Received: by 2002:a17:907:6288:: with SMTP id nd8mr8136883ejc.223.1621184105934; Sun, 16 May 2021 09:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621184105; cv=none; d=google.com; s=arc-20160816; b=EtUaHeIC6Nj1XL683zcWYGKbf0gM0/XurIOihoNBbiiXs2alAJi462JjkXizJRJ+0v vYgJIGgmC17E7vHmPa/5gVdM6yc7+AswtaUV4KLgEbw0ZhZNmM5xKux2UFmdxE10oh5S Y+edboR2EHfQ8bscsUase0JbxbkdHMiIRHlsoPOEWaFIiTaAoJrCtPgc0hde4TOP10Fs QnGibEl4STQ+qvIyquZAk6lEEhDBxdVJu9fHzU3nmsoT2ukK3qOVQva8ngte3dg39mKq ebAOkdls00MAvFoByQPhTJ1rZPH1qrS0BAlgDg2uxYQ9U0h9utT2tVfiGXuqkwl8OTAK wqPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=q5ECZIcoUPs3HAlpH6Ijrmp7zL3WNFZCaOs8cfYXoV0=; b=J0lfsjsjcNbKxBFuaoYwJuwIw0LZdq+0Sg5nETPZP/XftDDxkjPa1hohdf7AtMQNAZ 3TIiNxXZX/dHA6PymAGhvsgfFBQPRVD1QJ655Y4XbUP20WIodTBuijbNAwurUS/1P2h1 3wRMiicmQZh1Hws6jkFvz8F/EXoEhdEC5BK9GU2fXez0xjVPcg4IDNPjI62z1X8vN9hc 6uDzog0hN0WGrvQlba27NU6GzOnXysBpGu+4BAYDVhU4G9FkYEV6hFFuHapqzivWv5QH jARElEbJ8WBfIzlBHUsduQzy+N4avQEVNAeKs7AasOy2WDhHqvGB1+zV9oRyk5UJUrPf ASQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=TL7U9Zfr; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d24si4875036edp.529.2021.05.16.09.54.42; Sun, 16 May 2021 09:55:05 -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=@infradead.org header.s=casper.20170209 header.b=TL7U9Zfr; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234589AbhEPPjI (ORCPT + 99 others); Sun, 16 May 2021 11:39:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234525AbhEPPjI (ORCPT ); Sun, 16 May 2021 11:39:08 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EC94C061573; Sun, 16 May 2021 08:37:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=q5ECZIcoUPs3HAlpH6Ijrmp7zL3WNFZCaOs8cfYXoV0=; b=TL7U9Zfr3aJh/jnDQ12puoWSin 93SCdki1O4DSRodqbUoAJlrqQ/IGfR4grcXoTnR8grJzuW7kXlxeRGD8QOwE4ua401EL5Zfvp/RAU +ceYei1wcwtMOnNW51bf5FuInVAr8Gba1kyr5+6uCDG1aZhbiSBVvu9IwS+ErPyXUjTn78ifSZFmv AyqqOpe63Md/FvNu62hP7Hd+/eiA5nAk+K6H7ZL4bONR0YIcSQWHKqFUhIlovFk6wt+OOgZ6KrmbZ ytNxXPU6zRUNXNfJys27QoiCTL5tYfYixvWxGLsAgwSK10jitDuno0kubQ9OQ7m6sI0t20tDj151H Fv0yHfqA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1liIpe-00C6mi-5d; Sun, 16 May 2021 15:37:33 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 5F61630022B; Sun, 16 May 2021 17:37:28 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 24B782C8BD554; Sun, 16 May 2021 17:37:28 +0200 (CEST) Date: Sun, 16 May 2021 17:37:28 +0200 From: Peter Zijlstra To: Khaled Romdhani Cc: mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH-next] sched: Fix Null pointer derefrence Message-ID: References: <20210515164645.22849-1-khaledromdhani216@gmail.com> <20210515210238.GG5618@worktop.programming.kicks-ass.net> <20210516130129.GA32445@ard0534> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210516130129.GA32445@ard0534> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 16, 2021 at 02:01:29PM +0100, Khaled Romdhani wrote: > On Sat, May 15, 2021 at 11:02:38PM +0200, Peter Zijlstra wrote: > > On Sat, May 15, 2021 at 05:46:45PM +0100, Khaled ROMDHANI wrote: > > > The 'curr' variable could be NULL and derefrenced by > > > pick_next_entity. Fix this by adding a check that prevent > > > the invocation of pick_next_entity with a NULL passed argument. > > > > And why exactly is that a problem? > > > Within pick_next_entity, we could have 'left = curr'. > Thus the function wakeup_preempt_entity which is invoked > from pick_next_entity, derefrence the the sched entity 'left' > that may be a NULL passed argument. We call pick_next_entity() from pick_task_fair() (or pick_next_task_fair(), same argument for both), we only call it when cfs_rq->nr_running != 0. IOW we *know* there is at least one task. Therefore, if curr == NULL, we *must* have left. If you can't read code, stay away from Coverity, it's crap.