Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp418254rdh; Tue, 19 Dec 2023 03:02:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFfSNzjvhZtsgpabqY1MGuZmH1oCFe2uNbhnNnOidQJLqRtqnBayNv2/gShPWIxrfnWXvkg X-Received: by 2002:a17:902:d58c:b0:1d3:bb55:fc1e with SMTP id k12-20020a170902d58c00b001d3bb55fc1emr2410312plh.60.1702983775839; Tue, 19 Dec 2023 03:02:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702983775; cv=none; d=google.com; s=arc-20160816; b=vfYJ14eBGUwKe81dWFIcBC24CC006Nt2Y2s/w6rozezso5StpU8Z4fIxDMvLTmMa/u teJYPlY1eKWxVyRz4J7Ewkm6kcQyvfjeDVrdCZ3TSww/sp+wJ2pwxRMmrQMPm+j/RpG5 qwTU0XTWhljaFCdFmNf2fK89+hAnvogv0Vlfe6Zp0vzZAYWyj06vq/wwDONHR8/jNCn4 fGTvYAZttvbe3b2m5VFNCKwqATDCA9p8HMUAyn4VDSC+lOLcbNLq8FTQ/TXw7uqYh4/b QJ2nDJb62QPaEqI84DZs/ihQEO9v4uopJirI/I4s2gLuyzGHUNJIQl/1SzlgAhsxfl/0 W7ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:in-reply-to:date:subject:cc:to:from:user-agent :references; bh=mywmpiUx/a6HujkngKOjqjDSc+JB5TsEJlOni3VEDcw=; fh=ug4JOG5MNJZb6tr1TxjDFx2ewmAEkXRv2OZu2F5gs5U=; b=HVrmtsuV/Bp05a5r94nOI1h87vQhxlQ529+IkqtamOscmGsxgWduGeyV5+/OdaZELw 5jtjPYxFmxG77QZ5/bIFyORZvkf+s1pVXSJY6xDgymGRgbWUaGUiK4PwQPjkBZPkesz+ ir4TDFKo6RjH+0JycCZ+VQuK19nxGh1OrFp5dIZ/avowz5f/y52IZoTohMFLMLM+cGrY zrtJJ8q5hKilxNZ6YwqPuyHkQps741KpA/UoYwHIvjmUldGx+YshU4+oQzhtkKaKAHVz K6s8OLUMIGwggDy2tYP4n88zXnKyUD9VfWR8zrbT8vTZYSPkm3RXezlAAqZGwtOB27i/ Tx9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-5054-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5054-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id u6-20020a170902e5c600b001d05450e410si1160673plf.208.2023.12.19.03.02.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 03:02:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5054-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-5054-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5054-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C349CB21217 for ; Tue, 19 Dec 2023 11:02:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0CB56154B8; Tue, 19 Dec 2023 11:02:22 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26F3D18E2C for ; Tue, 19 Dec 2023 11:02:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=ratatoskr.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rFXrX-0001qh-Dm; Tue, 19 Dec 2023 12:02:11 +0100 References: <20231023121346.4098160-1-s.hauer@pengutronix.de> <20231026070310.GY3359458@pengutronix.de> <8404022493c5ceda74807a3407e5a087425678e2.camel@redhat.com> <20231027120432.GB3359458@pengutronix.de> <20231117-starter-unvisited-d10f0314ae76-mkl@pengutronix.de> User-agent: mu4e 1.10.8; emacs 29.1 From: Steffen Trumtrar To: Marc Kleine-Budde Cc: Sascha Hauer , Jens Axboe , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "David S . Miller" , Jakub Kicinski , kernel@pengutronix.de Subject: Re: [PATCH] net: Do not break out of sk_stream_wait_memory() with TIF_NOTIFY_SIGNAL Date: Tue, 19 Dec 2023 12:00:44 +0100 In-reply-to: <20231117-starter-unvisited-d10f0314ae76-mkl@pengutronix.de> Message-ID: <87cyv2wj4e.fsf@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; format=flowed X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: s.trumtrar@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org On 2023-11-17 at 11:43 +01, Marc Kleine-Budde wrote: > [[PGP Signed Part:Undecided]] > On 27.10.2023 14:04:32, Sascha Hauer wrote: >> On Thu, Oct 26, 2023 at 10:49:18AM +0200, Paolo Abeni wrote: >> > On Thu, 2023-10-26 at 09:03 +0200, Sascha Hauer wrote: >> > > On Tue, Oct 24, 2023 at 03:56:17PM +0200, Paolo Abeni wrote: >> > > > On Mon, 2023-10-23 at 14:13 +0200, Sascha Hauer wrote: >> > > > > It can happen that a socket sends the remaining data at close() time. >> > > > > With io_uring and KTLS it can happen that sk_stream_wait_memory() bails >> > > > > out with -512 (-ERESTARTSYS) because TIF_NOTIFY_SIGNAL is set for the >> > > > > current task. This flag has been set in io_req_normal_work_add() by >> > > > > calling task_work_add(). >> > > > > >> > > > > It seems signal_pending() is too broad, so this patch replaces it with >> > > > > task_sigpending(), thus ignoring the TIF_NOTIFY_SIGNAL flag. >> > > > >> > > > This looks dangerous, at best. Other possible legit users setting >> > > > TIF_NOTIFY_SIGNAL will be broken. >> > > > >> > > > Can't you instead clear TIF_NOTIFY_SIGNAL in io_run_task_work() ? >> > > >> > > I don't have an idea how io_run_task_work() comes into play here, but it >> > > seems it already clears TIF_NOTIFY_SIGNAL: >> > > >> > > static inline int io_run_task_work(void) >> > > { >> > > /* >> > > * Always check-and-clear the task_work notification signal. With how >> > > * signaling works for task_work, we can find it set with nothing to >> > > * run. We need to clear it for that case, like get_signal() does. >> > > */ >> > > if (test_thread_flag(TIF_NOTIFY_SIGNAL)) >> > > clear_notify_signal(); >> > > ... >> > > } >> > >> > I see, io_run_task_work() is too late, sk_stream_wait_memory() is >> > already woken up. >> > >> > I still think this patch is unsafe. What about explicitly handling the >> > restart in tls_sw_release_resources_tx() ? The main point is that such >> > function is called by inet_release() and the latter can't be re- >> > started. >> >> I don't think there's anything I can do in tls_sw_release_resources_tx(). >> When entering this function TIF_NOTIFY_SIGNAL is not (yet) set. It gets >> set at some point while tls_sw_release_resources_tx() is running. I find >> it set when tls_tx_records() returns with -ERESTARTSYS. I tried clearing >> TIF_NOTIFY_SIGNAL then and called tls_tx_records() again, but that doesn't >> work. > > Seems the discussion got stuck, what are the blocking points? Ping! Any pointers on how to get this sorted out? Best regards, Steffen -- Pengutronix e.K. | Dipl.-Inform. Steffen Trumtrar | Steuerwalder Str. 21 | https://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686| Fax: +49-5121-206917-5555 |