From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC3CEF9C0; Sun, 17 May 2026 05:54:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778997245; cv=none; b=sgT7+F8mlIbJcZX/0PO6SQO/mU1ertz30mseFoY4Y98Qq+Z321GZcddc4j65zN+wvLRiEDZLd/aUXzfCZZVRQjHG+oVe9DGRAPjq3rlAtmPvV8ZMq9pHGr69LsYZVH4xnKKZS/gVjGOyM8ykZ6lEHTRmwMWKFUM2DGzjSZLGp50= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778997245; c=relaxed/simple; bh=t0yI2t35W6eRe10VKfaXc+7qm0DZ1XGhDhIF/nEZ+8E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pA2C3WNuKVOcPpu9CkbBp3ccQjWwFAwxmo3dOx3P4jeO1qUse9liVHLGout6IyhU+hHtJ+EgDUdz/+vMd22o1mD+Ef7lf23wZZ5ZEOvky0xcNBUT+fhbZydSzwGd0I5JHXKw1toZ18oZkvrA+3eZ8tgCtfikKDh9wkQgKRAN9ek= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=VpC/vJ/J; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="VpC/vJ/J" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1778997242; x=1810533242; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=t0yI2t35W6eRe10VKfaXc+7qm0DZ1XGhDhIF/nEZ+8E=; b=VpC/vJ/JULglIp9VnqaP5wNwPgPRl/yxAL9r/lcZRjkbjsdDk3yXYjfr Vr3ydteyXRtrL0uhD4zhR5Z8z1DpevIliGKIOqR40L1U0Nlt9iIQp0vXn uw8fff+QGVVGU33vHaI/zTg2TP0YteQT7f8EQWWgzG5OoXoXVwCvy5rAl Wl6Tk9r1O8pAPN1t3HoHz0x0SKj5haaIuFN0gBIex+PDIOaiyd88vHigS t9Llhw9Mse6DR0RrdjpEblUk5pAvt7EifQciU3hisemvIbgveQBUPTNwH zCdz2vF6FgM7xc96qrXUHI0jM0Fzh+kADwcUOaiiA8NRx136SKuLdh+Pp g==; X-CSE-ConnectionGUID: npuIJPJkRX6t/g9QC+kUqw== X-CSE-MsgGUID: SQ6yLk44TVSVcUaIDaphmg== X-IronPort-AV: E=McAfee;i="6800,10657,11788"; a="83758305" X-IronPort-AV: E=Sophos;i="6.23,239,1770624000"; d="scan'208";a="83758305" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2026 22:54:02 -0700 X-CSE-ConnectionGUID: EInY3zT1ROCVxYvVaZaXXg== X-CSE-MsgGUID: X6yuV4sGR6yaI/ecZybZBw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,239,1770624000"; d="scan'208";a="238118074" Received: from slindbla-desk.ger.corp.intel.com (HELO localhost) ([10.245.245.182]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2026 22:54:00 -0700 Date: Sun, 17 May 2026 08:53:56 +0300 From: Andy Shevchenko To: Stepan Ionichev Cc: andy@kernel.org, geert@linux-m68k.org, hcazarim@yahoo.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] auxdisplay: line-display: fix OOB read on zero-length message_store() Message-ID: References: <20260514174342.28451-1-sozdayvek@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260514174342.28451-1-sozdayvek@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo On Thu, May 14, 2026 at 10:43:42PM +0500, Stepan Ionichev wrote: > linedisp_display() unconditionally reads msg[count - 1] before > checking whether count is zero, so a write of zero bytes to the > message sysfs attribute hits msg[-1]: > > write(fd, "", 0); > > -> message_store(..., buf, count=0) > -> linedisp_display(linedisp, buf, count=0) > -> msg[count - 1] == '\n' ; OOB read > > The kernfs write buffer for that store is a 1-byte allocation > (kernfs_fop_write_iter() does kmalloc(len + 1) with len == 0), > so msg[-1] is a 1-byte read before the slab object. On a > KASAN-enabled kernel this trips an out-of-bounds report and > panics; on stock kernels it silently reads adjacent slab data > and, if that byte happens to be '\n', the following count-- > wraps ssize_t 0 to -1 and is then passed to kmemdup_nul(). > > linedisp_display() is reached from the message_store() sysfs > callback (drivers/auxdisplay/line-display.c message attribute, > mode 0644) and from the in-tree initial-message setup with > count == -1, so the OOB path is only userspace-triggerable via > zero-byte writes; vfs_write() does not short-circuit on > count == 0 and kernfs_fop_write_iter() dispatches the store > callback regardless. > > Guard the trailing-newline trim with a count check. The > existing if (!count) block then takes the clear-display path > unchanged. > > Affects every auxdisplay driver that registers via > linedisp_register() / linedisp_attach(): ht16k33, max6959, > img-ascii-lcd, seg-led-gpio. Pushed to my review and testing queue, thanks! -- With Best Regards, Andy Shevchenko