Skip to contentSkip to conversation

locks: fix null dereference on lease-break failure path

PATCH New J. Bruce Fields 1 participant 1 message Dec 23, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 locks: fix null dereference on lease-break failure path

From: "J. Bruce Fields" <[email protected]>

Commit 778fc546f749c588aa2f6cd50215d2715c374252 "locks: fix tracking of inprogress lease breaks" introduced a null dereference on failure to allocate memory.

This means an open (without O_NONBLOCK set) on a file with a lease applied (generally only done when Samba or nfsd (with v4) is running) could crash if a kmalloc() fails.

---
 fs/locks.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Eh, supposedly I'm on vacation till the end of the year, but I just noticed this.... I'll send it in for 3.2 soon if nobody notices a problem (and if I don't miss the release).

fs/locks.c +2 -2
index 3b0d05d..96a487a 100644
@@ -1214,8 +1214,8 @@ int __break_lease(struct inode *inode, unsigned int mode)
 	if ((flock == NULL) || !IS_LEASE(flock))
 		goto out;
 
-	if (!locks_conflict(flock, new_fl))
-		goto out;
+	if (flock->fl_type == F_RDLCK && !want_write)
+		goto out; /* no conflict */
 
 	for (fl = flock; fl && IS_LEASE(fl); fl = fl->fl_next)
 		if (fl->fl_owner == current->files)
Signature · 6 lines
1.7.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html