From patchwork Tue May 3 16:44:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel J Blueman X-Patchwork-Id: 750632 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 p43GiPV1019713 for ; Tue, 3 May 2011 16:44:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753842Ab1ECQoX (ORCPT ); Tue, 3 May 2011 12:44:23 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:59979 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753727Ab1ECQoW (ORCPT ); Tue, 3 May 2011 12:44:22 -0400 Received: by pzk9 with SMTP id 9so108735pzk.19 for ; Tue, 03 May 2011 09:44:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer; bh=VGQnQaG7BTG0TvZSqKliV/I/onMgHZbu0Zjqg3NaJVk=; b=phTiaZEnCB7dT+oDYUG/BESoHtUyiwo0oxvkNcWT3cf0zQyaRWC8Lq7fgYUGDrcBgm WaN6jO/ZfMJhG0YouvqddFl1R8B6xCOjHa5yO7zpsOg+nLFVA9wOZo+UO/0ZbL8lx9Bs LF+js40hI6FlWrxF5MxXzTVD472yzV7XyjcR4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=bO7ZNRJof4pzFdivZ3VF8hRaPybGt9r70pjzvWJd3foHXhQlNln63K6FJjYpMaxnQf 7nihalmmMh+PCXAzteOTRXVU0TwWV7/+RIdNjj92VwbW8e6pazeARoymB370bagBYxrQ ZCk681BNCyUY+ZqYwBaotstxahnS87DBjR8O0= Received: by 10.142.52.20 with SMTP id z20mr22335wfz.212.1304441062168; Tue, 03 May 2011 09:44:22 -0700 (PDT) Received: from localhost.localdomain (bb116-14-55-143.singnet.com.sg [116.14.55.143]) by mx.google.com with ESMTPS id x4sm138429pbr.71.2011.05.03.09.44.20 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 03 May 2011 09:44:21 -0700 (PDT) From: Daniel J Blueman To: linux-btrfs@vger.kernel.org, chris.mason@oracle.com Cc: Daniel J Blueman Subject: [PATCH] Prevent oopsing in posix_acl_valid() Date: Wed, 4 May 2011 00:44:13 +0800 Message-Id: <1304441053-4173-1-git-send-email-daniel.blueman@gmail.com> X-Mailer: git-send-email 1.7.4.1 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]); Tue, 03 May 2011 16:44:25 +0000 (UTC) If posix_acl_from_xattr() returns an error code, a negative address is dereferenced causing an oops; fix by checking for error code first. Signed-off-by: Daniel J Blueman Reviewed-by: Josef Bacik --- fs/btrfs/acl.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c index 5d505aa..cad6fbb 100644 --- a/fs/btrfs/acl.c +++ b/fs/btrfs/acl.c @@ -178,12 +178,13 @@ static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name, if (value) { acl = posix_acl_from_xattr(value, size); + if (IS_ERR(acl) + return PTR_ERR(acl); + if (acl) { ret = posix_acl_valid(acl); if (ret) goto out; - } else if (IS_ERR(acl)) { - return PTR_ERR(acl); } }