kernel/printk/printk.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 4dae9cbe9259..7e4a0412d9ff 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -410,6 +410,7 @@ struct devkmsg_user { u64 seq; u32 idx; enum log_flags prev; + struct ratelimit_state rs; struct mutex lock; char buf[8192]; }; @@ -483,6 +484,8 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf, if (!user) return -EBADF; + if (!___ratelimit(&user->rs, current->comm)) + return 0; ret = mutex_lock_interruptible(&user->lock); if (ret) @@ -671,6 +674,9 @@ static int devkmsg_open(struct inode *inode, struct file *file) if (!user) return -ENOMEM; + /* Configurable? */ + ratelimit_state_init(&user->rs, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); + mutex_init(&user->lock); raw_spin_lock_irq(&logbuf_lock);