From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751867AbdFEMjC (ORCPT ); Mon, 5 Jun 2017 08:39:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39606 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751657AbdFEMht (ORCPT ); Mon, 5 Jun 2017 08:37:49 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4081881233 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=oleg@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4081881233 Date: Mon, 5 Jun 2017 14:37:45 +0200 From: Oleg Nesterov To: zhongjiang Cc: akpm@linux-foundation.org, stsp@list.ru, Waiman.Long@hpe.com, mingo@kernel.org, mhocko@kernel.org, vbabka@suse.cz, linux-mm@kvack.org, linux-kernel@vger.kernel.org, qiuxishi@huawei.com Subject: Re: [PATCH] signal: Avoid undefined behaviour in kill_something_info Message-ID: <20170605123744.GA9807@redhat.com> References: <1496653897-53093-1-git-send-email-zhongjiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1496653897-53093-1-git-send-email-zhongjiang@huawei.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 05 Jun 2017 12:37:48 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/05, zhongjiang wrote: > > static int kill_something_info(int sig, struct siginfo *info, pid_t pid) > { > - int ret; > + int ret, vpid; > > if (pid > 0) { > rcu_read_lock(); > @@ -1395,8 +1395,12 @@ static int kill_something_info(int sig, struct siginfo *info, pid_t pid) > > read_lock(&tasklist_lock); > if (pid != -1) { > + if (pid == INT_MIN) > + vpid = INT_MAX; Well, this probably needs a comment to explain that this is just "avoid ub". And if we really want the fix, to me if (pid == INT_MIN) return -ESRCH; at the start makes more sense... Oleg.