From patchwork Fri Mar 4 17:15:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 609751 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p24HFp50024112 for ; Fri, 4 Mar 2011 17:15:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760028Ab1CDRPW (ORCPT ); Fri, 4 Mar 2011 12:15:22 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:39229 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759978Ab1CDRPT (ORCPT ); Fri, 4 Mar 2011 12:15:19 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.72 #1 (Red Hat Linux)) id 1PvYb1-0006y5-02; Fri, 04 Mar 2011 17:15:19 +0000 Date: Fri, 4 Mar 2011 17:15:18 +0000 From: Al Viro To: chris.mason@oracle.com Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org Subject: [PATCH 2/2] btrfs: check link counter overflow in link(2) Message-ID: <20110304171518.GB26708@ZenIV.linux.org.uk> References: <20110304171353.GU22723@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110304171353.GU22723@ZenIV.linux.org.uk> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 04 Mar 2011 17:15:52 +0000 (UTC) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 099d64c..8a6df03 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4826,6 +4826,9 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir, if (root->objectid != BTRFS_I(inode)->root->objectid) return -EPERM; + if (inode->i_nlink == ~0U) + return -EMLINK; + btrfs_inc_nlink(inode); inode->i_ctime = CURRENT_TIME;