Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3878088imm; Mon, 17 Sep 2018 04:50:14 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ/YN8tzwy633OEfkXkr9U2mD1W1OtBLVK1YvWLeIcia/hcVvu4VgAmEI4v20sz5kZZok9W X-Received: by 2002:a17:902:b190:: with SMTP id s16-v6mr24974191plr.26.1537185013974; Mon, 17 Sep 2018 04:50:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537185013; cv=none; d=google.com; s=arc-20160816; b=McOtifJeADGrlQ6FpoaBkveGfb4eDBjp8AdHHqATeIe578LOvh7MOgwIe15F1EVbg6 nC1N1d7clL1ydZsLqtmXOnJ2unb97fL9J8OW1pIpQl/7shbq164dgGKLBCndvZpbDjoC lilEmJufNoR8fQy9qdJH+2OVFUG9yQpX4FMpT7HRPjL7156W0j/+0AEqmhM8TjI0Tfdf L8+EiV8gKudNukpX1ssXW+qF9U2hk0SgmOMJi1iMpXoakk3Es4K0hhXiA3ManTURCE0t AGsomPsEv9bDsJ2huwHD7rR+D8d3dApcIJjqnzXgb6fDhOLxeG2DU576YKPyVpWlN/P+ UMtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date:autocrypt :openpgp:from:references:cc:to:subject; bh=OFpP/pY+Y9Mm4vRdn25a6l0svPMYq/qC7ZIxN5cT5YE=; b=cuQzhSm6bABy0pqY4MV9PH7vz6xZTgiUCFdC7AKFG3S0BMd3vnZQDxOfeQ6Cc79icm n8e6vmB34Z3zDV2svL10flHHybACc6P9jPZL/GzEOwQcdTUYOECaSH0cuEDAYpQ5AW9t RAk9MtW3QuZNOXS/mCPqv0oYYUuZjbbOEAULpaj+iR/hbpi4OJNR0DgvsYWThbnFj664 qkVN/TL3fxrLcoEkd5PU+aFQJfmX7ChUi2pXTuxRx4S/wiablHgAH+uTpZXImhmIkl8J GUNB1GW5rUvpWv6fvKuFBwOZJwFIFcg8OR27IzAaq3/CEpN6D/E/LBZjpqjkcRNpw7qh gF7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e12-v6si14699693pfn.322.2018.09.17.04.49.58; Mon, 17 Sep 2018 04:50:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728300AbeIQRQU (ORCPT + 99 others); Mon, 17 Sep 2018 13:16:20 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33100 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728101AbeIQRQU (ORCPT ); Mon, 17 Sep 2018 13:16:20 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8HBnKHU050886 for ; Mon, 17 Sep 2018 07:49:21 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2mj9kp5ch3-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 17 Sep 2018 07:49:20 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 17 Sep 2018 12:49:14 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 17 Sep 2018 12:49:12 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w8HBnBXY43712734 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Sep 2018 11:49:11 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B7BBBAE04D; Mon, 17 Sep 2018 14:48:20 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 64AB8AE053; Mon, 17 Sep 2018 14:48:20 +0100 (BST) Received: from oc7163163645.ibm.com (unknown [9.145.57.131]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 17 Sep 2018 14:48:20 +0100 (BST) Subject: Re: [PATCH net-next] net/smc: cast sizeof to int for comparison To: YueHaibing Cc: davem@davemloft.net, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org References: <20180915100036.20100-1-yuehaibing@huawei.com> <554a145a-d59d-9033-1702-4987a9c4bc94@linux.ibm.com> From: Ursula Braun Openpgp: preference=signencrypt Autocrypt: addr=ubraun@linux.ibm.com; prefer-encrypt=mutual; keydata= xsFNBFfk6uIBEADL7CmNIA6b1fxIX9RZltqQwLRemtjMyS1iSLenbaS0NMF2MLWgSsXyuy0A 0Bz5h+xlO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geGUlTQ8KSnqPt1weEgJK7dLkX6XAi8AEQEAAcLBZQQYAQIADwUCV+Tq4gIbDAUJ EswDAAAKCRDMvao0xe1mRax3D/9Y4D2ANmumdJgvEAPLdEm3kLEL858HVx7GJolVrA9szN3a 82YVrJiaXgSVf3j6hSl1tI2qeSRTLNzgfFJUP7EI8WAMI0HV70Ilh3b6HEq7Mcts9uEFasz1 FidTJ0P4oM8mGVuWk47ozXoqIFtyqDfV9lKRaj8oC8gW9zDcNeQXdJzGbjR8WQa2J4BjN2ir G1uP1uWmXa9BhZYFQizhRkboZvkVHQNw6MxkQPhK1DNdQb+Z2uH8ELD41Kw3nxLnIHb3w7Ff mS8HBL+cu9sNWrW2TXZ1NTJucTg3+2zRHnpGzt11roz5xgEWxPRraZo1SsPOJ5eAxi2u/JNo AFLDNjI9K6N5ZJQfJSlbQ9+6nOzW1th8K2iPcPWuWbplQKeaRo6UQCafCJaj+CxC2iTzmzau Sw+xokHdgtDvSBFHvpJf0atERNKd5bWcJGtpxQxPQlx/XsWm4pB4XXlbk1WjOoFQeRQOyWCv eHRz7wGpY0fe9Q/UWkV40gLoP6d9BD9ZWbGvvT2NZtDCnaHTZ/trtADgxno5TVdr3VzIHah3 mLlLUk+oxMnqJvLTPXppz2/0AsGbEFcLs6fO7P1zr48yAGzNqXlZCiCUZ5DPqvAeOEFHiJUh HjXBWPHQYZeG0DNdRY/dunPOGKIYwUlSY/SaIGvstrmeIGlMBd3TqWZ8qIqvrg== Date: Mon, 17 Sep 2018 13:49:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 18091711-0028-0000-0000-000002FA4AFF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18091711-0029-0000-0000-000023B3FCCD Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-09-17_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809170124 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/17/2018 11:38 AM, YueHaibing wrote: > > On 2018/9/17 16:49, Ursula Braun wrote: >> >> >> On 09/15/2018 12:00 PM, YueHaibing wrote: >>> Comparing an int to a size, which is unsigned, causes the int to become >>> unsigned, giving the wrong result. kernel_sendmsg can return a negative >>> error code. >>> >> >> Thanks for reporting this issue! >> >>> Signed-off-by: YueHaibing >>> --- >>> net/smc/smc_clc.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c >>> index 83aba9a..fd0f5ce 100644 >>> --- a/net/smc/smc_clc.c >>> +++ b/net/smc/smc_clc.c >>> @@ -446,7 +446,7 @@ int smc_clc_send_proposal(struct smc_sock *smc, int smc_type, >>> vec[i++].iov_len = sizeof(trl); >>> /* due to the few bytes needed for clc-handshake this cannot block */ >>> len = kernel_sendmsg(smc->clcsock, &msg, vec, i, plen); >>> - if (len < sizeof(pclc)) { >>> + if (len < (int)sizeof(pclc)) { >>> if (len >= 0) { >>> reason_code = -ENETUNREACH; >>> smc->sk.sk_err = -reason_code; >>> >> >> Your fix helps, but I would like to follow the hint of Andreas Schwab, and split >> the return value check like this: >> >> --- >> net/smc/smc_clc.c | 14 ++++++-------- >> 1 file changed, 6 insertions(+), 8 deletions(-) >> >> --- a/net/smc/smc_clc.c >> +++ b/net/smc/smc_clc.c >> @@ -446,14 +446,12 @@ int smc_clc_send_proposal(struct smc_soc >> vec[i++].iov_len = sizeof(trl); >> /* due to the few bytes needed for clc-handshake this cannot block */ >> len = kernel_sendmsg(smc->clcsock, &msg, vec, i, plen); >> - if (len < sizeof(pclc)) { >> - if (len >= 0) { >> - reason_code = -ENETUNREACH; >> - smc->sk.sk_err = -reason_code; >> - } else { >> - smc->sk.sk_err = smc->clcsock->sk->sk_err; >> - reason_code = -smc->sk.sk_err; >> - } >> + if (len < 0) { >> + smc->sk.sk_err = smc->clcsock->sk->sk_err; >> + reason_code = -smc->sk.sk_err; >> + } else if (len < (int)sizeof(pclc)) { >> + reason_code = -ENETUNREACH; >> + smc->sk.sk_err = -reason_code; >> } >> >> return reason_code; >> >> Agreed? > > Yes, Need a new patch from me? > Not necessary, I will make sure this patch version is added to the smc code. >> >> Regards, Ursula >> >> >> >