Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Aug 2013 01:56:25 GMT
From:      Garrett Cooper <yaneurabeya@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/181155: [PATCH] *access*(2) does not handle invalid amodes properly
Message-ID:  <201308090156.r791uPX5059585@oldred.freebsd.org>
Resent-Message-ID: <201308090200.r79200VQ040999@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         181155
>Category:       kern
>Synopsis:       [PATCH] *access*(2) does not handle invalid amodes properly
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 09 02:00:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Garrett Cooper
>Release:        10-CURRENT
>Organization:
EMC Isilon
>Environment:
FreeBSD fuji-current.local 10.0-CURRENT FreeBSD 10.0-CURRENT #12 c3d9dc4-dirty: Thu Aug  8 18:48:47 PDT 2013     root@fuji-current.local:/usr/obj/usr/src/sys/FUJI-NOCOMPAT  i386
>Description:
Invalid access modes aren't properly handled in FreeBSD, so feeding in a valid like -1 won't result in a failed call.
>How-To-Repeat:
access("/", -1);
>Fix:


Patch attached with submission follows:

>From ceea6405b65a81a336b7c804dbe6c2dd0d84b72c Mon Sep 17 00:00:00 2001
From: Garrett Cooper <yanegomi@gmail.com>
Date: Thu, 8 Aug 2013 18:26:53 -0700
Subject: [PATCH] Handle invalid modes properly

Sponsored-by: EMC Isilon
---
 sys/kern/vfs_syscalls.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index a004ea0..9350821 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -2094,6 +2094,9 @@ kern_accessat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
 	struct nameidata nd;
 	int error;
 
+	if (amode & ~(F_OK | R_OK | W_OK | X_OK))
+		return (EINVAL);
+
 	/*
 	 * Create and modify a temporary credential instead of one that
 	 * is potentially shared.
-- 
1.8.3.4



>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308090156.r791uPX5059585>