Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2813636rwe; Mon, 29 Aug 2022 00:01:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR4mFeiCXzqsERNRqNNpujxGSVH976/Hyp3Lo4JtmHfzXq7Jvd8+D07cIuTv7GRdnHy43/ns X-Received: by 2002:aa7:c611:0:b0:447:844d:e5a2 with SMTP id h17-20020aa7c611000000b00447844de5a2mr15757926edq.10.1661756502465; Mon, 29 Aug 2022 00:01:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661756502; cv=none; d=google.com; s=arc-20160816; b=dyxb2rCPe4oiEmGf5JbgeBo0vvgl5qg8oKZOmhEwCrLRFlIpLD4zuT4kvDDFIoY1k/ V9+N/w/C6sBe/4u0/KvhX12BBEflwI2o2yKXR16ilbjHoWafQshhkNIhw3XgcsAnnOnN WqHrbBl3EfS/8L9Dut0MAH/bVhy6Y3pqssp8IyQcm1zvfqSYPaGQ8+2Cb9ke4gVEHpH5 wavP/0OuFrTd7EjwBqOuJsaMihCW4MYYrej7HykbWRoiNQdli9k45GiAn3jeXyOuX3Hx XrkIHFjYkCPB25VN2+5/itEdh/H32cPc3SvfgYR5HWr47fxGBYPwMqAJg3yIEivG/EJy ccwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=d0XLGL5mfncbPh3lhzLMsvGwbv0FlnsgLNAmMGSW4d4=; b=DK251B1uOsUaD3GY9n4D6yf6P0LK2uO8vv0qpe6ZpVcq3PeJnJmFB3f+OPBIWsCbcl BGCyPF4iAckG9NCwb4FLMls832F3YOfL4VjYrh3U/toS5xZV5pgI+SJkWl2Wr+6GBNr2 +iAjBoS60m0f5muTcVglp/XG9982eTGzjWhffjvuaG6zQx/2tyyKsq61pQo4MGm9WgE9 TUkmSukVrOslaRl4XihtWrR94l/UOiSRJWPWwPrVcbFaTj+rRkRC07pvcvQgK8F2vNXB Egd8brAsdaaa2PM3KERJEfC3LIKSRTEpB4F1MrFvTEou2nFMqIXtIWCzWDRSapSt+DDE dWqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i5-20020a1709064fc500b007317d093e6csi6372621ejw.808.2022.08.29.00.01.15; Mon, 29 Aug 2022 00:01:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229570AbiH2G7g (ORCPT + 99 others); Mon, 29 Aug 2022 02:59:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbiH2G7f (ORCPT ); Mon, 29 Aug 2022 02:59:35 -0400 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71E802124E for ; Sun, 28 Aug 2022 23:59:34 -0700 (PDT) Received: by mail-ej1-f53.google.com with SMTP id og21so13825525ejc.2 for ; Sun, 28 Aug 2022 23:59:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc; bh=d0XLGL5mfncbPh3lhzLMsvGwbv0FlnsgLNAmMGSW4d4=; b=bJtLBYyYDnLuguAy6LSO1Spvv836TnDC3U7IsKgoqSetAsi3jVEX+pqgzvBfD13NuP xO+L5Ii9BMCKaG8UDlA0lb01jSTMwxSQHkyJuU7YaVCBZ7Qv/aoAfgp2tVNJ8JL50z8S zzRNLJIUdu362n0hzuACvlMWXhI9xy/toZCUThFgr9xjLataIU++NLh8kONTJif33s+G btoj/0Hpi6cWCGqVppzyemgj9VM80vy5jUqgsgE/5FrDIAeaGDh2HqqK2eriwQRbIiZ+ sAsZVBgV++ZUDJ8sfCIpt4AARUD3WXa8qJFZSWI20X0ox2mg3q4iP8mBxAyXYLJk3tn4 fI2w== X-Gm-Message-State: ACgBeo1Fsw9fproxsI65WDG5Nl9feqAjn0PP0dHF6zdCwVBPZCeperog I+UvHO5gL6Vn7bAPdCN1xPnOIkkTnZA= X-Received: by 2002:a17:907:628a:b0:72f:678d:6047 with SMTP id nd10-20020a170907628a00b0072f678d6047mr12474797ejc.456.1661756373028; Sun, 28 Aug 2022 23:59:33 -0700 (PDT) Received: from ?IPV6:2a0b:e7c0:0:107::70f? ([2a0b:e7c0:0:107::70f]) by smtp.gmail.com with ESMTPSA id j19-20020a508a93000000b0043ba7df7a42sm5299292edj.26.2022.08.28.23.59.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 28 Aug 2022 23:59:32 -0700 (PDT) Message-ID: <7f8d878b-ca7b-9bc0-6962-1c7de28c2c7b@kernel.org> Date: Mon, 29 Aug 2022 08:59:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH v3] tty: n_gsm: avoid call of sleeping functions from atomic context To: Fedor Pchelkin , Greg Kroah-Hartman , Daniel Starke Cc: linux-kernel@vger.kernel.org, Alexey Khoroshilov , ldv-project@linuxtesting.org, Hillf Danton References: <20220827195548.191180-1-pchelkin@ispras.ru> Content-Language: en-US From: Jiri Slaby In-Reply-To: <20220827195548.191180-1-pchelkin@ispras.ru> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27. 08. 22, 21:55, Fedor Pchelkin wrote: > Syzkaller reports the following problem: ... > The patch replaces tx_lock spinlock with mutex in order to avoid the > problem. Also kick_timer timer_list is replaced with kick_timeout > delayed_work to be able to synchronize with mutexes, as suggested by > Hillf Danton . > > Found by Linux Verification Center (linuxtesting.org) with Syzkaller. > > Fixes: 32dd59f96924 ("tty: n_gsm: fix race condition in gsmld_write()") > Fixes: c568f7086c6e ("tty: n_gsm: fix missing timer to handle stalled links") > Signed-off-by: Fedor Pchelkin > Signed-off-by: Alexey Khoroshilov > --- > v1->v2: sorry, now adapted patch from 5.10 to upstream > v2->v3: replaced a kick_timer with a delayed_work Please do so separately. That is, split the below 2 changes into two patches. > --- a/drivers/tty/n_gsm.c > +++ b/drivers/tty/n_gsm.c > @@ -248,7 +248,7 @@ struct gsm_mux { > bool constipated; /* Asked by remote to shut up */ > bool has_devices; /* Devices were registered */ > > - spinlock_t tx_lock; > + struct mutex tx_mutex; > unsigned int tx_bytes; /* TX data outstanding */ > #define TX_THRESH_HI 8192 > #define TX_THRESH_LO 2048 > @@ -256,7 +256,7 @@ struct gsm_mux { > struct list_head tx_data_list; /* Pending data packets */ > > /* Control messages */ > - struct timer_list kick_timer; /* Kick TX queuing on timeout */ > + struct delayed_work kick_timeout; /* Kick TX queuing on timeout */ > struct timer_list t2_timer; /* Retransmit timer for commands */ > int cretries; /* Command retry counter */ > struct gsm_control *pending_cmd;/* Our current pending command */ thanks, -- js suse labs