Re: [PATCHv2] fibmap: Warn and return an error in case of block > INT_MAX

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 4/28/20 5:11 PM, Matthew Wilcox wrote:
On Tue, Apr 28, 2020 at 01:08:31PM +0530, Ritesh Harjani wrote:
@@ -71,6 +72,13 @@ static int ioctl_fibmap(struct file *filp, int __user *p)
  	block = ur_block;
  	error = bmap(inode, &block);
+ if (block > INT_MAX) {
+		error = -ERANGE;
+		pr_warn_ratelimited("[%s/%d] FS (%s): would truncate fibmap result\n",
+				    current->comm, task_pid_nr(current),
+				    sb->s_id);

Why is it useful to print the pid?
For e.g. a case where you have pthreads. pid could be different there.

And why print the superblock when we could print the filename instead? > We have a struct file, so we can printk("%pD4", filp) to print the
last four components of the pathname.


Sure, let me use below print msg then. This should cover everything now
If no objections, I could send this in v3. Pls, do let me know if
otherwise.

Since this has changed again from the 1st version, will drop all
Reviewed-by: and you could directly review v3 then.

pr_warn_ratelimited("[%s/%d] FS: %s File: %pD4 would truncate fibmap result\n",
				    current->comm, task_pid_nr(current),
				    sb->s_id, filp);

About %pD from (Documentation/core-api/printk-formats.rst)
========================================================
<..>
	%pd{,2,3,4}
	%pD{,2,3,4}

For printing dentry name; if we race with :c:func:`d_move`, the name might
be a mix of old and new ones, but it won't oops.  %pd dentry is a safer
equivalent of %s dentry->d_name.name we used to use, %pd<n> prints ``n``
last components.  %pD does the same thing for struct file.



-ritesh



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux