seq_file: introduce seq_setwidth() and seq_pad()

There are several users who want to know bytes written by seq_*() for
alignment purpose.  Currently they are using %n format for knowing it
because seq_*() returns 0 on success.

This patch introduces seq_setwidth() and seq_pad() for allowing them to
align without using %n format.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Joe Perches <joe@perches.com>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Git-commit: 839cc2a94cc3665bafe32203c2f095f4dd470a80)
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
CRs-fixed: 665291
Change-Id: I727d9af5ed320d717295c9d0f82c88623fb181c1
Signed-off-by: David Brown <davidb@codeaurora.org>
vsprintf: ignore %n again

This ignores %n in printf again, as was originally documented.
Implementing %n poses a greater security risk than utility, so it should
stay ignored.  To help anyone attempting to use %n, a warning will be
emitted if it is encountered.

Based on an earlier patch by Joe Perches.

Because %n was designed to write to pointers on the stack, it has been
frequently used as an attack vector when bugs are found that leak
user-controlled strings into functions that ultimately process format
strings.  While this class of bug can still be turned into an
information leak, removing %n eliminates the common method of elevating
such a bug into an arbitrary kernel memory writing primitive,
significantly reducing the danger of this class of bug.

For seq_file users that need to know the length of a written string for
padding, please see seq_setwidth() and seq_pad() instead.

Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Joe Perches <joe@perches.com>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Git-commit: 9196436ab2f713b823a2ba2024cb69f40b2f54a5
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
CRs-fixed: 665291
Change-Id: Id191acaf66e3c395df92b0a77331269b525e3cad
Signed-off-by: David Brown <davidb@codeaurora.org>
msm: cpp: Validate frame message before manipulating it

CPP frame message is used to send all frame data
to Microcontroller. It is sent every frame. CPP kernel
driver has to add information to it before transfer it.
The message has to be validated before manipulations.
If it is not valid the message and corresponding frame
are discarded.
Change-Id: Ib5b9b5d2e1886d3d671966b693ce212d58e34041
Signed-off-by: Manish Poddar <mpoddar@codeaurora.org>
seq_file: remove "%n" usage from seq_file users.

All seq_printf() users are using "%n" for calculating padding size,
convert them to use seq_setwidth() / seq_pad() pair.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Joe Perches <joe@perches.com>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Git-commit: 652586df95e5d76b37d07a11839126dcfede1621
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
[rsiddoji@codeaurora.org: Resolve merge conflicts with ipv4/6 ping
 changes in upstream]
CRs-fixed: 665291
Change-Id: Ia0416c9dbe3d80ff35f24f9c93c3543d1200a327
Signed-off-by: Ravi Kumar <rsiddoji@codeaurora.org>
Merge "seq_file: introduce seq_setwidth() and seq_pad()"
Merge "seq_file: remove "%n" usage from seq_file users."
Merge "vsprintf: ignore %n again"
Merge "msm: cpp: Validate frame message before manipulating it"
tspp: fix bam irq request preventing sleep

Registering and resetting BAM device upon initialization of tspp
driver requests bam irq resource, which prevents entering sleep.
Instead, BAM device is now initialized only when first needed which
is when the first channel is opened. BAM device is uninitialized
when channel is closed.

Change-Id: I056acea721fae164b91a2a5e3946028b4c2b6df2
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
ASoC: qcom: qdsp6v2: Initialize locks before use

Spinlock crash issue is fixed with this patch. This patch
is to initialize the locks before it is used.

Change-Id: Ib8200b5f2d89bd3e06db4a47e3682fe290fa6b3c
Signed-off-by: Anish Kumar <kanish@codeaurora.org>
msm: vidc: Fix various decoder downscalar issues

Queue output buffers without extradata to Venus.
Venus is returning UPSCALE_NOT_SUPPORTED error when
output2 size is bigger than output size. This change
suppresses this error as it is not fatal.

Change-Id: I8a3f708092b131400b88828f6c1a684f08b3f18a
Signed-off-by: Manikanta Sivapala <msivap@codeaurora.org>
ASoC: msm: qdsp6v2: adding volume per dev-id

Add volume mixer control per device id for pcm use case.

Change-Id: Ieab721541a5cdf494b7fad78abc06d4f667b4baf
Signed-off-by: Anish Kumar <kanish@codeaurora.org>
crypto: msm: add suspend/resume callback for qcedev driver

Make chanegs to add suspend/resume callback for qcedev driver, and
disable ce clocks when entering suspend and re-enable clocks in resume.

Change-Id: Ibeab1e7cb531af79ae973d7ff0d0ed2d776f6d6f
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Signed-off-by: William Clark <wclark@codeaurora.org>
msm: Create shadow files under /sys/kernel/ipv4

The TCP delayed ack parameters can be configured from user space
application which runs with non-root credentials and does not have
direct write access to /proc entries. This commit creates shadow
files under /sys/kernel/ipv4 which maps to /proc/sys/net/ipv4.

CRs-Fixed: 628139
Change-Id: Ib7242aaae930dbc02133e44c04e182ebc52bc89f
Signed-off-by: Ravi Joshi <ravij@codeaurora.org>
msm: mdss: set default value of panel mode gpio to -EINVAL

Default value of panel mode gpio is set to 0 which is still a
valid gpio and preventing access to legitimate owners when not
provided explicitly in device tree file. This patch addresses
the issue by changing default value to -EINVAL.

Change-Id: Ifc34513d21323af9843f6bbc85a3afca79891357
Signed-off-by: Vishnuvardhan Prodduturi <vproddut@codeaurora.org>
arm/dt: msm8974: Add support for voice svc driver

Add a new device that can be used by the voice svc
driver to allow userspace clients to send IOCTL
commands

CRs-fixed: 662362
Change-Id: I02c7113d0e3b50e68b89e76d60d5f807cb140971
Signed-off-by: Vicky Sehrawat <vickys@codeaurora.org>
Signed-off-by: Karthik Reddy Katta <a_katta@codeaurora.org>
ASoC: msm8974: Add VoWLAN dia link

Add VoWLAN dai link to the machine driver
to enable Voice over WLAN.

CRs-fixed: 662362
Change-Id: I3ada1f10436e5724670052901b648f46885d3bf6
Signed-off-by: Vicky Sehrawat <vickys@codeaurora.org>
Signed-off-by: Karthik Reddy Katta <a_katta@codeaurora.org>
msm: isp: Fix stats mask upon VFE reset.

When streamoff is issued, a HARD reset is done for VFE. This
causes the stats register to be reset to zero. It needs to be
properly initialized with the last used mask upon init.

Change-Id: I5e2fcab0358e63272f40458862f4cf6a7d3bb4bc
Signed-off-by: Abhishek Kondaveeti <akondave@codeaurora.org>
msm: mdss: Fix check for highest of overlap and prefill bw calc

This check is supposed to be used to get the max between overlap and
prefill bandwidth value. This value is used when calculating the ib
bandwidth value to request when bus bandwidth is updated. Having a value
that is too low results in mdp underrun.

Change-Id: Ie1302737f004d8e030f8d61c75d4301fe99b1069
Signed-off-by: Terence Hampson <thampson@codeaurora.org>
ARM: dts: msm: Add CX regulator Phandle to MDP node

The Phandle might change for different versions of
the msm8974 chip. Add the proper Phandle of CX regulator
to 8974pro version.

Change-Id: I6e8ab19c9765ff225a54a621cd001e8af1c7391d
Signed-off-by: Xiaoming Zhou <zhoux@codeaurora.org>