Received: by 10.223.185.116 with SMTP id b49csp5656887wrg; Tue, 27 Feb 2018 18:14:41 -0800 (PST) X-Google-Smtp-Source: AH8x225lHH7cTu+L5YoFpdCYHV/bH6USnSKaRPjBfbuSXYTjY7bcv/JZehz4w7fkgqIr2clf1tfd X-Received: by 10.98.144.65 with SMTP id a62mr15981879pfe.96.1519784081329; Tue, 27 Feb 2018 18:14:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519784081; cv=none; d=google.com; s=arc-20160816; b=nZX+r4OzxBgegYtFM1k7JreN9G/+6uqR1oGz1zwc9hhh2Nt1Ge35OYqyjPsv0/O+Qs TEX1VfpSKedDW+sWLlfeQs+OcXD9soskcQpW2c+ugcuQnKC/zNHfs29nKraHAO47qEbn aDJKgvyhqPVEJlhZ/wMa/Sg03iawv9JUdf09JWBE4O2tCMGzP8vXRs/jBhqhSCcTpCJ6 0q07R+QpKairz8zVTR8W6D//XzOi7m8ZDe6PUUGHNKEN7MNiVjzEryJeQBEayxzM5Mjc 87vlY9Am4pVsZH5eiy9eEsOt+m5B6CUlAarOe5RGIOlqxhAzHi3VG+hNJqgggsWQXsbR BAlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:to:cc:references :subject:arc-authentication-results; bh=wlhVrfrZ58ZQIz557eCryC82WrAvUdx7Ip4ylGSIi64=; b=WgG1liy65ZuyLiowLwGJRso6KaWSZVDRX+kAE22+GCs2vBkW1EwAGPa8R+wfqlFb1P 0iGEGcwcvX92fkds7ch94RpMO0YI1KDqFZYAN2LQgLjTQejpxIj7o5NpaXfXoT2/RoHI T36WDXdwCiQChH2cVf4Q5Y+pFz45b2iwKpXg2FqfthtEGHFamIrvxZtdpdl3diE/Xgbr KOW/8iequyTcjuCJedjlSqiDcPl5Jb5w/JGFuG9qM8FMXDT0/EIumgeNFKg+bPDemk7V +F8aIlE/nztvkI+1lQvEyFkPZpqHywg+6k5FZStC0me6HgI9Z9mK3Yl1i2SVVg7ciTtV Z3Cg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a80si392118pfa.315.2018.02.27.18.14.25; Tue, 27 Feb 2018 18:14:41 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751811AbeB1CNq (ORCPT + 99 others); Tue, 27 Feb 2018 21:13:46 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:5679 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751682AbeB1CNp (ORCPT ); Tue, 27 Feb 2018 21:13:45 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id E5DEAF214FB3F; Wed, 28 Feb 2018 10:13:30 +0800 (CST) Received: from [127.0.0.1] (10.177.16.168) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.361.1; Wed, 28 Feb 2018 10:13:30 +0800 Subject: Re: [V9fs-developer] [PATCH] net/9p: avoid -ERESTARTSYS leak to userspace References: <151811152925.12219.16418114797025615002.stgit@bahia.lab.toulouse-stg.fr.ibm.com> <20180220174816.0ef05769@bahia.lan> CC: , , , , , , , Greg Kurz To: From: jiangyiwen Message-ID: <5A961047.8000905@huawei.com> Date: Wed, 28 Feb 2018 10:13:27 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20180220174816.0ef05769@bahia.lan> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.16.168] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Al, I totally agree the Greg's suggestion, I think v9fs is the direction as the VirtFS in the virtualization field, that it still deserves to be used and developed, so I also suggestion you can apply (or nack) the patch as v9fs maintainer, I hope you won't refuse. Thanks, Yiwen. On 2018/2/21 0:48, Greg Kurz wrote: > Hi Al, > > It's been two years without any sign of life from 9p maintainers... :-\ > > Would you apply (or nack) this patch ? > > Thanks, > > -- > Greg > > PS: in the case you apply it, probable Cc stable@vger.kernel.org as well > > > On Thu, 08 Feb 2018 18:38:49 +0100 > > Greg Kurz wrote: > >> If it was interrupted by a signal, the 9p client may need to send some >> more requests to the server for cleanup before returning to userspace. >> >> To avoid such a last minute request to be interrupted right away, the >> client memorizes if a signal is pending, clear TIF_SIGPENDING, handle >> the request and call recalc_sigpending() before returning. >> >> Unfortunately, if the transmission of this cleanup request fails for any >> reason, the transport returns an error and the client propagates it right >> away, without calling recalc_sigpending(). >> >> This ends up with -ERESTARTSYS from the initially interrupted request >> crawling up to syscall exit, with TIF_SIGPENDING cleared by the cleanup >> request. The specific signal handling code, which is responsible for >> converting -ERESTARTSYS to -EINTR is not called, and userspace receives >> the confusing errno value: >> >> open: Unknown error 512 (512) >> >> This is really hard to hit in real life. I discovered the issue while >> working on hot-unplug of a virtio-9p-pci device with an instrumented >> QEMU allowing to control request completion. >> >> Both p9_client_zc_rpc() and p9_client_rpc() functions have this buggy >> error path actually. Their code flow is a bit obscure and the best >> thing to do would probably be a full rewrite: to really ensure this >> situation of clearing TIF_SIGPENDING and returning -ERESTARTSYS can >> never happen. >> >> But given the general lack of interest for the 9p code, I won't risk >> breaking more things. So this patch simply fix the buggy paths in both >> functions with a trivial label+goto. >> >> Thanks to Laurent Dufour for his help and suggestions on how to find >> the root cause and how to fix it. >> >> Signed-off-by: Greg Kurz >> --- >> net/9p/client.c | 6 ++++-- >> 1 file changed, 4 insertions(+), 2 deletions(-) >> >> diff --git a/net/9p/client.c b/net/9p/client.c >> index 4c8cf9c1631a..5154eaf19fff 100644 >> --- a/net/9p/client.c >> +++ b/net/9p/client.c >> @@ -769,7 +769,7 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...) >> if (err < 0) { >> if (err != -ERESTARTSYS && err != -EFAULT) >> c->status = Disconnected; >> - goto reterr; >> + goto recalc_sigpending; >> } >> again: >> /* Wait for the response */ >> @@ -804,6 +804,7 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...) >> if (req->status == REQ_STATUS_RCVD) >> err = 0; >> } >> +recalc_sigpending: >> if (sigpending) { >> spin_lock_irqsave(¤t->sighand->siglock, flags); >> recalc_sigpending(); >> @@ -867,7 +868,7 @@ static struct p9_req_t *p9_client_zc_rpc(struct p9_client *c, int8_t type, >> if (err == -EIO) >> c->status = Disconnected; >> if (err != -ERESTARTSYS) >> - goto reterr; >> + goto recalc_sigpending; >> } >> if (req->status == REQ_STATUS_ERROR) { >> p9_debug(P9_DEBUG_ERROR, "req_status error %d\n", req->t_err); >> @@ -885,6 +886,7 @@ static struct p9_req_t *p9_client_zc_rpc(struct p9_client *c, int8_t type, >> if (req->status == REQ_STATUS_RCVD) >> err = 0; >> } >> +recalc_sigpending: >> if (sigpending) { >> spin_lock_irqsave(¤t->sighand->siglock, flags); >> recalc_sigpending(); >> >> >> ------------------------------------------------------------------------------ >> Check out the vibrant tech community on one of the world's most >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot >> _______________________________________________ >> V9fs-developer mailing list >> V9fs-developer@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/v9fs-developer > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > V9fs-developer mailing list > V9fs-developer@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/v9fs-developer > > . >