mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Christoph Hellwig <hch@lst.de>, linux-kernel@vger.kernel.org
Subject: Re: bpfilter logging write errors in dmesg
Date: Mon, 27 Jul 2020 16:50:13 +0200	[thread overview]
Message-ID: <20200727145013.GA2154@lst.de> (raw)
In-Reply-To: <20200727141337.liwdfjxq4cwvt5if@wittgenstein>

Strange.  Can you add this additional debugging patch:

diff --git a/fs/read_write.c b/fs/read_write.c
index 4fb797822567a6..d0a8ada1efd954 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -369,8 +369,10 @@ int rw_verify_area(int read_write, struct file *file, const loff_t *ppos, size_t
 	int retval = -EINVAL;
 
 	inode = file_inode(file);
-	if (unlikely((ssize_t) count < 0))
+	if (unlikely((ssize_t) count < 0)) {
+		printk("count invalid: %zd\n", count);
 		return retval;
+	}
 
 	/*
 	 * ranged mandatory locking does not apply to streams - it makes sense
@@ -380,25 +382,35 @@ int rw_verify_area(int read_write, struct file *file, const loff_t *ppos, size_t
 		loff_t pos = *ppos;
 
 		if (unlikely(pos < 0)) {
-			if (!unsigned_offsets(file))
+			if (!unsigned_offsets(file)) {
+				printk("pos invalid: %lld\n", pos);
 				return retval;
+			}
 			if (count >= -pos) /* both values are in 0..LLONG_MAX */
 				return -EOVERFLOW;
 		} else if (unlikely((loff_t) (pos + count) < 0)) {
-			if (!unsigned_offsets(file))
+			if (!unsigned_offsets(file)) {
+				printk("pos+count invalid: %lld, %zd\n", pos, count);
 				return retval;
+			}
 		}
 
 		if (unlikely(inode->i_flctx && mandatory_lock(inode))) {
 			retval = locks_mandatory_area(inode, file, pos, pos + count - 1,
 					read_write == READ ? F_RDLCK : F_WRLCK);
-			if (retval < 0)
+			if (retval < 0) {
+				if (retval == -EINVAL)
+					printk("locks_mandatory_area\n");
 				return retval;
+			}
 		}
 	}
 
-	return security_file_permission(file,
+	retval = security_file_permission(file,
 				read_write == READ ? MAY_READ : MAY_WRITE);
+	if (retval == -EINVAL)
+		printk("security_file_permission\n");
+	return retval;
 }
 
 static ssize_t new_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos)

  parent reply	other threads:[~2020-07-27 14:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-27 10:46 Christian Brauner
2020-07-27 13:28 ` Christoph Hellwig
2020-07-27 14:13   ` Christian Brauner
2020-07-27 14:21     ` Christian Brauner
2020-07-27 14:50     ` Christoph Hellwig [this message]
2020-07-30  0:59       ` Rodrigo Madera
2020-07-30  6:06         ` Christoph Hellwig
2020-07-30 15:55           ` Rodrigo Madera
2020-07-30  7:09       ` Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200727145013.GA2154@lst.de \
    --to=hch@lst.de \
    --cc=christian.brauner@ubuntu.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome