Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2223620imm; Thu, 18 Oct 2018 10:58:39 -0700 (PDT) X-Google-Smtp-Source: ACcGV61/lzB2oV3EaSHha+awE6qwTlrQGubUj11wLRQi3oDJMnZHvOlHk9VdsylkiUp0kG6qAguM X-Received: by 2002:a17:902:7b83:: with SMTP id w3-v6mr31136701pll.285.1539885519001; Thu, 18 Oct 2018 10:58:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539885518; cv=none; d=google.com; s=arc-20160816; b=YLcXTQY9SOaKnf02YofsUQpENC2CEXiskBwtkeoxawv8yqvoJkcVjiF8sQ3UgdpGeF Gxm22WQexU7TaCeCKKysN4PQwT+o5GR9mR0qehKHGUon7aAEdJgznW3eOclPqOmtOGEd 8OwaOotGbf3Q9tqJjrOd9bc9fkyXghSXRwSffxpTkw+Zl4GdvH7tQgpdVHjXZlVb3fWs HVA7acCQ/h1ZROgN8sU1PrSCGjXOxmzbN773ZHaaMUClOGv9gLczoQC7RzJJhF+V2hYo jAJEe09Sxy0myU71L3cVpr6mYa4xq5qwth5swBdQtTwiqtP9hM5NsP8hUTao5eEosR2y h8jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=R+/d0m5aqikQYd5mhRlUdgquvchRjppGvwAn9ArrETA=; b=lxSr8OUGMdgETfM7O4y4zpmZlbCbL2156UwDGApUPY2HDk0tPMQEUG9JuqqOSK4M3u EUGaSVOZi5GnQLSD1lwS177xB+Hj6gyHERRTMGcUHKCs60uf6Px6vbpCrSU0HILxn0Xh HZlXpGv6kksVxy8mqI5QjgcZIlmsS3kcyi1/87PfbmVf0yTeCro/+uoECBITMfXwWyH3 humT2MHj3/0Jo7bhQturfaJLAj49wBao1xCqBfTCUbkCwLRuJQxZuWyXLuQuPAi0Au54 uBjQONfsMQbRHBcqjU9XhR0j4w/aCP+KyAOdb5uxreikV/8Ib1Ihth7KswpPuG8gTp89 K0pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SBlMCIQI; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u5-v6si21547614pgm.268.2018.10.18.10.58.23; Thu, 18 Oct 2018 10:58:38 -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; dkim=pass header.i=@kernel.org header.s=default header.b=SBlMCIQI; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728843AbeJSB72 (ORCPT + 99 others); Thu, 18 Oct 2018 21:59:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:47122 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728086AbeJSB71 (ORCPT ); Thu, 18 Oct 2018 21:59:27 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D118F2145D; Thu, 18 Oct 2018 17:57:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539885442; bh=0VTEzbKenSSfLcTUtCevlaoy7Kf57DsWwHlNhS6GVeg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SBlMCIQII0yYQ93rMKL8tEDoiKHmw3baDslTl4Mcud4UJ4y1wvuMm9KOSzv42iuU6 IhO2yWJrPlYNdBCII5rgMiyGa42jmJuM8tSwnHyMtAIWbUANEtkwbx5XZBCsmShaVl TPCiExspZHf5g/Oae/Cd+EzgwrxfaYngnx1OjqRs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, YueHaibing , Ursula Braun , "David S. Miller" , Sasha Levin Subject: [PATCH 4.18 27/53] net/smc: fix sizeof to int comparison Date: Thu, 18 Oct 2018 19:54:20 +0200 Message-Id: <20181018175421.660219096@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181018175416.561567978@linuxfoundation.org> References: <20181018175416.561567978@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: YueHaibing [ Upstream commit 381897798a94065ffcad0772eecdc6b04a7ff23d ] 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. Signed-off-by: YueHaibing Signed-off-by: Ursula Braun Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- 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 @@ -405,14 +405,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;