Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • L linux
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Kirill Smelkov
  • linux
  • Repository
You need to sign in or sign up before continuing.
  • linux
  • drivers
  • input
  • joydev.c
Find file BlameHistoryPermalink
  • Alexander Larkin's avatar
    Input: joydev - prevent use of not validated data in JSIOCSBTNMAP ioctl · f8f84af5
    Alexander Larkin authored Jul 04, 2021
    Even though we validate user-provided inputs we then traverse past
    validated data when applying the new map. The issue was originally
    discovered by Murray McAllister with this simple POC (if the following
    is executed by an unprivileged user it will instantly panic the system):
    
    int main(void) {
    	int fd, ret;
    	unsigned int buffer[10000];
    
    	fd = open("/dev/input/js0", O_RDONLY);
    	if (fd == -1)
    		printf("Error opening file\n");
    
    	ret = ioctl(fd, JSIOCSBTNMAP & ~IOCSIZE_MASK, &buffer);
    	printf("%d\n", ret);
    }
    
    The solution is to traverse internal buffer which is guaranteed to only
    contain valid date when constructing the map.
    
    Fixes: 182d679b ("Input: joydev - prevent potential read overflow in ioctl")
    Fixes: 999b874f
    
     ("Input: joydev - validate axis/button maps before clobbering current ones")
    Reported-by: default avatarMurray McAllister <murray.mcallister@gmail.com>
    Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: default avatarAlexander Larkin <avlarkin82@gmail.com>
    Link: https://lore.kernel.org/r/20210620120030.1513655-1-avlarkin82@gmail.com
    
    
    Cc: stable@vger.kernel.org
    Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
    f8f84af5
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7