فهرست منبع

quota: Fix possible oops in __dquot_initialize()

When quotaon(8) races with __dquot_initialize() or dqget() fails because
of EIO, ENOSPC, or similar error, we could possibly dereference NULL pointer
in inode->i_dquot[cnt]. Add proper checking.

Reported-by: Dmitry Monakhov <dmonakhov@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Jan Kara 14 سال پیش
والد
کامیت
4408ea41c0
1فایلهای تغییر یافته به همراه3 افزوده شده و 0 حذف شده
  1. 3 0
      fs/quota/dquot.c

+ 3 - 0
fs/quota/dquot.c

@@ -1386,6 +1386,9 @@ static void __dquot_initialize(struct inode *inode, int type)
 		/* Avoid races with quotaoff() */
 		/* Avoid races with quotaoff() */
 		if (!sb_has_quota_active(sb, cnt))
 		if (!sb_has_quota_active(sb, cnt))
 			continue;
 			continue;
+		/* We could race with quotaon or dqget() could have failed */
+		if (!got[cnt])
+			continue;
 		if (!inode->i_dquot[cnt]) {
 		if (!inode->i_dquot[cnt]) {
 			inode->i_dquot[cnt] = got[cnt];
 			inode->i_dquot[cnt] = got[cnt];
 			got[cnt] = NULL;
 			got[cnt] = NULL;