All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC v2 0/4] 9p: fix open-unlink-f*syscall bug.
@ 2020-09-23 14:11 Jianyong Wu
  2020-09-23 14:11 ` [PATCH v2 1/4] fs/9p: fix create-unlink-getattr idiom Jianyong Wu
                   ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: Jianyong Wu @ 2020-09-23 14:11 UTC (permalink / raw)
  To: ericvh, lucho, asmadeus, qemu_oss
  Cc: groug, v9fs-developer, linux-kernel, justin.he, jianyong.wu

open-unlink-f*syscall bug is well-known in 9p. We try to fix the bug
in this patch set.
I take Eric's and Greg's patches which constiute the 1/4 - 3/4 of this patch
set as the main frame of the solution. In patch 4/4, I fix the fid race issue
exists in Greg's patch.

change log:
v1 to v2:
        (1) in patch 4/4: do fid refcounter down in the clunk helper.
        (2) int patch 4/4: remove the enum value denoting from which of the
inode or dentry fids are allcated.

Eric Van Hensbergen (1):
  fs/9p: fix create-unlink-getattr idiom

Greg Kurz (1):
  fs/9p: search open fids first

Jianyong Wu (2):
  fs/9p: track open fids
  9p: fix race issue in fid contention.

 fs/9p/fid.c             | 69 ++++++++++++++++++++++++++++++++++++++---
 fs/9p/fid.h             | 11 ++++++-
 fs/9p/vfs_dentry.c      |  2 ++
 fs/9p/vfs_dir.c         |  6 +++-
 fs/9p/vfs_file.c        |  1 +
 fs/9p/vfs_inode.c       | 47 ++++++++++++++++++++++------
 fs/9p/vfs_inode_dotl.c  | 35 +++++++++++++++++----
 fs/9p/vfs_super.c       |  1 +
 fs/9p/xattr.c           | 16 ++++++++--
 include/net/9p/client.h |  7 +++++
 net/9p/client.c         | 14 ++++++---
 11 files changed, 179 insertions(+), 30 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 21+ messages in thread
* Re: [PATCH RFC v2 4/4] 9p: fix race issue in fid contention.
@ 2020-09-24  4:50 kernel test robot
  2020-09-24  7:01 ` Dan Carpenter
  0 siblings, 1 reply; 21+ messages in thread
From: kernel test robot @ 2020-09-24  4:50 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 5543 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20200923141146.90046-5-jianyong.wu@arm.com>
References: <20200923141146.90046-5-jianyong.wu@arm.com>
TO: Jianyong Wu <jianyong.wu@arm.com>

Hi Jianyong,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on v5.9-rc6]
[also build test WARNING on next-20200923]
[cannot apply to v9fs/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jianyong-Wu/9p-fix-open-unlink-f-syscall-bug/20200923-221306
base:    ba4f184e126b751d1bffad5897f263108befc780
:::::: branch date: 15 hours ago
:::::: commit date: 15 hours ago
config: mips-randconfig-c004-20200923 (attached as .config)
compiler: mipsel-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@lip6.fr>


coccinelle warnings: (new ones prefixed by >>)

>> net/9p/client.c:1469:6-25: atomic_dec_and_test variation before object free at line 1497.

# https://github.com/0day-ci/linux/commit/7e17225563a1d031abb996e557ad28a4f6ff3ab0
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jianyong-Wu/9p-fix-open-unlink-f-syscall-bug/20200923-221306
git checkout 7e17225563a1d031abb996e557ad28a4f6ff3ab0
vim +1469 net/9p/client.c

920e65dc6911da Venkateswararao Jujjuri (JV  2010-09-22  1455) 
bd238fb431f319 Latchesar Ionkov             2007-07-10  1456  int p9_client_clunk(struct p9_fid *fid)
bd238fb431f319 Latchesar Ionkov             2007-07-10  1457  {
bd238fb431f319 Latchesar Ionkov             2007-07-10  1458  	int err;
bd238fb431f319 Latchesar Ionkov             2007-07-10  1459  	struct p9_client *clnt;
51a87c552dfd42 Eric Van Hensbergen          2008-10-16  1460  	struct p9_req_t *req;
208f3c28aab706 Jim Garlick                  2012-02-26  1461  	int retries = 0;
bd238fb431f319 Latchesar Ionkov             2007-07-10  1462  
7e17225563a1d0 Jianyong Wu                  2020-09-23  1463  	if (!fid || IS_ERR(fid)) {
7e17225563a1d0 Jianyong Wu                  2020-09-23  1464  		pr_warn("%s (%d): Trying to clunk with invalid fid\n",
5d3851530d6d68 Joe Perches                  2011-11-28  1465  			__func__, task_pid_nr(current));
8e44a0805fc9d7 jvrao                        2010-08-25  1466  		dump_stack();
8e44a0805fc9d7 jvrao                        2010-08-25  1467  		return 0;
8e44a0805fc9d7 jvrao                        2010-08-25  1468  	}
7e17225563a1d0 Jianyong Wu                  2020-09-23 @1469  	if (!atomic_dec_and_test(&fid->count))
7e17225563a1d0 Jianyong Wu                  2020-09-23  1470  		return 0;
8e44a0805fc9d7 jvrao                        2010-08-25  1471  
208f3c28aab706 Jim Garlick                  2012-02-26  1472  again:
208f3c28aab706 Jim Garlick                  2012-02-26  1473  	p9_debug(P9_DEBUG_9P, ">>> TCLUNK fid %d (try %d)\n", fid->fid,
208f3c28aab706 Jim Garlick                  2012-02-26  1474  								retries);
bd238fb431f319 Latchesar Ionkov             2007-07-10  1475  	err = 0;
bd238fb431f319 Latchesar Ionkov             2007-07-10  1476  	clnt = fid->clnt;
bd238fb431f319 Latchesar Ionkov             2007-07-10  1477  
51a87c552dfd42 Eric Van Hensbergen          2008-10-16  1478  	req = p9_client_rpc(clnt, P9_TCLUNK, "d", fid->fid);
51a87c552dfd42 Eric Van Hensbergen          2008-10-16  1479  	if (IS_ERR(req)) {
51a87c552dfd42 Eric Van Hensbergen          2008-10-16  1480  		err = PTR_ERR(req);
51a87c552dfd42 Eric Van Hensbergen          2008-10-16  1481  		goto error;
bd238fb431f319 Latchesar Ionkov             2007-07-10  1482  	}
bd238fb431f319 Latchesar Ionkov             2007-07-10  1483  
5d3851530d6d68 Joe Perches                  2011-11-28  1484  	p9_debug(P9_DEBUG_9P, "<<< RCLUNK fid %d\n", fid->fid);
bd238fb431f319 Latchesar Ionkov             2007-07-10  1485  
43cbcbee9938b1 Tomas Bortoli                2018-08-11  1486  	p9_tag_remove(clnt, req);
51a87c552dfd42 Eric Van Hensbergen          2008-10-16  1487  error:
5034990e28efb2 Aneesh Kumar K.V             2011-07-11  1488  	/*
5034990e28efb2 Aneesh Kumar K.V             2011-07-11  1489  	 * Fid is not valid even after a failed clunk
208f3c28aab706 Jim Garlick                  2012-02-26  1490  	 * If interrupted, retry once then give up and
208f3c28aab706 Jim Garlick                  2012-02-26  1491  	 * leak fid until umount.
5034990e28efb2 Aneesh Kumar K.V             2011-07-11  1492  	 */
208f3c28aab706 Jim Garlick                  2012-02-26  1493  	if (err == -ERESTARTSYS) {
208f3c28aab706 Jim Garlick                  2012-02-26  1494  		if (retries++ == 0)
208f3c28aab706 Jim Garlick                  2012-02-26  1495  			goto again;
208f3c28aab706 Jim Garlick                  2012-02-26  1496  	} else
5034990e28efb2 Aneesh Kumar K.V             2011-07-11 @1497  		p9_fid_destroy(fid);
bd238fb431f319 Latchesar Ionkov             2007-07-10  1498  	return err;
bd238fb431f319 Latchesar Ionkov             2007-07-10  1499  }
bd238fb431f319 Latchesar Ionkov             2007-07-10  1500  EXPORT_SYMBOL(p9_client_clunk);
bd238fb431f319 Latchesar Ionkov             2007-07-10  1501  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 29212 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread
* Re: [kbuild] Re: [PATCH RFC v2 4/4] 9p: fix race issue in fid contention.
  2020-09-24  7:01 ` Dan Carpenter
@ 2020-09-24  8:29 Reshetova, Elena
  2020-09-24  8:40 ` Dan Carpenter
  -1 siblings, 1 reply; 21+ messages in thread
From: Reshetova, Elena @ 2020-09-24  8:29 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 920 bytes --]

