From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by befuddled.reisers.ca (Postfix, from userid 65534) id 5D77A1EF6B4; Fri, 19 Jul 2013 08:38:02 -0400 (EDT) Received: from hurricane.the-brannons.com (unknown [IPv6:2001:470:1:41:a800:ff:fe3e:bc77]) by befuddled.reisers.ca (Postfix) with ESMTP id 693621EF56E for ; Fri, 19 Jul 2013 08:38:01 -0400 (EDT) Received: from localhost (unknown [IPv6:2602:4b:af3c:ae00:12bf:48ff:fe7c:5584]) by hurricane.the-brannons.com (Postfix) with ESMTPSA id DF9D478701 for ; Fri, 19 Jul 2013 05:39:23 -0700 (PDT) From: Chris Brannon To: "Speakup is a screen review system for Linux." Subject: Re: ot memory allocation question References: <41356f9b-e7c3-4522-b960-142abea1cedd@default> Date: Fri, 19 Jul 2013 05:37:52 -0700 In-Reply-To: <41356f9b-e7c3-4522-b960-142abea1cedd@default> (Don Raikes's message of "Fri, 19 Jul 2013 02:53:23 -0700 (PDT)") Message-ID: <87fvvawwrj.fsf@mushroom.PK5001Z> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.2 X-BeenThere: speakup@linux-speakup.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: "Speakup is a screen review system for Linux." List-Id: "Speakup is a screen review system for Linux." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Jul 2013 12:38:02 -0000 Don Raikes writes: > My solution: > > Allocate a new larger buffer inside of the userspace and copy_to_user > into the new buffer and then when I pass control to the "real" > sys_write function point it to the new buffer. > But the problem is how do I allocate this new buffer? There's no easy way to do this. You can't just pass your kernel buffer to the system call you are intercepting, since the intercepted call expects a user-space buffer. Have a look at this link for some inspiration: http://web.cs.wpi.edu/~cs4513/b05/proj1note2.txt Also be careful about the return value of the real sys_write system call. If you're passing it a buffer larger than the n bytes passed in from userspace, its return value can be greater than n. Don't just use it unmodified as the return value for your function. -- Chris