From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hugh Dickins Subject: [PATCH] simple_xattr: permit 0-size extended attributes Date: Wed, 16 Jul 2014 13:14:06 -0700 (PDT) Message-ID: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: Jeff Layton , Aristeu Rozanski , Andrew Morton , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org To: Al Viro Return-path: Received: from mail-pd0-f178.google.com ([209.85.192.178]:50896 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751267AbaGPUQN (ORCPT ); Wed, 16 Jul 2014 16:16:13 -0400 Received: by mail-pd0-f178.google.com with SMTP id w10so1795155pde.37 for ; Wed, 16 Jul 2014 13:16:13 -0700 (PDT) Sender: linux-fsdevel-owner@vger.kernel.org List-ID: If a filesystem uses simple_xattr to support user extended attributes, LTP setxattr01 and xfstests generic/062 fail with "Cannot allocate memory": simple_xattr_alloc()'s wrap-around test mistakenly excludes values of zero size. Fix that off-by-one (but apparently no filesystem needs them yet). Signed-off-by: Hugh Dickins --- fs/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- 3.16-rc5/fs/xattr.c 2013-02-18 15:58:34.000000000 -0800 +++ linux/fs/xattr.c 2014-07-16 12:47:10.640004412 -0700 @@ -843,7 +843,7 @@ struct simple_xattr *simple_xattr_alloc( /* wrap around? */ len = sizeof(*new_xattr) + size; - if (len <= sizeof(*new_xattr)) + if (len < sizeof(*new_xattr)) return NULL; new_xattr = kmalloc(len, GFP_KERNEL);