mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: miklos@szeredi.hu
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org
Cc: Ulrich Drepper <drepper@redhat.com>
Subject: [patch 2/9] VFS: check nanoseconds in utimensat
Date: Thu, 09 Aug 2007 11:20:48 +0200	[thread overview]
Message-ID: <20070809092455.212609837@szeredi.hu> (raw)
In-Reply-To: <20070809092046.656183199@szeredi.hu>

[-- Attachment #1: utimens_check_fix.patch --]
[-- Type: text/plain, Size: 1094 bytes --]

From: Miklos Szeredi <mszeredi@suse.cz>

utimensat() (and possibly other callers of do_utimes()) didn't check
if the nanosecond value was within the allowed range.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---

Index: linux/fs/utimes.c
===================================================================
--- linux.orig/fs/utimes.c	2007-08-09 11:01:30.000000000 +0200
+++ linux/fs/utimes.c	2007-08-09 11:04:19.000000000 +0200
@@ -38,6 +38,14 @@ asmlinkage long sys_utime(char __user *f
 
 #endif
 
+static bool nsec_valid(long nsec)
+{
+	if (nsec == UTIME_OMIT || nsec == UTIME_NOW)
+		return true;
+
+	return nsec >= 0 && nsec <= 999999999;
+}
+
 /* If times==NULL, set access and modification to current time,
  * must be owner or have write permission.
  * Else, update from *times, must be owner or super user.
@@ -52,6 +60,11 @@ long do_utimes(int dfd, char __user *fil
 	struct file *f = NULL;
 
 	error = -EINVAL;
+	if (times && (!nsec_valid(times[0].tv_nsec) ||
+		      !nsec_valid(times[1].tv_nsec))) {
+		goto out;
+	}
+
 	if (flags & ~AT_SYMLINK_NOFOLLOW)
 		goto out;
 

--

  parent reply	other threads:[~2007-08-09  9:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-09  9:20 [patch 0/9] assorted fixes and cleanups miklos
2007-08-09  9:20 ` [patch 1/9] unprivileged mounts: fix subtype handling miklos
2007-08-09  9:20 ` miklos [this message]
2007-08-09  9:20 ` [patch 3/9] fix execute checking in permission() miklos
2007-08-09  9:20 ` [patch 4/9] exec: remove unnecessary check for MNT_NOEXEC miklos
2007-08-09  9:20 ` [patch 5/9] fuse: fix setting i_mode bits miklos
2007-08-09  9:20 ` [patch 6/9] fuse: clean up execute permission checking miklos
2007-08-09  9:20 ` [patch 7/9] clean out unused code in dentry pruning miklos
2007-08-09  9:20 ` [patch 8/9] UML: remove unnecessary hostfs_getattr() miklos
2007-08-09  9:20 ` [patch 9/9] fix warnings is revoked_inode.c miklos

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=20070809092455.212609837@szeredi.hu \
    --to=miklos@szeredi.hu \
    --cc=akpm@linux-foundation.org \
    --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

all inboxes | Powered by JetHome®