From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04BCAC10DCE for ; Sun, 8 Mar 2020 19:59:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D4EAE206D5 for ; Sun, 8 Mar 2020 19:59:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726352AbgCHT7g (ORCPT ); Sun, 8 Mar 2020 15:59:36 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:17096 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726336AbgCHT7g (ORCPT ); Sun, 8 Mar 2020 15:59:36 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 028JwfvN026461 for ; Sun, 8 Mar 2020 15:59:35 -0400 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ym8n6bh71-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sun, 08 Mar 2020 15:59:35 -0400 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 8 Mar 2020 19:59:33 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) 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) Sun, 8 Mar 2020 19:59:31 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 028JxTSF46137590 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 8 Mar 2020 19:59:29 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CBB9EA405B; Sun, 8 Mar 2020 19:59:29 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 653AFA4054; Sun, 8 Mar 2020 19:59:29 +0000 (GMT) Received: from [9.145.159.148] (unknown [9.145.159.148]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Sun, 8 Mar 2020 19:59:29 +0000 (GMT) Subject: Re: [PATCH net] net/smc: cancel event worker during device removal To: Leon Romanovsky Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-s390@vger.kernel.org, heiko.carstens@de.ibm.com, raspl@linux.ibm.com, ubraun@linux.ibm.com References: <20200306134518.84416-1-kgraul@linux.ibm.com> <20200308150107.GC11496@unreal> From: Karsten Graul Organization: IBM Deutschland Research & Development GmbH Date: Sun, 8 Mar 2020 20:59:33 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200308150107.GC11496@unreal> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 20030819-4275-0000-0000-000003A988A4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20030819-4276-0000-0000-000038BE9D75 Message-Id: <0b5d992d-2447-1606-f8ce-73801643160a@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-03-08_07:2020-03-06,2020-03-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 spamscore=0 phishscore=0 bulkscore=0 malwarescore=0 clxscore=1015 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003080150 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 08/03/2020 16:01, Leon Romanovsky wrote: > On Fri, Mar 06, 2020 at 02:45:18PM +0100, Karsten Graul wrote: >> During IB device removal, cancel the event worker before the device >> structure is freed. In the worker, check if the device is being >> terminated and do not proceed with the event work in that case. >> >> Fixes: a4cf0443c414 ("smc: introduce SMC as an IB-client") >> Reported-by: syzbot+b297c6825752e7a07272@syzkaller.appspotmail.com >> Signed-off-by: Karsten Graul >> Reviewed-by: Ursula Braun >> --- >> net/smc/smc_ib.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/net/smc/smc_ib.c b/net/smc/smc_ib.c >> index d6ba186f67e2..5e4e64a9aa4b 100644 >> --- a/net/smc/smc_ib.c >> +++ b/net/smc/smc_ib.c >> @@ -240,6 +240,9 @@ static void smc_ib_port_event_work(struct work_struct *work) >> work, struct smc_ib_device, port_event_work); >> u8 port_idx; >> >> + if (list_empty(&smcibdev->list)) >> + return; >> + > > How can it be true if you are not holding "smc_ib_devices.lock" during > execution of smc_ib_port_event_work()? > It is true when smc_ib_remove_dev() runs before the work actually started. Other than that its only a shortcut to return earlier, when the item is removed from the list after the check then the processing just takes a little bit longer...its still save. >> for_each_set_bit(port_idx, &smcibdev->port_event_mask, SMC_MAX_PORTS) { >> smc_ib_remember_port_attr(smcibdev, port_idx + 1); >> clear_bit(port_idx, &smcibdev->port_event_mask); >> @@ -582,6 +585,7 @@ static void smc_ib_remove_dev(struct ib_device *ibdev, void *client_data) >> smc_smcr_terminate_all(smcibdev); >> smc_ib_cleanup_per_ibdev(smcibdev); >> ib_unregister_event_handler(&smcibdev->event_handler); >> + cancel_work_sync(&smcibdev->port_event_work); >> kfree(smcibdev); >> } >> >> -- >> 2.17.1 >> -- Karsten (I'm a dude)