> > >> net/9p/client.c:1469:6-25: atomic_dec_and_test variation before object free at
> line 1497.
> 
> 
> This warning was confusing for me.  Perhaps a better wording would be:
> "Use refcount_t instead of atomic_t for refcounting"?  

The reason we didn't want to have such a strong statement, because this detection
can give false positives, i.e. suggest converting smth that should be left as atomic_t.
So, it should be always carefully analyzed by a code author before just plainly converting.
Also, this way it gives you the background on which exact pattern (we have a number
of them) triggered this case, and if we see that one pattern gives too much mistakes, 
we can remove/update it. But atomic_dec_and_test usage before freeing the object is
actually one of the most common cases., so maybe I can add a statement saying 
"consider using refcount_t instead of atomic_t"?

Best Regards,
Elena.

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2020-11-19 16:07 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-23 14:11 [PATCH RFC v2 0/4] 9p: fix open-unlink-f*syscall bug Jianyong Wu
2020-09-23 14:11 ` [PATCH v2 1/4] fs/9p: fix create-unlink-getattr idiom Jianyong Wu
2020-09-23 14:11 ` [PATCH v2 2/4] fs/9p: track open fids Jianyong Wu
2020-09-23 14:11 ` [PATCH v2 3/4] fs/9p: search open fids first Jianyong Wu
2020-09-23 14:11 ` [PATCH RFC v2 4/4] 9p: fix race issue in fid contention Jianyong Wu
2020-09-23 14:49   ` Dominique Martinet
2020-09-24  8:38     ` Jianyong Wu
2020-09-24  8:56       ` Greg Kurz
2020-09-24  9:51       ` Dominique Martinet
2020-09-25  9:49         ` Jianyong Wu
2020-11-03 10:41   ` Dominique Martinet
2020-11-04 11:32     ` Christian Schoenebeck
2020-11-04 11:57       ` Dominique Martinet
2020-11-05 12:32         ` Christian Schoenebeck
2020-11-05  7:05     ` Jianyong Wu
2020-11-19 16:06     ` [PATCH 0/2] follow-up to " Dominique Martinet
2020-11-19 16:06       ` [PATCH 1/2] 9p: apply review requests for fid refcounting Dominique Martinet
2020-11-19 16:06       ` [PATCH 2/2] 9p: Fix writeback fid incorrectly being attached to dentry Dominique Martinet
  -- strict thread matches above, loose matches on Subject: below --
2020-09-24  4:50 [PATCH RFC v2 4/4] 9p: fix race issue in fid contention kernel test robot
2020-09-24  7:01 ` Dan Carpenter
2020-09-24  8:29 [kbuild] " Reshetova, Elena
2020-09-24  8:40 ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.