Skip to content

Commit 769f526

Browse files
bvanasscheChristoph Hellwig
authored andcommitted
configfs: restore the kernel v5.13 text attribute write behavior
Instead of appending new text attribute data at the offset specified by the write() system call, only pass the newly written data to the .store() callback. Reported-by: Bodo Stroesser <[email protected]> Tested-by: Bodo Stroesser <[email protected]> Signed-off-by: Bart Van Assche <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 36a21d5 commit 769f526

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

fs/configfs/file.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,28 +177,22 @@ static ssize_t configfs_bin_read_iter(struct kiocb *iocb, struct iov_iter *to)
177177
return retval;
178178
}
179179

180-
/* Fill [buffer, buffer + pos) with data coming from @from. */
181-
static int fill_write_buffer(struct configfs_buffer *buffer, loff_t pos,
180+
/* Fill @buffer with data coming from @from. */
181+
static int fill_write_buffer(struct configfs_buffer *buffer,
182182
struct iov_iter *from)
183183
{
184-
loff_t to_copy;
185184
int copied;
186-
u8 *to;
187185

188186
if (!buffer->page)
189187
buffer->page = (char *)__get_free_pages(GFP_KERNEL, 0);
190188
if (!buffer->page)
191189
return -ENOMEM;
192190

193-
to_copy = SIMPLE_ATTR_SIZE - 1 - pos;
194-
if (to_copy <= 0)
195-
return 0;
196-
to = buffer->page + pos;
197-
copied = copy_from_iter(to, to_copy, from);
191+
copied = copy_from_iter(buffer->page, SIMPLE_ATTR_SIZE - 1, from);
198192
buffer->needs_read_fill = 1;
199193
/* if buf is assumed to contain a string, terminate it by \0,
200194
* so e.g. sscanf() can scan the string easily */
201-
to[copied] = 0;
195+
buffer->page[copied] = 0;
202196
return copied ? : -EFAULT;
203197
}
204198

@@ -227,10 +221,10 @@ static ssize_t configfs_write_iter(struct kiocb *iocb, struct iov_iter *from)
227221
{
228222
struct file *file = iocb->ki_filp;
229223
struct configfs_buffer *buffer = file->private_data;
230-
ssize_t len;
224+
int len;
231225

232226
mutex_lock(&buffer->mutex);
233-
len = fill_write_buffer(buffer, iocb->ki_pos, from);
227+
len = fill_write_buffer(buffer, from);
234228
if (len > 0)
235229
len = flush_write_buffer(file, buffer, len);
236230
if (len > 0)

0 commit comments

Comments
 (0)