summaryrefslogtreecommitdiffstats
path: root/fs/binfmt_flat.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-09-01 11:39:13 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2017-09-04 19:05:15 -0400
commitbdd1d2d3d251c65b74ac4493e08db18971c09240 (patch)
tree71df247eeb367203c59a26eed8a384398c2d8131 /fs/binfmt_flat.c
parentc41fbad015dabb0a40ecca50c3ff5658eb6471ff (diff)
fs: fix kernel_read prototype
Use proper ssize_t and size_t types for the return value and count argument, move the offset last and make it an in/out argument like all other read/write helpers, and make the buf argument a void pointer to get rid of lots of casts in the callers. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/binfmt_flat.c')
-rw-r--r--fs/binfmt_flat.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index a1e6860b6f46..afb7e9d521d2 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -176,19 +176,14 @@ static int create_flat_tables(struct linux_binprm *bprm, unsigned long arg_start
176#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ 176#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
177#define RESERVED 0xC0 /* bit 6,7: reserved */ 177#define RESERVED 0xC0 /* bit 6,7: reserved */
178 178
179static int decompress_exec( 179static int decompress_exec(struct linux_binprm *bprm, loff_t fpos, char *dst,
180 struct linux_binprm *bprm, 180 long len, int fd)
181 unsigned long offset,
182 char *dst,
183 long len,
184 int fd)
185{ 181{
186 unsigned char *buf; 182 unsigned char *buf;
187 z_stream strm; 183 z_stream strm;
188 loff_t fpos;
189 int ret, retval; 184 int ret, retval;
190 185
191 pr_debug("decompress_exec(offset=%lx,buf=%p,len=%lx)\n", offset, dst, len); 186 pr_debug("decompress_exec(offset=%llx,buf=%p,len=%lx)\n", fpos, dst, len);
192 187
193 memset(&strm, 0, sizeof(strm)); 188 memset(&strm, 0, sizeof(strm));
194 strm.workspace = kmalloc(zlib_inflate_workspacesize(), GFP_KERNEL); 189 strm.workspace = kmalloc(zlib_inflate_workspacesize(), GFP_KERNEL);
@@ -204,13 +199,11 @@ static int decompress_exec(
204 } 199 }
205 200
206 /* Read in first chunk of data and parse gzip header. */ 201 /* Read in first chunk of data and parse gzip header. */
207 fpos = offset; 202 ret = kernel_read(bprm->file, buf, LBUFSIZE, &fpos);
208 ret = kernel_read(bprm->file, offset, buf, LBUFSIZE);
209 203
210 strm.next_in = buf; 204 strm.next_in = buf;
211 strm.avail_in = ret; 205 strm.avail_in = ret;
212 strm.total_in = 0; 206 strm.total_in = 0;
213 fpos += ret;
214 207
215 retval = -ENOEXEC; 208 retval = -ENOEXEC;
216 209
@@ -276,7 +269,7 @@ static int decompress_exec(
276 } 269 }
277 270
278 while ((ret = zlib_inflate(&strm, Z_NO_FLUSH)) == Z_OK) { 271 while ((ret = zlib_inflate(&strm, Z_NO_FLUSH)) == Z_OK) {
279 ret = kernel_read(bprm->file, fpos, buf, LBUFSIZE); 272 ret = kernel_read(bprm->file, buf, LBUFSIZE, &fpos);
280 if (ret <= 0) 273 if (ret <= 0)
281 break; 274 break;
282 len -= ret; 275 len -= ret;
@@ -284,7 +277,6 @@ static int decompress_exec(
284 strm.next_in = buf; 277 strm.next_in = buf;
285 strm.avail_in = ret; 278 strm.avail_in = ret;
286 strm.total_in = 0; 279 strm.total_in = 0;
287 fpos += ret;
288 } 280 }
289 281
290 if (ret < 0) { 282 if (ret < 0) {