Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754341AbbLCUye (ORCPT ); Thu, 3 Dec 2015 15:54:34 -0500 Received: from mailhub.eng.utah.edu ([155.98.110.27]:23765 "EHLO mailhub.eng.utah.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754244AbbLCUyc (ORCPT ); Thu, 3 Dec 2015 15:54:32 -0500 To: linux-kernel@vger.kernel.org From: Scotty Bauer X-Enigmail-Draft-Status: N1110 Subject: Accessing user-land memory without safe functions Message-ID: <5660AC06.8080300@eng.utah.edu> Date: Thu, 3 Dec 2015 13:54:30 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-UCE-Score: -2.2 (--) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1221 Lines: 40 I Have been auditing a few drivers and have found some of them are accessing user-land memory without either mapping the pages in, or copying the data via the safe user access apis. The thing I have mostly been seeing is something along the lines of: ioctl(etc, etc, arg) { char buf[32]; __user *some_struct = (type cast) arg; size_t amount = some_struct->amount; ** do size check on amount ** copy_from_user(buf, some_struct->some_uland_addr, amount); } Above you see 2 unsafe user-land dereferences, the some_struct->amount and some_struct->some_uland_addr. Since I've seen this a couple times now I'm wondering if my understanding of touching user-land memory is flawed. For the above example Ioctl, the proper way to get access to those fields through the safe copy_from_user or get_user() functions, correct? I'm wondering if I should submit patches to fix the issues I've found, but now I'm doubting whether they're really issues at all. Thanks, Scotty -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/