Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp220741ybh; Tue, 17 Mar 2020 21:49:11 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuawg8m3Qr5vpGKuaR7cnZzUkVCje1aB3roXK0OJLswUQAuqaQOp4/bQoh++IhBRwvmcbCO X-Received: by 2002:aca:c70f:: with SMTP id x15mr1777453oif.80.1584506951540; Tue, 17 Mar 2020 21:49:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584506951; cv=none; d=google.com; s=arc-20160816; b=WoA6RS4kziFXCsp7/HDEqA/2eStRortJIUxoxFlueC655/ht8UwG2QQ/cuA/SZEDAL w7qM52GgiE9GOmjeSZW2+jiYSs/EXtvfJHfP2ywMC5eSxwmZTduBRYb7Gz2C9g2gt+QV 75YnXtw8ajec0VUcstqXpf6y6wkUaXCjC+Luj/Hm8Oglp6TOjmq1VljWNkiRYyE+ePvN Q/5+VK9mXWqFL8MhNWwshRnnzmkag9t+9CbkjhT2e3Y4dwPAM+ATaLP+lW3P8i4R4uwh 4Ma35GS0/mumPDWnh97mG5LxuITo9j7xOJmILzLDTpCSEhvMedg86gtAEdBPp4+Cs7m6 RK4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=9t6OER6Nr8rTZmv9fIvbSoay6iMJgVOYfySsd9QPfc4=; b=DK29nZetnGCKwPhYskI+8iMNR9Uv9gVo9eq4GOORKz/tsXweNUC9OOxhB8+LewCBdg 01xedOP6juyJYl/gLeq/Q3Z9O6Mo9qL2MzwTagZuQBPovPefKXv6/4t1Fu93+tWjxdL8 Mue1kjyshNAyHz8LaxkMVglXmI8XYUALQjItd0jeMfQbN9uFBQskOJJXJzYn3MfeJNGr d0T+zzWxUapZj9SkUvFlDHctDuQLxmSgzrcvgph8aQgoGOhDw7DfYSI2yhRsPWurADc6 AZagMpiHtWS5MYU/tP0hMvPbBJht9EBHYTCN3ykG7c2CJUIm6tvh+NeU9AA9SeIaPF43 1N0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mfA+GMmC; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p204si2746729oib.241.2020.03.17.21.48.57; Tue, 17 Mar 2020 21:49:11 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mfA+GMmC; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726933AbgCRErp (ORCPT + 99 others); Wed, 18 Mar 2020 00:47:45 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:43189 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726227AbgCREro (ORCPT ); Wed, 18 Mar 2020 00:47:44 -0400 Received: by mail-io1-f67.google.com with SMTP id n21so23509931ioo.10; Tue, 17 Mar 2020 21:47:44 -0700 (PDT) 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 :cc; bh=9t6OER6Nr8rTZmv9fIvbSoay6iMJgVOYfySsd9QPfc4=; b=mfA+GMmCp4qNgKXbNcNzf8cghnXV6QQ3GtKTAxFhMdD6bRnE36h5Xo3rZwAUXBoNmZ nuGj1WreHi2fmsfZ3wRWJPTwZWKbcwxcHCJJ3wl1PhnaN1X95rsCkpPT9b//wmJeXFSN XgakKl2ogf7QvmgHiMGwTU/vTm6WUgtHxfFXS3ERvHEJEVThIiLpq+cKdg5fLQ27W3sx JoeBXDa85cjpI5pO1PUKyF2t9NggC9wu7zf4SnCNRVVI10Kgcis7Op2/Aujk5er8KzEa ij3V20oD2QMnmLU2JgWxoztvhNaHbXh9ndRIQm31FQ/yG/EtZrOI8COKYz9SBZiJchp4 h0Mg== 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:cc; bh=9t6OER6Nr8rTZmv9fIvbSoay6iMJgVOYfySsd9QPfc4=; b=NxIoQg14mbO2u4JEUeSZuTzdFxO35mzX23yZ9adfA+2OHSt2kYeex7UoIzlh4B66MB nYcYA4uYuvEMT/Ty20WHJr+65pN4ALGJMbVs//nIaKYtPuoQDnZ4erong1inQuFVKCx9 p6MSrTAYVVG9UN12OLNSxnVATz7hDW6DPVHZJZ4KTqVbd9wyeGZYLQaBL6gCZJpeZkD/ 2gK4E+yUXfaBXFbYcX/BTu0UFA8y6Mu+SC8AaCoABjMHMx1vweKgmTyNkyv+5q5I3rU1 vcOMJEww+pWnyhP63lTvhi4JycZhnTyNoUA5Qtgkg6m8Pq9qW3kX5cA9Vh3YMduFu37s ecFg== X-Gm-Message-State: ANhLgQ0c2ArHHjJzIWScHDXPsZBwVROvuCE+Gw1rwKopvlLBAgkPCfeZ FzbgOoz8sXYZ51b57VVH8Or8PHMoSpx1+pckktHV9g== X-Received: by 2002:a05:6638:a99:: with SMTP id 25mr2729836jas.37.1584506863812; Tue, 17 Mar 2020 21:47:43 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: ronnie sahlberg Date: Wed, 18 Mar 2020 14:47:32 +1000 Message-ID: Subject: Re: [PATCH] CIFS: Fix bug which the return value by asynchronous read is error To: Yilu Lin Cc: linux-cifs , Steve French , "samba-technical@lists.samba.org" , LKML , alex.chen@huawei.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Yilu, I think your reasoning makes sense. Do you have a small reproducer for this? A small C program that triggers this? I am asking because if you do we would like to add it to our buildbot to make sure we don't get regressions. regards ronnie sahlberg On Wed, Mar 18, 2020 at 1:59 PM Yilu Lin wrote: > > This patch is used to fix the bug in collect_uncached_read_data() > that rc is automatically converted from a signed number to an > unsigned number when the CIFS asynchronous read fails. > It will cause ctx->rc is error. > > Example: > Share a directory and create a file on the Windows OS. > Mount the directory to the Linux OS using CIFS. > On the CIFS client of the Linux OS, invoke the pread interface to > deliver the read request. > > The size of the read length plus offset of the read request is greater > than the maximum file size. > > In this case, the CIFS server on the Windows OS returns a failure > message (for example, the return value of > smb2.nt_status is STATUS_INVALID_PARAMETER). > > After receiving the response message, the CIFS client parses > smb2.nt_status to STATUS_INVALID_PARAMETER > and converts it to the Linux error code (rdata->result=-22). > > Then the CIFS client invokes the collect_uncached_read_data function to > assign the value of rdata->result to rc, that is, rc=rdata->result=-22. > > The type of the ctx->total_len variable is unsigned integer, > the type of the rc variable is integer, and the type of > the ctx->rc variable is ssize_t. > > Therefore, during the ternary operation, the value of rc is > automatically converted to an unsigned number. The final result is > ctx->rc=4294967274. However, the expected result is ctx->rc=-22. > > Signed-off-by: Yilu Lin > --- > fs/cifs/file.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/cifs/file.c b/fs/cifs/file.c > index 022029a5d..ff4ac244c 100644 > --- a/fs/cifs/file.c > +++ b/fs/cifs/file.c > @@ -3323,7 +3323,7 @@ again: > if (rc == -ENODATA) > rc = 0; > > - ctx->rc = (rc == 0) ? ctx->total_len : rc; > + ctx->rc = (rc == 0) ? (ssize_t)ctx->total_len : rc; > > mutex_unlock(&ctx->aio_mutex); > > -- > 2.19.1 > >