* [PATCH] src/attr_replace_test: limit size of extended attribute value
@ 2019-05-17 12:06 Luis Henriques
2019-05-19 17:27 ` Nikolay Borisov
2019-05-20 16:23 ` [PATCH] " Darrick J. Wong
0 siblings, 2 replies; 7+ messages in thread
From: Luis Henriques @ 2019-05-17 12:06 UTC (permalink / raw)
To: fstests; +Cc: Luis Henriques, Darrick J . Wong
The maximum size for extended attribute values is 65536 (XATTR_SIZE_MAX).
Since there are filesystems that can set blksize to really big values
(CephFS for example has a default of 4M), it's easy to have this test
failing with fsetxattr returning -E2BIG.
Cc: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Luis Henriques <lhenriques@suse.com>
---
src/attr_replace_test.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/attr_replace_test.c b/src/attr_replace_test.c
index 0720bfdc18ab..1ca9bf11ba58 100644
--- a/src/attr_replace_test.c
+++ b/src/attr_replace_test.c
@@ -9,6 +9,7 @@
#include <sys/types.h>
#include <sys/xattr.h>
#include <sys/stat.h>
+#include <linux/limits.h>
#define die() do { perror(""); \
fprintf(stderr, "error at line %d\n", __LINE__); \
@@ -44,6 +45,8 @@ int main(int argc, char *argv[])
size = sbuf.st_blksize * 3 / 4;
if (!size)
fail("Invalid st_blksize(%ld)\n", sbuf.st_blksize);
+ if (size > XATTR_SIZE_MAX)
+ size = XATTR_SIZE_MAX;
value = malloc(size);
if (!value)
fail("Failed to allocate memory\n");
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH] src/attr_replace_test: limit size of extended attribute value
2019-05-17 12:06 [PATCH] src/attr_replace_test: limit size of extended attribute value Luis Henriques
@ 2019-05-19 17:27 ` Nikolay Borisov
2019-05-20 8:24 ` Luis Henriques
2019-05-20 16:23 ` [PATCH] " Darrick J. Wong
1 sibling, 1 reply; 7+ messages in thread
From: Nikolay Borisov @ 2019-05-19 17:27 UTC (permalink / raw)
To: Luis Henriques, fstests; +Cc: Darrick J . Wong
On 17.05.19 г. 15:06 ч., Luis Henriques wrote:
> The maximum size for extended attribute values is 65536 (XATTR_SIZE_MAX).
> Since there are filesystems that can set blksize to really big values
> (CephFS for example has a default of 4M), it's easy to have this test
> failing with fsetxattr returning -E2BIG.
>
> Cc: Darrick J. Wong <darrick.wong@oracle.com>
> Signed-off-by: Luis Henriques <lhenriques@suse.com>
> ---
> src/attr_replace_test.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/src/attr_replace_test.c b/src/attr_replace_test.c
> index 0720bfdc18ab..1ca9bf11ba58 100644
> --- a/src/attr_replace_test.c
> +++ b/src/attr_replace_test.c
> @@ -9,6 +9,7 @@
> #include <sys/types.h>
> #include <sys/xattr.h>
> #include <sys/stat.h>
> +#include <linux/limits.h>
>
> #define die() do { perror(""); \
> fprintf(stderr, "error at line %d\n", __LINE__); \
> @@ -44,6 +45,8 @@ int main(int argc, char *argv[])
> size = sbuf.st_blksize * 3 / 4;
> if (!size)
> fail("Invalid st_blksize(%ld)\n", sbuf.st_blksize);
> + if (size > XATTR_SIZE_MAX)
> + size = XATTR_SIZE_MAX;
nit: size = max(size, XATTRS_SIZE_MAX);
> value = malloc(size);
> if (!value)
> fail("Failed to allocate memory\n");
>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] src/attr_replace_test: limit size of extended attribute value
2019-05-19 17:27 ` Nikolay Borisov
@ 2019-05-20 8:24 ` Luis Henriques
2019-05-20 8:27 ` Nikolay Borisov
0 siblings, 1 reply; 7+ messages in thread
From: Luis Henriques @ 2019-05-20 8:24 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: fstests, Darrick J . Wong
Nikolay Borisov <nborisov@suse.com> writes:
> On 17.05.19 г. 15:06 ч., Luis Henriques wrote:
>> The maximum size for extended attribute values is 65536 (XATTR_SIZE_MAX).
>> Since there are filesystems that can set blksize to really big values
>> (CephFS for example has a default of 4M), it's easy to have this test
>> failing with fsetxattr returning -E2BIG.
>>
>> Cc: Darrick J. Wong <darrick.wong@oracle.com>
>> Signed-off-by: Luis Henriques <lhenriques@suse.com>
>> ---
>> src/attr_replace_test.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/src/attr_replace_test.c b/src/attr_replace_test.c
>> index 0720bfdc18ab..1ca9bf11ba58 100644
>> --- a/src/attr_replace_test.c
>> +++ b/src/attr_replace_test.c
>> @@ -9,6 +9,7 @@
>> #include <sys/types.h>
>> #include <sys/xattr.h>
>> #include <sys/stat.h>
>> +#include <linux/limits.h>
>>
>> #define die() do { perror(""); \
>> fprintf(stderr, "error at line %d\n", __LINE__); \
>> @@ -44,6 +45,8 @@ int main(int argc, char *argv[])
>> size = sbuf.st_blksize * 3 / 4;
>> if (!size)
>> fail("Invalid st_blksize(%ld)\n", sbuf.st_blksize);
>> + if (size > XATTR_SIZE_MAX)
>> + size = XATTR_SIZE_MAX;
>
> nit: size = max(size, XATTRS_SIZE_MAX);
Thanks, Nikolay. But I can't find the definition of such macro or
function. I believe it's only available in kernel, right? Also, you
probably meant min() ;-)
Cheers,
--
Luis
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] src/attr_replace_test: limit size of extended attribute value
2019-05-20 8:24 ` Luis Henriques
@ 2019-05-20 8:27 ` Nikolay Borisov
2019-05-21 8:28 ` [PATCH v2] " Luis Henriques
0 siblings, 1 reply; 7+ messages in thread
From: Nikolay Borisov @ 2019-05-20 8:27 UTC (permalink / raw)
To: Luis Henriques; +Cc: fstests, Darrick J . Wong
On 20.05.19 г. 11:24 ч., Luis Henriques wrote:
> Nikolay Borisov <nborisov@suse.com> writes:
>
>> On 17.05.19 г. 15:06 ч., Luis Henriques wrote:
>>> The maximum size for extended attribute values is 65536 (XATTR_SIZE_MAX).
>>> Since there are filesystems that can set blksize to really big values
>>> (CephFS for example has a default of 4M), it's easy to have this test
>>> failing with fsetxattr returning -E2BIG.
>>>
>>> Cc: Darrick J. Wong <darrick.wong@oracle.com>
>>> Signed-off-by: Luis Henriques <lhenriques@suse.com>
>>> ---
>>> src/attr_replace_test.c | 3 +++
>>> 1 file changed, 3 insertions(+)
>>>
>>> diff --git a/src/attr_replace_test.c b/src/attr_replace_test.c
>>> index 0720bfdc18ab..1ca9bf11ba58 100644
>>> --- a/src/attr_replace_test.c
>>> +++ b/src/attr_replace_test.c
>>> @@ -9,6 +9,7 @@
>>> #include <sys/types.h>
>>> #include <sys/xattr.h>
>>> #include <sys/stat.h>
>>> +#include <linux/limits.h>
>>>
>>> #define die() do { perror(""); \
>>> fprintf(stderr, "error at line %d\n", __LINE__); \
>>> @@ -44,6 +45,8 @@ int main(int argc, char *argv[])
>>> size = sbuf.st_blksize * 3 / 4;
>>> if (!size)
>>> fail("Invalid st_blksize(%ld)\n", sbuf.st_blksize);
>>> + if (size > XATTR_SIZE_MAX)
>>> + size = XATTR_SIZE_MAX;
>>
>> nit: size = max(size, XATTRS_SIZE_MAX);
>
> Thanks, Nikolay. But I can't find the definition of such macro or
> function. I believe it's only available in kernel, right? Also, you
> probably meant min() ;-)
Yeah, re min, but it seems there is a MIN/MAX macros provided in
<sys/param.h>. Anyway, as mentioned initially this is a minor point :) .
>
> Cheers,
>
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v2] src/attr_replace_test: limit size of extended attribute value
2019-05-20 8:27 ` Nikolay Borisov
@ 2019-05-21 8:28 ` Luis Henriques
2019-05-21 18:17 ` Darrick J. Wong
0 siblings, 1 reply; 7+ messages in thread
From: Luis Henriques @ 2019-05-21 8:28 UTC (permalink / raw)
To: Darrick J. Wong, Nikolay Borisov; +Cc: fstests, Luis Henriques
The maximum size for extended attribute values is 65536 (XATTR_SIZE_MAX).
Since there are filesystems that can set blksize to really big values
(CephFS for example has a default of 4M), it's easy to have this test
failing with fsetxattr returning -E2BIG.
Cc: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Luis Henriques <lhenriques@suse.com>
---
src/attr_replace_test.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/attr_replace_test.c b/src/attr_replace_test.c
index 0720bfdc18ab..cca8dcf8ff60 100644
--- a/src/attr_replace_test.c
+++ b/src/attr_replace_test.c
@@ -9,6 +9,8 @@
#include <sys/types.h>
#include <sys/xattr.h>
#include <sys/stat.h>
+#include <sys/param.h>
+#include <linux/limits.h>
#define die() do { perror(""); \
fprintf(stderr, "error at line %d\n", __LINE__); \
@@ -44,6 +46,7 @@ int main(int argc, char *argv[])
size = sbuf.st_blksize * 3 / 4;
if (!size)
fail("Invalid st_blksize(%ld)\n", sbuf.st_blksize);
+ size = MIN(size, XATTR_SIZE_MAX);
value = malloc(size);
if (!value)
fail("Failed to allocate memory\n");
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v2] src/attr_replace_test: limit size of extended attribute value
2019-05-21 8:28 ` [PATCH v2] " Luis Henriques
@ 2019-05-21 18:17 ` Darrick J. Wong
0 siblings, 0 replies; 7+ messages in thread
From: Darrick J. Wong @ 2019-05-21 18:17 UTC (permalink / raw)
To: Luis Henriques; +Cc: Nikolay Borisov, fstests
On Tue, May 21, 2019 at 09:28:36AM +0100, Luis Henriques wrote:
> The maximum size for extended attribute values is 65536 (XATTR_SIZE_MAX).
> Since there are filesystems that can set blksize to really big values
> (CephFS for example has a default of 4M), it's easy to have this test
> failing with fsetxattr returning -E2BIG.
>
> Cc: Darrick J. Wong <darrick.wong@oracle.com>
> Signed-off-by: Luis Henriques <lhenriques@suse.com>
Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> ---
> src/attr_replace_test.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/src/attr_replace_test.c b/src/attr_replace_test.c
> index 0720bfdc18ab..cca8dcf8ff60 100644
> --- a/src/attr_replace_test.c
> +++ b/src/attr_replace_test.c
> @@ -9,6 +9,8 @@
> #include <sys/types.h>
> #include <sys/xattr.h>
> #include <sys/stat.h>
> +#include <sys/param.h>
> +#include <linux/limits.h>
>
> #define die() do { perror(""); \
> fprintf(stderr, "error at line %d\n", __LINE__); \
> @@ -44,6 +46,7 @@ int main(int argc, char *argv[])
> size = sbuf.st_blksize * 3 / 4;
> if (!size)
> fail("Invalid st_blksize(%ld)\n", sbuf.st_blksize);
> + size = MIN(size, XATTR_SIZE_MAX);
> value = malloc(size);
> if (!value)
> fail("Failed to allocate memory\n");
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] src/attr_replace_test: limit size of extended attribute value
2019-05-17 12:06 [PATCH] src/attr_replace_test: limit size of extended attribute value Luis Henriques
2019-05-19 17:27 ` Nikolay Borisov
@ 2019-05-20 16:23 ` Darrick J. Wong
1 sibling, 0 replies; 7+ messages in thread
From: Darrick J. Wong @ 2019-05-20 16:23 UTC (permalink / raw)
To: Luis Henriques; +Cc: fstests
On Fri, May 17, 2019 at 01:06:53PM +0100, Luis Henriques wrote:
> The maximum size for extended attribute values is 65536 (XATTR_SIZE_MAX).
> Since there are filesystems that can set blksize to really big values
> (CephFS for example has a default of 4M), it's easy to have this test
> failing with fsetxattr returning -E2BIG.
>
> Cc: Darrick J. Wong <darrick.wong@oracle.com>
> Signed-off-by: Luis Henriques <lhenriques@suse.com>
> ---
> src/attr_replace_test.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/src/attr_replace_test.c b/src/attr_replace_test.c
> index 0720bfdc18ab..1ca9bf11ba58 100644
> --- a/src/attr_replace_test.c
> +++ b/src/attr_replace_test.c
> @@ -9,6 +9,7 @@
> #include <sys/types.h>
> #include <sys/xattr.h>
> #include <sys/stat.h>
> +#include <linux/limits.h>
>
> #define die() do { perror(""); \
> fprintf(stderr, "error at line %d\n", __LINE__); \
> @@ -44,6 +45,8 @@ int main(int argc, char *argv[])
> size = sbuf.st_blksize * 3 / 4;
> if (!size)
> fail("Invalid st_blksize(%ld)\n", sbuf.st_blksize);
> + if (size > XATTR_SIZE_MAX)
> + size = XATTR_SIZE_MAX;
Looks good to me (this or the min()/MIN()/whatever version),
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> value = malloc(size);
> if (!value)
> fail("Failed to allocate memory\n");
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-05-21 18:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-17 12:06 [PATCH] src/attr_replace_test: limit size of extended attribute value Luis Henriques
2019-05-19 17:27 ` Nikolay Borisov
2019-05-20 8:24 ` Luis Henriques
2019-05-20 8:27 ` Nikolay Borisov
2019-05-21 8:28 ` [PATCH v2] " Luis Henriques
2019-05-21 18:17 ` Darrick J. Wong
2019-05-20 16:23 ` [PATCH] " Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox