Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2142581imm; Mon, 16 Jul 2018 03:02:12 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdJ91mVu9d1P2Od24QvA3BWxOeDYRxTO9R7q9qdvWHSNnTohroEaOSgRJdRcEVHCgBUppzP X-Received: by 2002:a62:c0c4:: with SMTP id g65-v6mr17239518pfk.72.1531735332807; Mon, 16 Jul 2018 03:02:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531735332; cv=none; d=google.com; s=arc-20160816; b=qKqzF08YhdrL93bQm4MEN6aWB0KTS2YjQtSe+wcq4K4AGAMF2nt8WGFawOwxQ5YRy1 7ZBExBNnK2XBEwmQMACAKwD9S0ga0ZHALcTs/7EpeGnlDpEyXD/zXbedSeIqVaoXG2nS Q3jRjSz7HTb74/01eWAK8sg/GrxzH0zXYXK8Ywcm9g16Jqqsx4RudLNajYUoLy9Lj3gG 7ROaZlb7/mrWf07/FxBzo7mQZ3c67Uy3VclYvj8x7/KwFS1ow0+tPTIsJmIEJZqpSCxv okKvXlG82MUYs7a5NBwfkxNLGOPGu0mF+U0m/SQwfKnuyCpnG2xPMOT9IVzjpmU2Kexi fjxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=NeRd7exvzsEqcB17ghDxZ3vMO8QY2zq/fky1eXrQQ7s=; b=PemO89ZgqIupot9Y+LhEBtLroRNrtMM8/JolpdVS4MT7BhVhWXXJUXKd4WeP/3GuPs MJEnb/tLRVvLak2Vkjqs0fNr/iJbqDAR6GronnLC2s2nR4lRX9Wvg6XhDsepzKCVR895 CAXjIASm4yt1Xx2n5n8h3nyICgt1cQajpR037Xns7901Trzvz41gAZBfZjuA/X91Az2R 0GznV5NfvcpPIfBUkJ4uoaV13M0y+eC+ptsKMRgoxvpsy9b0cRSd3DBgywmBVLPhXY+t RblRghlUHZUI+CqZOCEmHBLAVD8ZxatKy97/+X106hz8U7mK2E9bx4DCQ2KnNiimDVsw fPWg== 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 n125-v6si29675528pga.376.2018.07.16.03.01.58; Mon, 16 Jul 2018 03:02:12 -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 S1730246AbeGPK15 (ORCPT + 99 others); Mon, 16 Jul 2018 06:27:57 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57130 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728343AbeGPK14 (ORCPT ); Mon, 16 Jul 2018 06:27:56 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6G9xPIO125340 for ; Mon, 16 Jul 2018 06:01:17 -0400 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0b-001b2d01.pphosted.com with ESMTP id 2k8qacvvk6-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 16 Jul 2018 06:01:17 -0400 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Jul 2018 11:01:15 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 16 Jul 2018 11:01:14 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w6GA1CWn45547568 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 16 Jul 2018 10:01:12 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 113EB52057; Mon, 16 Jul 2018 13:01:31 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id C32AC52063; Mon, 16 Jul 2018 13:01:30 +0100 (BST) From: Ursula Braun To: davem@davemloft.net Cc: netdev@vger.kernel.org, linux-s390@vger.kernel.org, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, raspl@linux.ibm.com, linux-kernel@vger.kernel.org, eric.dumazet@gmail.com, lifeasageek@gmail.com Subject: [PATCH net 1/4] net/smc: take sock lock in smc_ioctl() Date: Mon, 16 Jul 2018 12:01:01 +0200 X-Mailer: git-send-email 2.16.4 X-TM-AS-GCONF: 00 x-cbid: 18071610-4275-0000-0000-0000029973EE X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18071610-4276-0000-0000-000037A1861F Message-Id: <20180716100101.79272-1-ubraun@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-16_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=707 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807160118 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ursula Braun SMC ioctl processing requires the sock lock to work properly in all thinkable scenarios. Problem has been found with RaceFuzzer and fixes: KASAN: null-ptr-deref Read in smc_ioctl Reported-by: Byoungyoung Lee Reported-by: syzbot+35b2c5aa76fd398b9fd4@syzkaller.appspotmail.com Signed-off-by: Ursula Braun --- net/smc/af_smc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 5334157f5065..a4381b38a521 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -1524,6 +1524,7 @@ static int smc_ioctl(struct socket *sock, unsigned int cmd, return -EBADF; return smc->clcsock->ops->ioctl(smc->clcsock, cmd, arg); } + lock_sock(&smc->sk); switch (cmd) { case SIOCINQ: /* same as FIONREAD */ if (smc->sk.sk_state == SMC_LISTEN) @@ -1573,8 +1574,10 @@ static int smc_ioctl(struct socket *sock, unsigned int cmd, } break; default: + release_sock(&smc->sk); return -ENOIOCTLCMD; } + release_sock(&smc->sk); return put_user(answ, (int __user *)arg); } -- 2.16.4