Received: by 10.192.165.148 with SMTP id m20csp2924155imm; Mon, 7 May 2018 03:41:32 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqjD/8IEyEbroWazOKgq8KWZzzjC3h/UhLjFwlGLnIHJBCksX2r2oMHuPEoSWUUPS9/IOlH X-Received: by 2002:a17:902:708a:: with SMTP id z10-v6mr34821167plk.283.1525689692153; Mon, 07 May 2018 03:41:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525689692; cv=none; d=google.com; s=arc-20160816; b=NsKNSk7mFZ/AzsnsDoHqK/r6zMoHUy9Ht6QvP0YGSRIBzWkFevpxpL6sgTZsMPkre+ F0YaMOADGo7yEtnbxbbtmAaZwncGoSLTEbEkzE+hS69VYEhKtaCx2+k3QvmCgHm3VI95 2rcGqNDaEJ0s63k8naVy3plCy6NddShzJJxw6uD6gt4YH1j3ays5dD9peyEVjoSRnk1T 0lzo7S8pSvysjjDZwCeLcgmbXks68c8g47Py1hlvyzQ6kr10BQa4LriIoX+NS+m23GYA D8TY2NSRyut0FBpT39Uova6adT7E6O3yd9svHHO0VA2tBB4v8qh3uof6chRrKqd6fKYv rQ0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=SeEQalLboYdW1UB39gJhxP8uxSKCtBl54UFGqmJoFyg=; b=hA/twpI4SKhUBXDOxErqbtbNZcpWW/Adsrp6DTUljpkCs/v6wh616MwI5P/86dhDlU cIP6aL8BJSpZYKpBwFPa1vwxBre2cfdPEEZ1xbEkygRCT6MZnT21WKLqgvRq/oadw7X/ i8mQORIphqu/7ZfBdtVLd/q1fsvZfdF4TPXzT70tYS4UfnQm2zhetQ9UAHxPk3VLnf4D ZetbYbrzTEgt0zTZtI5nFeCJVVUzWxDr6uo1Oa2z7FBjoC4vGMaeezcTZj07IgvmsWYg ljlnzTAQiIxrk9GMxX+drZvWxAuqiX/pXv5rUMy4VA8E55VaehBKDVj8dkP1dgfS7SUl V6KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=Ajx2lAw+; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i74si22864582pfd.105.2018.05.07.03.41.18; Mon, 07 May 2018 03:41:32 -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=@oracle.com header.s=corp-2017-10-26 header.b=Ajx2lAw+; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752168AbeEGKkV (ORCPT + 99 others); Mon, 7 May 2018 06:40:21 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:47518 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751147AbeEGKkT (ORCPT ); Mon, 7 May 2018 06:40:19 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w47AVNuR096270; Mon, 7 May 2018 10:40:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type : in-reply-to; s=corp-2017-10-26; bh=SeEQalLboYdW1UB39gJhxP8uxSKCtBl54UFGqmJoFyg=; b=Ajx2lAw+7yIETliD9T3XZekN3N1V7sElYFc+8Dy2pF6tD7lOyYiGziqahON6WUXx6ONJ LHoVC3pYbNtONe35uwb2/U+mXjxuco7yiB4lK9SZ9wEGB8B6tn3zJo7UjN9fNYdCjfgX y6+4irGOIZbgxy7LZytnq1fs6zbdHP0Z3LbD5XryBfpoYl3Lb8Z9e2pX0LVSm46u+14J cf2PUwLuXTnDKP+uh5R46hhkBULqXsq4CE18Eg+RD0u+3xMw+G00rtNG2IsKfmDNbcJS EVV2SMQBQM/z4bHmBatpoeR38DQKe+jAF7G3J4JZXYjU/4e2KG4Qs2hy2rUjZqgIvp7h ng== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2hs24sbrq1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 07 May 2018 10:40:07 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w47Ae6uT017829 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 7 May 2018 10:40:06 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w47Ae4Ex014150; Mon, 7 May 2018 10:40:05 GMT Received: from mwanda (/197.254.35.146) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 07 May 2018 03:40:04 -0700 Date: Mon, 7 May 2018 13:39:54 +0300 From: Dan Carpenter To: kbuild@01.org, Wenwen Wang Cc: kbuild-all@01.org, Wenwen Wang , Kangjie Lu , Harsh Jain , Herbert Xu , "David S. Miller" , Atul Gupta , Michael Werner , Casey Leedom , "open list:CXGB4 CRYPTO DRIVER (chcr)" , open list Subject: Re: [PATCH] crypto: chtls - fix a missing-check bug Message-ID: <20180507103954.d3gfgyjnce2ctp4p@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1525546431-12535-1-git-send-email-wang6495@umn.edu> User-Agent: NeoMutt/20170609 (1.8.3) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8885 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805070110 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Wenwen, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on cryptodev/master] [also build test WARNING on v4.17-rc3 next-20180504] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Wenwen-Wang/crypto-chtls-fix-a-missing-check-bug/20180506-091039 base: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master :::::: branch date: 26 hours ago :::::: commit date: 26 hours ago New smatch warnings: drivers/crypto/chelsio/chtls/chtls_main.c:496 do_chtls_setsockopt() warn: potential pointer math issue ('crypto_info' is a 32 bit pointer) Old smatch warnings: drivers/crypto/chelsio/chtls/chtls_main.c:253 chtls_uld_add() error: buffer overflow 'cdev->rspq_skb_cache' 32 <= 32 drivers/crypto/chelsio/chtls/chtls_main.c:350 chtls_recv_packet() error: double free of 'skb' drivers/crypto/chelsio/chtls/chtls_main.c:390 chtls_recv_rsp() error: double free of 'skb' drivers/crypto/chelsio/chtls/chtls_main.c:408 chtls_recv() error: double free of 'skb' # https://github.com/0day-ci/linux/commit/183b5e3e71c75e3149dac2698883f0bd63a89c75 git remote add linux-review https://github.com/0day-ci/linux git remote update linux-review git checkout 183b5e3e71c75e3149dac2698883f0bd63a89c75 vim +496 drivers/crypto/chelsio/chtls/chtls_main.c a0894394 Atul Gupta 2018-03-31 461 a0894394 Atul Gupta 2018-03-31 462 static int do_chtls_setsockopt(struct sock *sk, int optname, a0894394 Atul Gupta 2018-03-31 463 char __user *optval, unsigned int optlen) a0894394 Atul Gupta 2018-03-31 464 { a0894394 Atul Gupta 2018-03-31 465 struct tls_crypto_info *crypto_info, tmp_crypto_info; a0894394 Atul Gupta 2018-03-31 466 struct chtls_sock *csk; a0894394 Atul Gupta 2018-03-31 467 int keylen; a0894394 Atul Gupta 2018-03-31 468 int rc = 0; a0894394 Atul Gupta 2018-03-31 469 a0894394 Atul Gupta 2018-03-31 470 csk = rcu_dereference_sk_user_data(sk); a0894394 Atul Gupta 2018-03-31 471 a0894394 Atul Gupta 2018-03-31 472 if (!optval || optlen < sizeof(*crypto_info)) { a0894394 Atul Gupta 2018-03-31 473 rc = -EINVAL; a0894394 Atul Gupta 2018-03-31 474 goto out; a0894394 Atul Gupta 2018-03-31 475 } a0894394 Atul Gupta 2018-03-31 476 a0894394 Atul Gupta 2018-03-31 477 rc = copy_from_user(&tmp_crypto_info, optval, sizeof(*crypto_info)); a0894394 Atul Gupta 2018-03-31 478 if (rc) { a0894394 Atul Gupta 2018-03-31 479 rc = -EFAULT; a0894394 Atul Gupta 2018-03-31 480 goto out; a0894394 Atul Gupta 2018-03-31 481 } a0894394 Atul Gupta 2018-03-31 482 a0894394 Atul Gupta 2018-03-31 483 /* check version */ a0894394 Atul Gupta 2018-03-31 484 if (tmp_crypto_info.version != TLS_1_2_VERSION) { a0894394 Atul Gupta 2018-03-31 485 rc = -ENOTSUPP; a0894394 Atul Gupta 2018-03-31 486 goto out; a0894394 Atul Gupta 2018-03-31 487 } a0894394 Atul Gupta 2018-03-31 488 a0894394 Atul Gupta 2018-03-31 489 crypto_info = (struct tls_crypto_info *)&csk->tlshws.crypto_info; a0894394 Atul Gupta 2018-03-31 490 a0894394 Atul Gupta 2018-03-31 491 switch (tmp_crypto_info.cipher_type) { a0894394 Atul Gupta 2018-03-31 492 case TLS_CIPHER_AES_GCM_128: { 183b5e3e Wenwen Wang 2018-05-05 493 /* Obtain version and type from previous copy */ 183b5e3e Wenwen Wang 2018-05-05 494 crypto_info[0] = tmp_crypto_info; 183b5e3e Wenwen Wang 2018-05-05 495 /* Now copy the following data */ 183b5e3e Wenwen Wang 2018-05-05 @496 rc = copy_from_user(crypto_info + sizeof(*crypto_info), 183b5e3e Wenwen Wang 2018-05-05 497 optval + sizeof(*crypto_info), 183b5e3e Wenwen Wang 2018-05-05 498 sizeof(struct tls12_crypto_info_aes_gcm_128) 183b5e3e Wenwen Wang 2018-05-05 499 - sizeof(*crypto_info)); a0894394 Atul Gupta 2018-03-31 500 a0894394 Atul Gupta 2018-03-31 501 if (rc) { a0894394 Atul Gupta 2018-03-31 502 rc = -EFAULT; a0894394 Atul Gupta 2018-03-31 503 goto out; a0894394 Atul Gupta 2018-03-31 504 } a0894394 Atul Gupta 2018-03-31 505 a0894394 Atul Gupta 2018-03-31 506 keylen = TLS_CIPHER_AES_GCM_128_KEY_SIZE; a0894394 Atul Gupta 2018-03-31 507 rc = chtls_setkey(csk, keylen, optname); a0894394 Atul Gupta 2018-03-31 508 break; a0894394 Atul Gupta 2018-03-31 509 } a0894394 Atul Gupta 2018-03-31 510 default: a0894394 Atul Gupta 2018-03-31 511 rc = -EINVAL; a0894394 Atul Gupta 2018-03-31 512 goto out; a0894394 Atul Gupta 2018-03-31 513 } a0894394 Atul Gupta 2018-03-31 514 out: a0894394 Atul Gupta 2018-03-31 515 return rc; a0894394 Atul Gupta 2018-03-31 516 } a0894394 Atul Gupta 2018-03-31 517 --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation