Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp516471pxb; Wed, 20 Jan 2021 12:48:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJwOuMBRxpXK1VRxNV5AHTDMKaMEIRs0u8EOGb5UluJaSaXmGcJT195CzZmjMztr3M4FNhIq X-Received: by 2002:a17:906:804c:: with SMTP id x12mr7142803ejw.42.1611175683250; Wed, 20 Jan 2021 12:48:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611175683; cv=none; d=google.com; s=arc-20160816; b=c7JkuAxzbp9dWdMnyC87kEYDq9GlECTQ/6szNyfcgygAa9bFrjyYGqUQ+OMfQPno3T uBf/2IJDKhKFAZNUahCZk1NY09W0EKykXW192f1+zqb6qbREX2bXJGFI0D2OO1RMBu9I U0MDGcZf2kLYu0hF85T+V5x0XiL+wqSaInqCKxC1vcAqDitpBBYoaSDY6HyXCvMG2kOK rUn1BcA/lA+zURrc6JURKAMPzMvlauO1mR23kSJgbrzhJ32raMCrrUMBE+IrNm3fKT/e UaoPMhegbWdn1sxIsxx/tLamdn/4zQ9j36sY/PSC7SG0Nzp3fNnwF8ShYJkQ+WdeUxjQ H0KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=l4bZ7k3MLtL4D33E1D9YrozkMl3wQeHdeBeC/C0ogfE=; b=YPdRoQdSZBNbdjfKRlJOXBcFuVZ5l6elssZ5rmcBsSGW/h00zJmBRPeMVnPoOv9xLK LPpIJg9ex+0OBhInHSKncjBIhP/b5bxVBCiKfgUFkF4UL8gfQyGJiGY23gcCpdcHUA1b R87LdRt0heEto2jcr8U1EHBt0RJoaIUNxv6uOQTNRpb7qlJRZ6E0ZWmE6ljkipMbHdQo S5256oI1LYvAhuddMpksJqToTs4BqBaraLozRAQby7xNjDefBt4TsjEgHrd18Tomw7ms VR4Oxlhp+2JEzLx176LmEEGj7qu3dyhYqkl9NE1IlhYS/b2bKRFU5DfLjQqs8sxoMS+i 9rsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="EMmI/yHT"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t22si1018540ejb.452.2021.01.20.12.47.32; Wed, 20 Jan 2021 12:48:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="EMmI/yHT"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388511AbhATUoc (ORCPT + 99 others); Wed, 20 Jan 2021 15:44:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731842AbhATUnJ (ORCPT ); Wed, 20 Jan 2021 15:43:09 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BF13C061757; Wed, 20 Jan 2021 12:42:29 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id my11so3674935pjb.1; Wed, 20 Jan 2021 12:42:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=l4bZ7k3MLtL4D33E1D9YrozkMl3wQeHdeBeC/C0ogfE=; b=EMmI/yHTTV1Mpux7tKIPYfLFSTGkfH72QLHU1dgIqX1Y4igOtMYt0XoxjV37/m82QB BWmN+pKbES/bkyzb6tgjhZtElcy1O2JUH/FXnURIcZnrbc+u0sO3jN89LikTF0dg54ro IXp8PYLEGDRd1mZHqP109ZYQU7qAltNfcx11QCF5MqLt8Wt9h47lqxB9V/yGzS+WSNFv rMAMUGQ8UmnpaZLdwYW7YfsWwZxNSgZ3J0hUcoI9wKvdAOXngrq7kds/abp8Xnud15sZ FtjSm1uI/Yp5CIEEifMZLc3dxnHJGZlv8fjXGEe8632+cDpo6bcFSTlAhAURM29vrgu4 L1rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=l4bZ7k3MLtL4D33E1D9YrozkMl3wQeHdeBeC/C0ogfE=; b=Xk/g9PsTEZYBA1xBx7p0hBPVPM8bsbFMhwOseub0Ijj6aWCigkkVzvlf1wp3gb/xA8 Erx7qppX/1+OAL4m+7OXPI9NgrdG1TCMl6s1sc0KwyqmfZCHdLbWx81XDOB83UPFDGv/ B72paKzRVNIPciDZGMBnbIGep+gprlPStNBBHC2vxiLzFCh4bw5LuWhMMbF+JduNKQLH x9M+YyMZtDWrRhR4jMYK5tHM0fwzFjZiInE7ksK25vxcvqReY02Q5w+N6Wv1WzzrVFQc lKRMBmP7G5q9KdctliS90nfATQmzYPfdgKezqjGHDjCl7dDXAD+kBkSAVFdLkDsgCIdw +iEg== X-Gm-Message-State: AOAM533oFha7aB4zLRfvuXjm47nmAoeyy0MAXXgrcZmLX/XUSeoGumIc jNTUYiSTL/LQF3AVCaSaeVor6NUwF4Drl/AGju4= X-Received: by 2002:a17:902:9894:b029:da:5698:7f7b with SMTP id s20-20020a1709029894b02900da56987f7bmr11554332plp.78.1611175348636; Wed, 20 Jan 2021 12:42:28 -0800 (PST) MIME-Version: 1.0 References: <20210120102837.23663-1-xie.he.0141@gmail.com> In-Reply-To: <20210120102837.23663-1-xie.he.0141@gmail.com> From: Xie He Date: Wed, 20 Jan 2021 12:42:17 -0800 Message-ID: Subject: Re: [PATCH net v4] net: lapb: Add locking to the lapb module To: "David S. Miller" , Jakub Kicinski , Linux X25 , Linux Kernel Network Developers , LKML , Martin Schiller Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With this patch, there is still a problem that lapb_unregister may run concurrently with other LAPB API functions (such as lapb_data_received). This other LAPB API function can get the lapb->lock after lapb->lock is released by lapb_unregister, and continue to do its work. This is not correct. We can fix this problem by adding a new field "bool stop" to "struct lapb_cb" (just like "bool t1timer_stop, t2timer_stop"), and make every API function abort whenever it sees lapb->stop == true after getting the lock. Alternatively we can also require the callers (the LAPB drivers) to never call lapb_unregister concurrently with other LAPB APIs. They should make sure all LAPB API functions are only called after lapb_register ends and before lapb_unregister starts. This is a reasonable requirement, because if they don't follow this requirement, even if we do the fix in the LAPB module (as said above), the LAPB driver will still get the "LAPB_BADTOKEN" error from the LAPB module. This is not desirable and I think LAPB drivers should avoid this from happening. So I think this problem may not need to be fixed here in the LAPB module because the LAPB drivers should deal with this problem anyway. Please feel free to share your comment. Thanks!