From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751441AbdFEMt0 (ORCPT ); Mon, 5 Jun 2017 08:49:26 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:6867 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751346AbdFEMsZ (ORCPT ); Mon, 5 Jun 2017 08:48:25 -0400 Message-ID: <593552F3.4040407@huawei.com> Date: Mon, 5 Jun 2017 20:47:47 +0800 From: zhong jiang User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Oleg Nesterov CC: , , , , , , , , Subject: Re: [PATCH] signal: Avoid undefined behaviour in kill_something_info References: <1496653897-53093-1-git-send-email-zhongjiang@huawei.com> <20170605123744.GA9807@redhat.com> In-Reply-To: <20170605123744.GA9807@redhat.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.29.68] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.59355312.01D7,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 01af31100c42ef11e251fae4be2df03c Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017/6/5 20:37, Oleg Nesterov wrote: > 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. > > > . > ok, I will motify it in v2 shortly, Thanks Regards zhongjiang